proto-http). The Python SDK’s OTLPLogExporter speaks this protocol directly. Install it, set three env vars, and emit records through logging. Records land in the OTEL logs index pinned by your ingest API key (otel-logs-v0_9 in these examples).
Prerequisites
- A running Rootprint instance and its base URL — you’ll substitute it for
<your-rootprint>. - Python 3.8+ with
pip. - An ingest API key scoped to your target index. In Settings → API keys, click Create ingest key, give it a name, and pick the index (
otel-logs-v0_9for the examples here). See API keys.
Setup
1
Install the OpenTelemetry SDK
opentelemetry-instrumentation-asyncio.2
Set environment variables
3
Minimal working example
4
Verify in Rootprint
Open Search, filter on
service_name:my-python-service, and your record should appear within ~2 seconds (one batch interval).Structured logging
Attach attributes via theextra kwarg on the standard logging API. The OTEL handler translates them into log record attributes.
attributes.user_id and attributes.plan in Rootprint and become searchable and filterable.
Framework recipe: FastAPI
FastAPI apps work the same way. Set up the provider once at startup. Put the exporter config in your app factory so every worker process picks it up.Troubleshooting
- 401 / 403: the Bearer token is missing, malformed, or the
%20separator is not URL-encoded. Re-checkOTEL_EXPORTER_OTLP_LOGS_HEADERS. - Nothing in Search: records are batched; wait 2–5 s or call
logger_provider.force_flush()from your script. Also verifyOTEL_SERVICE_NAMEis set so you can filter onservice_name. - TLS errors against a self-signed endpoint: set
OTEL_EXPORTER_OTLP_CERTIFICATE=/path/to/ca.pem. - Records rejected by Quickwit: the API key is scoped to a specific index. If that index’s schema doesn’t accept the record, create an API key for a different index. See Manage indexes.
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
