logging module — no log statement changes needed — and traces are emitted via a tracer provider.
Prerequisites
- Python 3.8 or later
- pip
- A running OTel Collector configured to forward logs and traces to Bronto — see Connect Open Telemetry to Bronto
- OpenTelemetry Python SDK documentation
Install dependencies
Configure the log bridge
The OTel Python SDK ships aLoggingHandler that bridges Python’s standard logging module into OTel. Attach it to the root logger (or any specific logger) and all log records flow through the OTel pipeline.
Pass a specific logger name to
logging.getLogger("my_app") if you only want to instrument part of your application.Configure the OTLP exporter
Wire aBatchLogRecordProcessor and OTLPLogExporter into the LoggerProvider. By default the OTel Collector listens for OTLP/HTTP on port 4318 — no authentication is needed here since the Collector handles the connection to Bronto.
Set resource attributes
Resource attributes are attached to every log record exported from this process. Two attributes drive how Bronto organises incoming logs:
Pass a
Resource when constructing the LoggerProvider:
Complete example
The snippet below puts all the pieces together. Copy it into your application’s startup code and call it once before your first log statement.configure_logging.py
Verify delivery
After running your application, check both signals in Bronto:- Logs: open the Search page and filter by the dataset name you set in
service.name— your log records should appear within a few seconds. - Traces: open the Explore Traces page and filter by the same
service.name— your spans should appear within a few seconds.
- The OTel Collector is running and reachable at the configured endpoint.
- The Collector’s pipeline includes a
logspipeline with anotlpreceiver and the Bronto exporter — see Connect Open Telemetry to Bronto. BatchLogRecordProcessorexports on a background thread — make sure your process does not exit before the first flush. For short-lived scripts, replace it withSimpleLogRecordProcessorto export synchronously.
Synchronous export for scripts
Traces
Install tracing dependencies
No additional packages are needed —opentelemetry-sdk and opentelemetry-exporter-otlp-proto-http already include tracing support.
Configure the tracer provider
Create aTracerProvider using the same Resource you built for logging, then register it as the global tracer provider.
configure_tracing.py
Resource ensures service.name and service.namespace are identical on both logs and traces.
Creating spans
Get a tracer from the global provider and wrap operations in spans:trace_id and span_id — no manual propagation needed.
Complete example
app.py
GenAI semantic conventions
If your application calls an LLM (OpenAI, Anthropic, Amazon Bedrock, etc.), OpenTelemetry defines a dedicated set of GenAI semantic conventions —gen_ai.* attributes for model, token usage, and prompt/response content. Python has the richest GenAI auto-instrumentation of any OTel SDK today.
This page was verified on July 17, 2026. GenAI libraries and semantic conventions are evolving rapidly, so package configuration and emitted attributes can change between releases. Keep your instrumentation current and verify the fields emitted by the version you deploy.
Auto-instrumentation
Install the instrumentation package for your provider alongside the SDK packages from Install dependencies:chat gpt-4o-mini carrying gen_ai.provider.name (the deprecated gen_ai.system on older instrumentation versions), gen_ai.request.model, gen_ai.usage.input_tokens / output_tokens, and gen_ai.response.finish_reasons, instead of a plain HTTP client span.
The Anthropic package installed by
pip install opentelemetry-instrumentation-anthropic is maintained as part of OpenLLMetry, not OTel contrib. See OpenLLMetry for setup, schema guidance, and content-capture controls.Experimental: capturing prompt and response content
The official Python instrumentations (openai-v2, botocore) control content capture with two environment variables, both off by default:
Manual spans
Where no auto-instrumentation package exists for your provider, set thegen_ai.* attributes yourself on a span, following the same conventions:
gen_ai.input.messages / gen_ai.output.messages, and how to search and aggregate GenAI fields in Bronto.
Direct export to Bronto
If you are not using an OTel Collector, export directly to Bronto by replacing the exporter endpoints and adding your API key:
See API Keys for how to create a key with ingestion permissions. No other changes to the rest of the setup are required.

