hexastack-otel
Vendor-agnostic OpenTelemetry distributed tracing and CQRS telemetry middleware for Hexastack.
Part of the Hexastack Framework.
1. Architectural Overview
hexastack-otel provides pure hexagonal port interfaces for distributed tracing (TracingPort) and metrics collection (MetricsPort).
- Distributed Tracing: Backed by the official OpenTelemetry Python SDK (
OtelTracingAdapter,InMemoryTracingAdapter), linking correlation IDs and creating spans across CQRS Command/Query executions, HTTP endpoints, and gRPC RPCs. - Prometheus Metrics Engine: Backed by
prometheus_client(PrometheusMetricsAdapter), tracking throughput counters, execution duration histograms, and system gauges exposed over/metrics.
graph TD
CQRS["CQRS Command / Query Dispatch"]
MW["TracingMiddleware (order=12)"]
PORT["TracingPort"]
OTEL["OtelTracingAdapter\n(OpenTelemetry SDK)"]
MEM["InMemoryTracingAdapter\n(Test Isolation)"]
OTLP["OTLP Exporter\n(gRPC / HTTP)"]
COLLECTOR["OTel Collector / Jaeger / Grafana Tempo / Sift"]
CQRS --> MW
MW --> PORT
PORT -.-> OTEL
PORT -.-> MEM
OTEL --> OTLP
OTLP --> COLLECTOR
2. Quickstart
Installation
# Core OpenTelemetry SDK & TracingPort
pip install hexastack-otel
# With OTLP Protobuf Exporters (gRPC & HTTP)
pip install hexastack-otel[otlp]
Configuration (hexastack.toml or pyproject.toml)
[hexastack.otel]
service_name = "order-service"
endpoint = "http://localhost:4317"
exporter = "otlp_grpc" # "memory", "console", "otlp_grpc", "otlp_http"
sample_rate = 1.0
enabled = true
3. Automatic CQRS Tracing & Dynamic Feature Flagging
The TracingMiddleware automatically wraps every dispatched command or query in a scoped span:
- Dynamic Feature Flag Control: Evaluates
features.otel.tracingviaFeatureFlagPortdynamically per-message, enabling zero-downtime activation/deactivation of telemetry spans. - Span Name:
cqrs.CreateOrderCommand - Attributes:
message.name:CreateOrderCommandmessage.type:commandcorrelation.id:0724ec78-f952-4467...tenant.id:tenant-alphauser.id:usr_123
- Error Capture: Automatically catches unhandled exceptions, records them as span exception events, and sets span status to
ERROR.
Metadata
Release files for hexastack-otel 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hexastack_otel-0.4.0.tar.gz | 10.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hexastack_otel-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.3 kB
Release files / hexastack_otel-0.4.0.tar.gz
| Download URL | hexastack_otel-0.4.0.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
189a56adfd933cb90c98ecb99b19088d18b79ef5f36b0e50fed6b53887699786
|
|
BLAKE2b-256 checksum How to use checksums |
70eb8be5821fd648e304b5cd69becf20e49777cefe7be1b8b0bffec7dc719ef3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / hexastack_otel-0.4.0-py3-none-any.whl
| Download URL | hexastack_otel-0.4.0-py3-none-any.whl |
|---|---|
| Size | 18.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fe5e6d407fa340f4f83b88b5febf55609b2de11909627ed96456fb916c3d4100
|
|
BLAKE2b-256 checksum How to use checksums |
0309ad8bfd7c7fc2e0065407bc215e795e9abd29425e397dcbc66387ff6d0e14
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|