This release is a pre-release and may not be stable for production use.
benzene-otel
OpenTelemetry integration for Benzene Python. The
port already traces itself — benzene.mesh.trace_middleware emits one TraceEvent per invocation —
but that tracing was Benzene-internal only, feeding a mesh collector rather than a general OTel
pipeline. This package exports it to a real OpenTelemetry SDK, and adds a response-as-event pattern
mirroring .NET's Benzene.ResponseEvents. Depends on benzene-core and benzene-mesh.
pip install "benzene-otel[otel]" # the [otel] extra pulls opentelemetry-api / opentelemetry-sdk
OtelTraceExporter is a benzene.mesh.TraceExporter, so it wires into the existing tracing
middleware — no second instrumentation. Each finished span maps one-to-one onto an OTel span: topic →
span name, started_at/duration_ms → OTel start/end nanoseconds, every field → a benzene.*
attribute, and the semantic status → the OTel span status.
from benzene.mesh import trace_middleware
from benzene.otel import OtelTraceExporter, RecordingSink, response_event_interception
# Trace export: forward the port's own spans to OpenTelemetry (real tracer acquired lazily).
definition.middleware.insert(0, trace_middleware(OtelTraceExporter(), service="orders"))
# Response-as-event: publish each result to a sink after the handler runs.
sink = RecordingSink() # swap for an OTel-log / outbox / audit-topic sink in production
definition.middleware.append(response_event_interception(sink))
OtelTraceExporter— consumes the mesh trace model and pushes eachTraceEventto an injected (or lazily created) OTel tracer. The tracer is a duck-typed seam (OtelTracer/OtelSpan), so a fake tracer exercises it with noopentelemetryinstalled; export is non-blocking and never raises, so a bad tracer can't break the invocation it observes.response_event_interception(sink, *, when=..., include_payload=...)— afterawait next(), emits aResponseEvent(topic, status, correlation id, optional payload) to aResponseEventSink. Emits every result by default; passwhen=lambda r: r.is_successfulfor successes only. A sink that raises is logged and swallowed — emitting an event never breaks the pipeline.RecordingSink— an in-memorylistof emitted events, the fake for tests and dogfooding.
Nothing here needs a collector, a real clock, or the OpenTelemetry package to run in tests: the tracer
and sink are injectable seams, so the whole surface is exercised in memory. Mirrors the role of .NET's
Benzene.Diagnostics OTel wiring and Benzene.ResponseEvents, and contributes the benzene.otel
subpackage to the shared benzene namespace.
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 benzene_otel-0.1.0b1.tar.gz.
File metadata
- Download URL: benzene_otel-0.1.0b1.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f020d1d918a5e969db4397b0af6e5c4cc44dcc27ea54914f6617c59ca9bb8768
|
|
| MD5 |
60d8b54089e4d42d2eb69f3fb6c3e8bc
|
|
| BLAKE2b-256 |
07f56fda80d41cebd5137fbb7b8f56681fca915bc3375a1ee60e64f25484666b
|
Provenance
The following attestation bundles were made for benzene_otel-0.1.0b1.tar.gz:
Publisher:
release.yml on daniellepelley/benzene-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
benzene_otel-0.1.0b1.tar.gz -
Subject digest:
f020d1d918a5e969db4397b0af6e5c4cc44dcc27ea54914f6617c59ca9bb8768 - Sigstore transparency entry: 2467247460
- Sigstore integration time:
-
Permalink:
daniellepelley/benzene-python@7f3c0d2abeeb3782a82a8e2621ee8b431bf02ca8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/daniellepelley
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7f3c0d2abeeb3782a82a8e2621ee8b431bf02ca8 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file benzene_otel-0.1.0b1-py3-none-any.whl.
File metadata
- Download URL: benzene_otel-0.1.0b1-py3-none-any.whl
- Upload date:
- Size: 10.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
438cd415685028fefb2e768beb77d080f600292ca33682b636beb9db12807e64
|
|
| MD5 |
52afdc2254a6e808c38af2e57a5819c8
|
|
| BLAKE2b-256 |
26c6f994247f6883bd84c8fedec9a877fd039ff7b195d80b0a83704aa4b5428e
|
Provenance
The following attestation bundles were made for benzene_otel-0.1.0b1-py3-none-any.whl:
Publisher:
release.yml on daniellepelley/benzene-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
benzene_otel-0.1.0b1-py3-none-any.whl -
Subject digest:
438cd415685028fefb2e768beb77d080f600292ca33682b636beb9db12807e64 - Sigstore transparency entry: 2467227727
- Sigstore integration time:
-
Permalink:
daniellepelley/benzene-python@7f3c0d2abeeb3782a82a8e2621ee8b431bf02ca8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/daniellepelley
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7f3c0d2abeeb3782a82a8e2621ee8b431bf02ca8 -
Trigger Event:
workflow_dispatch
-
Statement type: