Observe applications and machine-learning models written using Python.
Instrumenting your Python application to generate traces, logs, and metrics is a powerful way to gain deep insights into its behavior and performance. By adding instrumentation, you enable your application to emit valuable data that can be used for monitoring, troubleshooting, and optimization.
The OpenTelemetry Python SDK provides a ready-made auto-instrumentation package that simplifies instrumentation:
1. Install the OpenTelemetry distribution package and OTLP exporter:
The opentelemetry-distro
package includes the necessary dependencies for auto-instrumentation. The OTLP exporter enables sending telemetry data to Dash0.
2. Run the bootstrap command:
This command detects installed libraries and installs the corresponding OpenTelemetry instrumentation packages.
The auto-instrumentation package applies tracing, metrics, and logging instrumentation to supported frameworks without modifying application code.
To send data to Dash0, configure the following settings:
1. Specify the application service name:
This helps identify your service in Dash0.
Replace my-first-observable-service
with a meaningful name for your application.
2. Set up the data export endpoint and authorization token:
Define where OpenTelemetry sends the telemetry data.
Note: You can specify which dataset to send data to by adding the Dash0-Dataset
header. For example:
For more information, see the dataset documentation.
3. Run your application with OpenTelemetry instrumentation:
Use the opentelemetry-instrument
command before running your application.
For frameworks like Flask:
To see which libraries are automatically instrumented, refer to the OpenTelemetry registry.