Skip to main content

hexastack-otel

hexastack-otel

Vendor-agnostic OpenTelemetry distributed tracing and CQRS telemetry middleware for Hexastack.

Part of the Hexastack Framework.

PyPI: hexastack-otel Python 3.13+ Coverage License: Apache 2.0


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.tracing via FeatureFlagPort dynamically per-message, enabling zero-downtime activation/deactivation of telemetry spans.
  • Span Name: cqrs.CreateOrderCommand
  • Attributes:
    • message.name: CreateOrderCommand
    • message.type: command
    • correlation.id: 0724ec78-f952-4467...
    • tenant.id: tenant-alpha
    • user.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.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hexastack-otel 0.6.0
File Size Uploaded
hexastack_otel-0.6.0.tar.gz 10.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hexastack-otel 0.6.0
File Interpreter ABI Platform
hexastack_otel-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 28.3 kB

Release files / hexastack_otel-0.6.0.tar.gz

Download URL hexastack_otel-0.6.0.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0dd790cebef169531713fcd93088a2fdc29585db391abc41ac9732d73cdb93a1
BLAKE2b-256 checksum
How to use checksums
3e817014a9e694835e090fd00d3d0ec493d43285d09570d23dec16a9bf218109
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.6.0-py3-none-any.whl

Download URL hexastack_otel-0.6.0-py3-none-any.whl
Size 18.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03b0a005aed86ee4dd3bd239a22452b978f3b546b7eef65fb88b5ffc7d4470a7
BLAKE2b-256 checksum
How to use checksums
174d99fb74f6292c2f2478b87d27f3d2115353f776e7eee338690d7d1345565c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

0.8.0

2 release files

0.7.0

2 release files

This release

0.6.0 This release

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page