Skip to main content

Unified telemetry library for the Undef ecosystem

Project description

undef-telemetry

Unified telemetry package for the Undef ecosystem.

Install

pip install undef-telemetry

Optional extras:

pip install "undef-telemetry[otel]"

API

from undef.telemetry import (
    setup_telemetry,
    get_logger, logger,
    trace, tracer, get_tracer,
    counter, gauge, histogram, get_meter,
    TelemetryMiddleware,
)

Runtime Config API

  • update_runtime_config(config) applies a config and returns the active runtime snapshot.
  • reload_runtime_from_env() reloads env config, applies it, and returns the active runtime snapshot.
  • get_runtime_config() returns a defensive copy of the active runtime snapshot.
  • reconfigure_telemetry(config) only applies hot runtime policy changes in-process; provider-changing OpenTelemetry reconfiguration requires a process restart once providers have been installed.

Quick Start

from undef.telemetry import setup_telemetry, shutdown_telemetry, get_logger

setup_telemetry()
log = get_logger(__name__)
log.info("app.start.ok", request_id="req-1")
shutdown_telemetry()

Environment Variables

The most commonly set variables:

  • UNDEF_TELEMETRY_SERVICE_NAME — service identity (default: undef-service)
  • UNDEF_LOG_LEVEL — log level (default: INFO)
  • UNDEF_LOG_FORMAT — renderer: console, json, or pretty (default: console)

See the Configuration Reference for all 60+ environment variables with types and defaults.

Event Naming Rule

Event names are strict: 3-5 dot-separated segments (last segment is status by convention). If you build names dynamically, use undef.telemetry.event_name(*segments).

from undef.telemetry import event_name, get_logger

log = get_logger(__name__)
log.info(event_name("auth", "login", "success"), user_id="u-123")
log.info(event_name("auth", "login", "failed"), reason="bad_password")

OpenObserve Quick Verification

export OPENOBSERVE_URL=http://localhost:5080/api/default
export OPENOBSERVE_USER=user@example.com
export OPENOBSERVE_PASSWORD=password
export OPENOBSERVE_REQUIRED_SIGNALS=logs
uv run --group dev --extra otel python examples/openobserve/01_emit_all_signals.py
uv run --group dev --extra otel python examples/openobserve/02_verify_ingestion.py

Set OPENOBSERVE_REQUIRED_SIGNALS=logs,metrics,traces when your runtime has OTel extras and you want hard all-signal verification.

Script references:

Quality Guarantees

  • Baseline test gate runs at 100% branch coverage (--cov-branch).
  • Mutation gate enforces --min-mutation-score 100.
  • Mutation policy is pinned in .ci/pymutant-profiles.json (min_score: 1.0, max_drop_from_baseline: 0.0) with baseline score in .ci/pymutant-policy-baseline.json.
  • CI validates linting, typing, security, compliance, examples, and integration slices.
  • Async-safe default exporter policy keeps retries/backoff at zero; non-zero async retry behavior is opt-in via UNDEF_EXPORTER_*_ALLOW_BLOCKING_EVENT_LOOP=true.
  • Exporter timeout settings are enforced both in OTLP exporter construction and per-attempt resilience execution bounds.

Documentation Ownership

  • README: onboarding and first successful local/backend verification.
  • Operations: full CQ matrix, troubleshooting, and environment operations.
  • Conventions: event/schema rules and naming standards.
  • Release: packaging/tagging/publishing workflow.

Docs

Project details


Download files

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

Source Distribution

undef_telemetry-0.3.18.tar.gz (41.8 kB view details)

Uploaded Source

Built Distribution

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

undef_telemetry-0.3.18-py3-none-any.whl (52.7 kB view details)

Uploaded Python 3

File details

Details for the file undef_telemetry-0.3.18.tar.gz.

File metadata

  • Download URL: undef_telemetry-0.3.18.tar.gz
  • Upload date:
  • Size: 41.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for undef_telemetry-0.3.18.tar.gz
Algorithm Hash digest
SHA256 e2417b42ee76076b2ee755036f63357269c2ee1f7933c57a853de07f75fbbd34
MD5 0551752b98df4f63415f5edb69ea0563
BLAKE2b-256 f447c38c35718c0745b21ce85f179dc5247c6e00b9ad1864403bd37c4b36d3f4

See more details on using hashes here.

File details

Details for the file undef_telemetry-0.3.18-py3-none-any.whl.

File metadata

  • Download URL: undef_telemetry-0.3.18-py3-none-any.whl
  • Upload date:
  • Size: 52.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for undef_telemetry-0.3.18-py3-none-any.whl
Algorithm Hash digest
SHA256 58b69c81ca8a6151469c66dc8fda019116e78b7d74909703fd19097ef362983b
MD5 53d78ad97ee8b7d022a284458417d805
BLAKE2b-256 8b7d86f1f1b510894e4c74aeaa3f0f3b27bc718d1b663bc4b4c6620108880679

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page