Python observability with OpenTelemetry

Install the OpenTelemetry distro, bootstrap the instrumentations for the libraries you already use, and run your app under opentelemetry-instrument. Flask, FastAPI, Django, SQLAlchemy, requests and dozens of other libraries are traced without code changes.

POST /checkout 8 spans · 203ms
DurationStatus
/checkoutapi-gateway
203ms200
validateTokenauth-service
24.0msOk
createOrderorder-service
111msOk
validateInventory
20.0msOk
reserveItems
16.0msOk
processPaymentpayment-svc
57.0msOk
chargeCard
45.0msOk
sendConfirmationorder-service
30.0msOk
Quick start

Up and running in minutes

1

Install the distro and bootstrap instrumentations

bash
pip install opentelemetry-distro opentelemetry-exporter-otlp

# Installs an instrumentation package for every supported library in your environment
opentelemetry-bootstrap -a install
2

Run under opentelemetry-instrument

bash
export OTEL_SERVICE_NAME="my-python-app"
export OTEL_EXPORTER_OTLP_PROTOCOL="http/protobuf"
export OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.maple.dev"
export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer your-api-key"
export OTEL_RESOURCE_ATTRIBUTES="deployment.environment.name=production"

opentelemetry-instrument python app.py

What you get

Automatic instrumentation for Python

Flask/FastAPI routes

Automatic spans for every HTTP request with route, method, and status code attributes.

SQLAlchemy queries

Database query spans with statement text, connection details, and execution duration.

HTTP requests

Outgoing requests via urllib3 and the requests library traced with context propagation.

Redis calls

Redis command spans with operation type, key patterns, and response time.

Celery tasks

Distributed task spans that link producers and consumers across worker processes.

gRPC calls

Client and server gRPC spans with service, method, and status code attributes.

통합

Other integrations

오늘 첫 트레이스를 확인하세요.

SDK를 추가하고 OTLP 익스포터를 Maple로 향하게 하면 트레이스가 도착합니다.

maple.dev: OpenTelemetry 위의 옵저버빌리티