OpenTelemetry oslo.service Instrumentation
OpenStack oslo.service instrumentation for OpenTelemetry.
oslo.service is OpenStack's service framework: it launches services and runs
their background work (ThreadGroup, looping/periodic calls, RPC servers) on
either a threading or an eventlet backend. This instrumentor emits no
telemetry of its own — it makes the active trace context survive the
concurrency boundaries oslo.service introduces, so spans and oslo.log records
created in spawned work stay correlated with the request that spawned them.
The trace a record/span is correlated to comes from the current OpenTelemetry
context, which lives in a contextvars.Context. Python does not copy that
context into new threads or greenthreads, so work handed to a worker would
otherwise start on a fresh, disconnected trace (or export trace_id/span_id
as 0).
On instrument() it:
- selects the oslo.service backend (threading by default) unless the host has
already chosen one — set
OTEL_PYTHON_OSLO_SERVICE_BACKEND=threading|eventletor passbackend="..."; - propagates the active context across oslo.service's concurrency primitives.
What gets propagated
| Backend | Primitive | Wrapped |
|---|---|---|
| threading | ThreadGroup.add_thread (a threading.Thread per task) |
threading.Thread.start / run |
| threading | looping / periodic calls (a futurist pool) |
futurist.ThreadPoolExecutor.submit |
| eventlet | greenthreads (ThreadGroup, hand-offs) |
eventlet.spawn / spawn_n / spawn_after, GreenPool.spawn / spawn_n, futurist.GreenThreadPoolExecutor.submit |
Not covered:
- stdlib
concurrent.futuresthread pools — enableopentelemetry-instrumentation-threading; threading.Timer/Threadsubclasses that overriderun, and cross-process (ProcessPoolExecutor) work.
Note: this context propagation previously lived in the oslo.messaging (eventlet spawns) and oslo.log (threads/futurist) instrumentors. It is consolidated here so it is defined once and benefits every OpenStack service, regardless of which of those instrumentors it also enables.
Usage
from opentelemetry.instrumentation.oslo_service import OsloServiceInstrumentor
OsloServiceInstrumentor().instrument()
To pair with log/trace instrumentation, enable it alongside the others (order does not matter):
OsloServiceInstrumentor().instrument()
OsloMessagingInstrumentor().instrument(tracer_provider=tracer_provider)
OsloLogInstrumentor().instrument(logger_provider=logger_provider)
Auto-instrumentation
Under opentelemetry-instrument, this package also ships an OpenTelemetry
distro and configurator so the instrumentor is enabled without any code change.
Eventlet monkey-patching
Services that run on the eventlet backend must monkey-patch the stdlib
before anything imports socket, ssl, select, etc. — otherwise the patch
is partial. A partial patch is not just a context-propagation problem: eventlet
no longer owns the sockets, so a connection (e.g. the RabbitMQ transport) that a
fork()-ing service — such as multi-backend cinder-volume under oslo.service
ProcessLauncher — establishes gets inherited across the fork and shared
between parent and child. oslo.messaging then logs "Process forked after
connection established!" and message ACKs are lost.
To beat that race the patch is applied from the distro — the earliest
in-process hook auto-instrumentation runs, before the SDK's OTLP exporter
imports the socket stack — and again from the configurator before its own
super()._configure(), so it is correct even with the stock distro. Opt in:
export OTEL_PYTHON_DISTRO=oslo_service
export OTEL_PYTHON_CONFIGURATOR=oslo_service
export OTEL_PYTHON_EVENTLET_MONKEY_PATCH=true
opentelemetry-instrument <your-service>
OTEL_PYTHON_EVENTLET_MONKEY_PATCH=truecallseventlet.monkey_patch()at the earliest point and pinsOTEL_PYTHON_OSLO_SERVICE_BACKEND=eventletso the backend matches the now-green stack. (eventletmust be installed; if it is not, a warning is emitted and startup continues unpatched.)OTEL_PYTHON_DISTRO=oslo_serviceselectsOsloServiceDistro, which is what makes the patch run early enough (before any exporter import). Without it only the configurator patches, which is later and may already be too late.OTEL_PYTHON_CONFIGURATOR=oslo_serviceis set automatically by the distro; set it explicitly too if you are not usingOTEL_PYTHON_DISTRO=oslo_service.
If you don't run on eventlet, none of these variables are needed.
Release files for opentelemetry-instrumentation-oslo-service 0.12.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| opentelemetry_instrumentation_oslo_service-0.12.5.tar.gz | 12.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| opentelemetry_instrumentation_oslo_service-0.12.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:24.4 kB
Release files / opentelemetry_instrumentation_oslo_service-0.12.5.tar.gz
| Download URL | opentelemetry_instrumentation_oslo_service-0.12.5.tar.gz |
|---|---|
| Size | 12.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dbda01fbec4adf423fd20a5dd294c36b048ddb4a9fad3644b644414674f7a6ce
|
|
BLAKE2b-256 checksum How to use checksums |
c3d72a1504068f465981901582f395271538c9debf7ecfd7f8286ce34ab88f55
|
| 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 20, 2026.
Transparency logRelease files / opentelemetry_instrumentation_oslo_service-0.12.5-py3-none-any.whl
| Download URL | opentelemetry_instrumentation_oslo_service-0.12.5-py3-none-any.whl |
|---|---|
| Size | 12.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4f1adbd06def595e72f75c0e8b2b620720f6bcb75babf63da72b2ef2c67572af
|
|
BLAKE2b-256 checksum How to use checksums |
59dddf735f17f11be7fec00f44cae5bc9e05e386597e79f534003af2333f4f2e
|
| 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 20, 2026.
Transparency log