Hello World Telemetry

chevron-rightPrerequisiteshashtag

Running Telemetry using Sentry + Open Telemetry

circle-info

All the code used in the following examples can be found in our GitHub repository bosa-example-apps/bosa-telemetry-sentry-example-appsarrow-up-right.

git clone https://github.com/GDP-ADMIN/bosa-example-apps.git
cd bosa-telemetry-sentry-example-apps

▶️ Execute the script for installing and start the dependencies

./start-dependencies.sh

This script will do the following:

  • Installing dependencies

🚀 Then run the app

poetry run python bosa_telemetry_sentry_example_app/main.py

🌐 After the app is running, try to hit the endpoints like curl http://127.0.0.1:8000 or curl http://127.0.0.1:8000/test-telemetry

this is the expected output

INFO: 127.0.0.1:34038 - "GET / HTTP/1.1" 200 OK {"message":"Application running with Sentry + OpenTelemetry.","telemetry_mode":"Sentry with OpenTelemetry","environment":"development"}

INFO: 127.0.0.1:34052 - "GET /test-telemetry HTTP/1.1" 200 OK {"message":"Telemetry test endpoint called.","using_opentelemetry":true,"check":"Check your Sentry dashboard for traces."}

The key indicators of success:

this is the snippet example how to initialize your code for using this:

chevron-rightInitialize examplehashtag

In the example you can init OpenTelemetryConfig ,SentryConfig ,TelemetryConfig. after you finisht hat you just need to call init_telemetry

How to setup your own DSN

Set up your SENTRY_DSN in .env file

circle-info

Currently the default value of SENTRY_DSN is using bosa-examples apps. you can ask bosa-eng@gdplabs.id to get access for sentry dashboard

this is the example of .env file (or you can see in the repository in .env.example)

Example how to add another instrumentation

This is the example if you want to add more instrumentation in your code, for example how to add instrumentation with HTTPX

  1. install the dependencies open telemetry instrumentation https

  1. Initiliaze the instrumentation

This is the list of instrumentation supported by open telemetry SDK: open telemetry instrumentation listarrow-up-right

Last updated