Skip to content

Instantly share code, notes, and snippets.

@amitava82
Created July 12, 2025 06:41
Show Gist options
  • Select an option

  • Save amitava82/5c0636a572a0f6ec770658539ffe2dfb to your computer and use it in GitHub Desktop.

Select an option

Save amitava82/5c0636a572a0f6ec770658539ffe2dfb to your computer and use it in GitHub Desktop.
Otel Python auto instrumentation

Setup

Run the following commands to install the appropriate packages.

pip install opentelemetry-distro opentelemetry-exporter-otlp
opentelemetry-bootstrap -a install

Run

Run the application with following commands.

export DJANGO_SETTINGS_MODULE=helloworld_project.settings
export OTEL_EXPORTER_OTLP_ENDPOINT=https://otel.kloudmate.com:4318
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=<private key>"
export OTEL_SERVICE_NAME=<service_name> 
opentelemetry-instrument --traces_exporter otlp --metrics_exporter otlp --exporter_otlp_protocol http/protobuf python manage.py runserver --noreload
  • Your must define DJANGO_SETTINGS_MODULE appropriately. In this example my project is helloworld_project
  • Replace <service_name> with your application name
  • Replace <private key> with your private workspace API key

More Details RTFM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment