OpenStack oslo.log instrumentation for OpenTelemetry
Project description
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,otelTraceSampledandotelServiceNameonto every log record, so they are available to oslo.log'sContextFormatterformat strings; - installs an
OsloLogHandleron oslo.log's root logger so records are exported through the configuredlogger_provider(disable withenable_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.
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file opentelemetry_instrumentation_oslo_log-0.10.0.tar.gz.
File metadata
- Download URL: opentelemetry_instrumentation_oslo_log-0.10.0.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c18024bfd6497bb5ba477eaba161ecfc385ffab1fa949116abde231b4358a11
|
|
| MD5 |
62abf4daa5e1eed6866e854bcadcc2db
|
|
| BLAKE2b-256 |
d74b5ca1827830cdc2eebaa1ec28bbec6b4a082c32c557caee026abc7b2ae03d
|
Provenance
The following attestation bundles were made for opentelemetry_instrumentation_oslo_log-0.10.0.tar.gz:
Publisher:
publish-pypi.yml on daipham3213/opentelemetry-openstack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opentelemetry_instrumentation_oslo_log-0.10.0.tar.gz -
Subject digest:
0c18024bfd6497bb5ba477eaba161ecfc385ffab1fa949116abde231b4358a11 - Sigstore transparency entry: 2057435528
- Sigstore integration time:
-
Permalink:
daipham3213/opentelemetry-openstack@616b79ad8efb698c7d41e7b8d4d792e7a37ac34d -
Branch / Tag:
refs/tags/0.10.0 - Owner: https://github.com/daipham3213
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@616b79ad8efb698c7d41e7b8d4d792e7a37ac34d -
Trigger Event:
release
-
Statement type:
File details
Details for the file opentelemetry_instrumentation_oslo_log-0.10.0-py3-none-any.whl.
File metadata
- Download URL: opentelemetry_instrumentation_oslo_log-0.10.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bffd482c4c533e51450c71180e63669129b0b1efd67e8e29192cc0284cca665
|
|
| MD5 |
07aec0316921a19ddb83ebb905f0c0a8
|
|
| BLAKE2b-256 |
436cc10d477be05a5b8c7e8ed3588abb137bbc392008c705177492fc94749f0e
|
Provenance
The following attestation bundles were made for opentelemetry_instrumentation_oslo_log-0.10.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on daipham3213/opentelemetry-openstack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
opentelemetry_instrumentation_oslo_log-0.10.0-py3-none-any.whl -
Subject digest:
4bffd482c4c533e51450c71180e63669129b0b1efd67e8e29192cc0284cca665 - Sigstore transparency entry: 2057435787
- Sigstore integration time:
-
Permalink:
daipham3213/opentelemetry-openstack@616b79ad8efb698c7d41e7b8d4d792e7a37ac34d -
Branch / Tag:
refs/tags/0.10.0 - Owner: https://github.com/daipham3213
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@616b79ad8efb698c7d41e7b8d4d792e7a37ac34d -
Trigger Event:
release
-
Statement type: