Skip to main content

omnixys-observability

Omnixys shared observability package — OpenTelemetry tracing, structlog structured logging, Prometheus metrics, request-context propagation and error classification.

Installation

pip install omnixys-observability

Features

  • Tracing: OTLP HTTP trace export with ratio/always-on sampling, FastAPI/httpx/logging auto-instrumentation, and a @span decorator for functions and methods
  • Logging: structlog JSON (or colored pretty) console output, OTLP log export, context enrichment (request/correlation id, user, tenant, trace ids), and recursive secret redaction
  • Metrics: Prometheus counters/histograms/gauges for HTTP, GraphQL, DB, Kafka, cache, rate limiting, auth and outbox — plus RateLimitMetrics and SloMetrics helpers
  • Request context: contextvars-based RequestContext propagation across async boundaries
  • Errors: classify_error()/ErrorClassifier buckets into server_error / client_error / internal_error
  • Runtime: configure_observability() one-call setup of traces + logs with a shared service resource

Usage

One-call setup

from observability import configure_observability, shutdown_observability

configure_observability(
    service_name="ticketing",
    otlp_endpoint="http://collector:4318",
    environment="production",
)

Structured logging

from observability import configure_logging, get_logger, RequestContext, set_request_context

configure_logging("INFO", service_name="ticketing")

set_request_context(RequestContext(request_id="r1", user_id="u1", tenant_id="t1"))
log = get_logger("ticketing")
log.info("event_created", event_id="e1")
log.error("payment_failed", status=503, token="sk_live_...")  # token -> [REDACTED]

LOG_PRETTY=true forces colored console output; production defaults to JSON.

Spans

from observability import span

@span
async def process_event(event_id: str) -> None: ...

@span(name="billing.charge", attributes={"provider": "stripe"})
def charge(customer_id: str) -> None: ...

Metrics

from observability import SloMetrics, RateLimitMetrics, http_requests_total

http_requests_total.labels(method="POST", path="/events", status_code="201").inc()

slo = SloMetrics()
slo.record_success()
slo.record_error()
slo.error_rate()          # 0.5

rl = RateLimitMetrics()
rl.hit("sms:user:42")
rl.get("sms:user:42")     # 1

Error classification

from observability import classify_error

classify_error(HTTPException(status_code=503))   # "server_error"
classify_error(HTTPException(status_code=404))   # "client_error"
classify_error(RuntimeError("boom"))             # "internal_error"

Testing

uv run pytest -q          # 30 tests
uv run ruff check .       # lint
uv run mypy src/          # strict typing

License

GPL-3.0-or-later

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

omnixys_observability-4.0.0.tar.gz (52.5 kB view details)

Uploaded Source

Built Distribution

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

omnixys_observability-4.0.0-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file omnixys_observability-4.0.0.tar.gz.

File metadata

  • Download URL: omnixys_observability-4.0.0.tar.gz
  • Upload date:
  • Size: 52.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for omnixys_observability-4.0.0.tar.gz
Algorithm Hash digest
SHA256 4b33d4d99214530026ffed8c4d47709276c8b1392a88b76bbc3ccc934bf32723
MD5 c205f0d5e5ad8f51eba24cf49372f8a6
BLAKE2b-256 dc3f4675d4dd6e7f251faee90dd3fa8679e63bdd1e7d48f4fda56711c8b5e256

See more details on using hashes here.

File details

Details for the file omnixys_observability-4.0.0-py3-none-any.whl.

File metadata

  • Download URL: omnixys_observability-4.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for omnixys_observability-4.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 23b8b69260a672216f1d51573b50edd87f6abfa10c4f45a4efd5d5e335b5e65d
MD5 bda4bfc81f7648381b71790dcc295be3
BLAKE2b-256 fda5c543c761a71fda600d012b9f9807d6e662b41dd89d71f3152b09164506ad

See more details on using hashes here.

Release history Release notifications | RSS feed

4.0.1

2 files

This release

4.0.0 This release

2 files

3.0.0

2 files

2.0.4

2 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