Skip to main content
Pre-release

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 each TraceEvent to an injected (or lazily created) OTel tracer. The tracer is a duck-typed seam (OtelTracer / OtelSpan), so a fake tracer exercises it with no opentelemetry installed; 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=...) — after await next(), emits a ResponseEvent (topic, status, correlation id, optional payload) to a ResponseEventSink. Emits every result by default; pass when=lambda r: r.is_successful for successes only. A sink that raises is logged and swallowed — emitting an event never breaks the pipeline.
  • RecordingSink — an in-memory list of 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

benzene_otel-0.1.0b1.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

benzene_otel-0.1.0b1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

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

Hashes for benzene_otel-0.1.0b1.tar.gz
Algorithm Hash digest
SHA256 f020d1d918a5e969db4397b0af6e5c4cc44dcc27ea54914f6617c59ca9bb8768
MD5 60d8b54089e4d42d2eb69f3fb6c3e8bc
BLAKE2b-256 07f56fda80d41cebd5137fbb7b8f56681fca915bc3375a1ee60e64f25484666b

See more details on using hashes here.

Provenance

The following attestation bundles were made for benzene_otel-0.1.0b1.tar.gz:

Publisher: release.yml on daniellepelley/benzene-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for benzene_otel-0.1.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 438cd415685028fefb2e768beb77d080f600292ca33682b636beb9db12807e64
MD5 52afdc2254a6e808c38af2e57a5819c8
BLAKE2b-256 26c6f994247f6883bd84c8fedec9a877fd039ff7b195d80b0a83704aa4b5428e

See more details on using hashes here.

Provenance

The following attestation bundles were made for benzene_otel-0.1.0b1-py3-none-any.whl:

Publisher: release.yml on daniellepelley/benzene-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0b1 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page