OpenTelemetry Tracing
JustAPI includes built-in OpenTelemetry tracing with OTLP gRPC export.
Enabling Tracing
Section titled “Enabling Tracing”from justapi.tracing import init_otlp_tracing
init_otlp_tracing( endpoint="http://localhost:4317", service_name="my-justapi-service",)Jaeger Stack
Section titled “Jaeger Stack”Generated projects include docker-compose.otel.yml:
services: jaeger: image: jaegertracing/all-in-one:latest ports: - "16686:16686" # Jaeger UI - "4318:4318" # OTLP HTTP - "4317:4317" # OTLP gRPCdocker compose -f docker-compose.otel.yml up -dAccess the Jaeger UI at http://localhost:16686.
Trace Spans
Section titled “Trace Spans”Each request generates spans:
| Span | Description |
|---|---|
request |
Full HTTP request lifecycle |
handler.execute |
Python handler execution |
middleware.* |
Each middleware in the chain |
db.query |
Database query execution |
db.execute |
Database write execution |
Context Propagation
Section titled “Context Propagation”Trace context propagates across the Python↔Rust boundary using thread-local variables. No manual instrumentation is needed.
Environment Variables
Section titled “Environment Variables”| Variable | Description |
|---|---|
OTEL_SERVICE_NAME |
Service name for traces |
OTEL_EXPORTER_OTLP_ENDPOINT |
OTLP collector endpoint |
RUST_LOG |
Log level (set to info for production) |
See Also
Section titled “See Also”- Metrics & Monitoring — Prometheus metrics
- Structured Logging — Log configuration
- Health Checks — Health endpoints