Skip to main content

OpenTelemetry oslo.log Instrumentation

OpenStack oslo.log instrumentation for OpenTelemetry.

oslo.log builds on top of the standard library logging module. This instrumentor exports OpenStack service logs through the OpenTelemetry logs pipeline (and onward to an OTLP collector) while keeping them correlated with traces. On instrument() it:

  • injects the OpenTelemetry attributes otelTraceID, otelSpanID, otelTraceSampled and otelServiceName onto every log record, so they are available to oslo.log's ContextFormatter format strings;
  • installs an OsloLogHandler on oslo.log's root logger so records are exported through the configured logger_provider (disable with enable_log_auto_instrumentation=False);
  • maps oslo request context (request id, user/project ids, ...) onto exported record attributes (disable with map_oslo_context=False).

The exported log body is the raw log message; structured fields travel as attributes.

Correlation across threads/greenthreads: the trace a record is correlated to comes from the current OpenTelemetry context, which lives in a contextvars.Context that Python does not copy into worker threads or greenthreads. A record logged off the request thread would otherwise export trace_id/span_id as 0 — the common cause of "my oslo.log records have no trace id" in OpenStack. Enable opentelemetry-instrumentation-oslo-service, which carries the context across oslo.service's concurrency primitives (threading.Thread, futurist pools, and eventlet spawns).

oslo_log.log.setup rebuilds the root logger's handlers from oslo.config, dropping every existing handler. The instrumentor wraps setup so the exporting handler is re-attached afterwards, and keeps working even when setup runs (or runs again) after instrument().

Note: the handler is attached to oslo.log's root logger, not the stdlib root logger. Records from non-oslo libraries that log straight to the stdlib root are handled by opentelemetry-instrumentation-logging, not this package.

Usage

from opentelemetry.instrumentation.oslo_log import OsloLogInstrumentor

OsloLogInstrumentor().instrument(logger_provider=logger_provider)

To surface the injected trace context in oslo.log output, reference the fields from logging_context_format_string / logging_default_format_string in your oslo.config:

[DEFAULT]
logging_default_format_string = %(asctime)s %(levelname)s %(name)s [trace_id=%(otelTraceID)s span_id=%(otelSpanID)s] %(message)s
logging_context_format_string = %(asctime)s %(levelname)s %(name)s [%(request_id)s trace_id=%(otelTraceID)s span_id=%(otelSpanID)s] %(message)s

Exported context attributes

When map_oslo_context is enabled (the default), the following oslo request context fields are mapped onto exported log record attributes:

oslo context value exported attribute
request_id openstack.request_id
global_request_id openstack.global_request_id
user openstack.user_id
user_name openstack.user_name
project openstack.project_id
project_name openstack.project_name
domain openstack.domain_id
user_domain openstack.user_domain_id
project_domain openstack.project_domain_id
roles openstack.roles
resource_uuid openstack.resource_uuid

Authentication tokens are never exported.

Release files for opentelemetry-instrumentation-oslo-log 0.12.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opentelemetry-instrumentation-oslo-log 0.12.2
File Size Uploaded
opentelemetry_instrumentation_oslo_log-0.12.2.tar.gz 8.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for opentelemetry-instrumentation-oslo-log 0.12.2
File Interpreter ABI Platform
opentelemetry_instrumentation_oslo_log-0.12.2-py3-none-any.whl Python 3 none any Details

Total release size: 16.5 kB

Release files / opentelemetry_instrumentation_oslo_log-0.12.2.tar.gz

Download URL opentelemetry_instrumentation_oslo_log-0.12.2.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
bc0f7212ce2a502565106b8c5e839afb876e3420cee1f10e5546abd57e84a3c6
BLAKE2b-256 checksum
How to use checksums
c45986f3a5fa35adf6d1cc0d2a3d20c4f610d3ff38fb19b3f6cfc0ca0485f9b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 14, 2026.

Transparency log

Release files / opentelemetry_instrumentation_oslo_log-0.12.2-py3-none-any.whl

Download URL opentelemetry_instrumentation_oslo_log-0.12.2-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b2302414e9e272547a5a732df8f9b629035d1ffaef1df6a3e147c3630d18fa5
BLAKE2b-256 checksum
How to use checksums
ff839e5dc58ab324349833fbd74ef8a219a5ab53434b0c314f2a285faf9188dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 14, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page