Skip to main content

nodus-observability

OpenTelemetry bootstrap, Prometheus registry, structured JSON logging, and async-safe trace ContextVars. Zero required dependencies beyond python-json-logger — OTel and Prometheus are optional extras.

Install

pip install nodus-observability                    # core only
pip install "nodus-observability[metrics]"         # + prometheus-client
pip install "nodus-observability[otel]"            # + opentelemetry stack
pip install "nodus-observability[all]"             # everything

Trace context

from nodus_observability import set_trace_id, get_trace_id, reset_trace_id, ensure_trace_id

tok = set_trace_id("req-abc-123")
print(get_trace_id())    # "req-abc-123"
reset_trace_id(tok)

Structured logging

from nodus_observability import configure_logging, get_trace_id

configure_logging(
    env="production",
    log_level="INFO",
    get_trace_id_fn=get_trace_id,   # inject trace_id from ContextVar
)

OTel tracing

from nodus_observability import init_otel, get_tracer

init_otel(service_name="my-service")   # reads OTEL_EXPORTER_OTLP_ENDPOINT
tracer = get_tracer("my-module")

with tracer.start_as_current_span("my-operation") as span:
    span.set_status("ok")

Prometheus metrics

from nodus_observability import create_registry, Counter

REGISTRY = create_registry()   # never use the default global registry

requests_total = Counter(
    "myapp_requests_total",
    "Total requests",
    ["method", "status"],
    registry=REGISTRY,
)
requests_total.labels(method="GET", status="200").inc()

Extracted from

AINDY/platform_layer/trace_context.py, otel.py, metrics.py, and log_config.py in the A.I.N.D.Y. runtime.

Metadata

Release files for nodus-observability 0.1.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 nodus-observability 0.1.0
File Size Uploaded
nodus_observability-0.1.0.tar.gz 10.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nodus-observability 0.1.0
File Interpreter ABI Platform
nodus_observability-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.8 kB

Release files / nodus_observability-0.1.0.tar.gz

Download URL nodus_observability-0.1.0.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e2cd4b336bbc812db994c1f3c83336af8df865d21c47f32027ce752ebde3aa41
BLAKE2b-256 checksum
How to use checksums
d56f7209f37600daec9b488069edec8623c4489d3232345032565af8f8c0cada
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / nodus_observability-0.1.0-py3-none-any.whl

Download URL nodus_observability-0.1.0-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
96f5c25bd0e7081a03253bdf940f9acb7d3809a5ab03a03010c99a4b6ad5b58b
BLAKE2b-256 checksum
How to use checksums
0afe623e7f716d099b0071603aac5986108bc3a96972cdc77c4943bc4cc97cd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.1.0 This release

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