logging module, with the OpenTelemetry SDK’s OTLPLogExporter sending them over OTLP HTTP (http/protobuf).
Prerequisites
- A running Rootprint instance. Substitute its host for
<your-rootprint>. - Python 3.10+ with
pip. - An ingest API key scoped to an OpenTelemetry logs index such as
otel-logs-v0_9. In Settings → API keys, click Create ingest key and pick the index. See API keys.
Setup
1
Install the OpenTelemetry SDK
opentelemetry-instrumentation-logging provides the LoggingHandler that bridges the standard logging module.2
Set environment variables
3
Minimal working example
4
Verify in Rootprint
Open Logs, filter on
service_name:my-python-service, and your record should appear within a few seconds.Structured logging
Pass attributes in theextra argument of the standard logging API:
attributes.user_id and attributes.plan, and you can search and filter on them.
Framework recipe: FastAPI
Set up the provider once at startup, in the app’slifespan handler, so every worker process picks it up.
Troubleshooting
- 401 or 403: the ingest API key is missing or wrong, or the space after
Bearerisn’t written as%20. CheckOTEL_EXPORTER_OTLP_LOGS_HEADERS. See Response codes. 200but no records in Logs: the ingest API key is scoped to an index without the OpenTelemetry logs schema, so the records are discarded. See Index target.- Nothing in Logs from a short-lived script: the batch processor buffers records. Shut down the logger provider before exit, as the minimal example does.
- TLS errors against a self-signed endpoint: set
OTEL_EXPORTER_OTLP_CERTIFICATE=/path/to/ca.pem.
Related
- OTLP reference: endpoint URL, response codes, env-var table
- Indexes:
otel-logs-v0_9schema and custom-index concepts - Manage indexes: map log level, message, and traceback fields

