Cómo hacer un seguimiento de una aplicación de C++
Aprende a compilar y ejecutar el ejemplo de C++ con OpenTelemetry y exportar los seguimientos a Cloud Trace. En este ejemplo, se usa el cliente de C++ de Google Cloud Pub/Sub para publicar 5 mensajes y se exportan los seguimientos a Cloud Trace.
Antes de comenzar
- Accede a tu cuenta de Google Cloud. Si eres nuevo en Google Cloud, crea una cuenta para evaluar el rendimiento de nuestros productos en situaciones reales. Los clientes nuevos también obtienen $300 en créditos gratuitos para ejecutar, probar y, además, implementar cargas de trabajo.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Asegúrate de que la facturación esté habilitada para tu proyecto de Google Cloud.
-
Enable the Pub/Sub and Trace APIs.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Asegúrate de que la facturación esté habilitada para tu proyecto de Google Cloud.
-
Enable the Pub/Sub and Trace APIs.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
Configurar
Crea un tema con el ID
my-topic
:gcloud pubsub topics create my-topic
Consulta el código fuente de muestra de C++:
git clone --depth 1 https://github.com/GoogleCloudPlatforms/cpp-samples
Publica mensajes
Compila y ejecuta el ejemplo:
cd cpp-samples/pubsub-open-telemetry bazel run //:quickstart -- $(gcloud config get project) my-topic
Después de ejecutar este ejemplo, verás las siguientes líneas impresas en la consola.
Sent message with id: (9095112996778043) Sent message with id: (9095112996778044) Sent message with id: (9095112996778045) Sent message with id: (9095112996778046) Sent message with id: (9095112996778047)
Cómo ver los seguimientos
En la barra de búsqueda de la consola de Google Cloud, ingresa Trace Overview. En los resultados de la búsqueda, ve a la sección Products & Pages y selecciona la página Overview de Trace:
Limpia
Sigue estos pasos para evitar que se apliquen cargos a tu cuenta de Google Cloud por los recursos que se usaron en esta página.
Borra el tema que se creó en el ejemplo:
gcloud pubsub topics delete my-topic
¿Qué sigue?
- Obtén más información sobre C++ y OpenTelemetry.
- Encuentra más ejemplos de C++.
- Obtén más información sobre las APIs de Pub/Sub.
- Prueba más ejemplos de OpenTelemetry de Pub/Sub de C++.