Sitelet https://maple.dev/integrations/python/
Python

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.

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.

Live trace preview

See your Python traces

Trace: Python App
POST /api/orders
234ms
FastAPI middleware
8ms
sqlalchemy SELECT products
45ms
requests.get https://payment.api
156ms
Explore more

Other integrations

See your first trace today.

Add the SDK, point your OTLP exporter at Maple, and traces arrive.

maple.dev: observability on OpenTelemetry