OpenTelemetry provides flexible and powerful support for Python applications. With both auto-instrumentation and manual APIs, you can easily capture traces, logs, and metrics from your services.
Auto-instrumentation lets you automatically trace common libraries such as HTTP clients, database drivers, and more without needing to modify your code. OpenTelemetry provides auto-instrumentation libraries for many popular languages, making it fast to get started with tracing.In Python, you can use the OpenTelemetry Distro package to automatically instrument your application:
Manual instrumentation gives you full control over your traces, allowing you to create spans wherever needed. You can customize span names, attributes, and relationships to capture the most important parts of your application’s flow.You can manually create spans and manage tracing in Python using the OpenTelemetry APIs:
Copy
Ask AI
from opentelemetry import tracetracer = trace.get_tracer(name)with tracer.start_as_current_span("my-span"): # your application logic pass
Once your application is instrumented, you need to export telemetry data. PlayerZero supports the OpenTelemetry Protocol (OTLP) over HTTP. You can configure your OpenTelemetry SDK to export traces, logs, and metrics to PlayerZero’s endpoint by setting the endpoint URL and API token.In Python, you can configure the OTLP exporter by setting environment variables or through your instrumentation code.Key environment variables:
Using an OpenTelemetry Collector is optional for most setups. A collector can help route telemetry to multiple destinations, perform transformations, or batch data efficiently. You might use a collector if you want to forward telemetry to both PlayerZero and another observability platform simultaneously.You can optionally forward your telemetry through an OpenTelemetry Collector for routing, filtering, or enriching spans before reaching PlayerZero.