qx-observability
One-call observability setup for Qx services — structured logging (structlog), distributed tracing (OpenTelemetry), Prometheus metrics, and health probes.
What lives here
qx.observability.setup_observability— configures logging and tracing, returns a(Metrics, HealthRegistry)pair. This is the only call most services need.qx.observability.Metrics— Prometheus counter/histogram wrapper. Pass a customCollectorRegistryin tests to avoid collisions.qx.observability.HealthRegistry— register named health checks; aggregates their results for/healthzand/readyz.qx.observability.configure_logging— structlog pipeline with JSON output in production and pretty console output in development.qx.observability.configure_tracing— OpenTelemetry SDK setup; exports to an OTLP endpoint (Tempo, Jaeger, etc.) or console.qx.observability.get_logger— returns a bound structlog logger for a given name.qx.observability.get_tracer— returns an OTelTracer; use withtrace_span.qx.observability.trace_span— async context manager that wraps a block in an OTel span.qx.observability.inject_context/extract_context— propagate trace context through message headers (W3C TraceContext format).qx.observability.MetricsBehavior/TracingBehavior— Mediator pipeline behaviors that instrument every command/query automatically.
Usage
from qx.observability import setup_observability
# In application bootstrap
metrics, health = setup_observability(
settings,
otlp_endpoint="http://tempo:4317",
)
# Register a health check
@health.check("database")
async def _db_check() -> bool:
return await db.ping()
# In any module
from qx.observability import get_logger, trace_span
log = get_logger(__name__)
async def do_work() -> None:
async with trace_span("my-operation"):
log.info("doing work", key="value")
Mediator pipeline wiring
from qx.cqrs import compose
from qx.observability import MetricsBehavior, TracingBehavior
pipeline = compose(
TracingBehavior(get_tracer("mediator")),
MetricsBehavior(metrics),
)
mediator = Mediator(container, pipeline=pipeline)
Design rules
- Logging is structured (key-value) everywhere — no f-string log messages in framework code.
setup_observability()is idempotent in tests when a freshCollectorRegistryis passed viametrics_registry.- Trace context is propagated automatically via
RequestContextMiddlewareon ingress andinject_contexton egress (outbox relay, NATS publisher).
Metadata
Release files for qx-observability 1.1.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 | Provenance | Actions |
|---|---|---|---|---|
| qx_observability-1.1.0.tar.gz | 11.7 kB | Without provenance | Details for qx_observability-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| qx_observability-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for qx_observability-1.1.0-py3-none-any.whl |
Total release size: 24.8 kB
Release files / qx_observability-1.1.0.tar.gz
| Download URL | qx_observability-1.1.0.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c4399803b6eb9e7a6bf3fd9756a6a53bbfb1c4ac083585adf3634b21f462515f
|
|
BLAKE2b-256 checksum How to use checksums |
2b7d5becd38daa844c31747fa3b5b2d67a9d5cd2334b8a76f91b7505613d6c2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / qx_observability-1.1.0-py3-none-any.whl
| Download URL | qx_observability-1.1.0-py3-none-any.whl |
|---|---|
| Size | 13.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
faef3234231f6ce104e44cee0035b43d7d543a703c9563cc9f55af6120ac1efc
|
|
BLAKE2b-256 checksum How to use checksums |
6f726c2e16084c4df21e31b0eecfc505297b48e8b6fa6eaf097dae81ba4749a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for qx-observability 1.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.