Skip to main content

Unified telemetry library for the Undef ecosystem

Project description

Undef Telemetry

Unified telemetry library for structured logging, distributed tracing, and metrics across Python and TypeScript. Graceful OTel degradation — works without OpenTelemetry installed, activates full export when OTel SDK is present.

1. 🐍 CI — Python 2. 🟦 CI — TypeScript 5. 🔒 CodeQL

Install

Python:

pip install undef-telemetry              # core (structlog)
pip install "undef-telemetry[otel]"      # + OpenTelemetry export

TypeScript:

npm install @undef-games/telemetry             # core (pino + @opentelemetry/api)

Quick Start

Python:

from undef.telemetry import setup_telemetry, shutdown_telemetry, get_logger, event_name

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

TypeScript:

import { setupTelemetry, getLogger, shutdownTelemetry } from '@undef-games/telemetry';

setupTelemetry({ serviceName: 'my-app' });
const log = getLogger('api');
log.info({ event: 'app.start.ok', requestId: 'req-1' });
await shutdownTelemetry();

Both languages share the same API surface, event naming conventions, and configuration environment variables.

Configuration

All runtime config is via environment variables:

Variable Default Description
UNDEF_TELEMETRY_SERVICE_NAME undef-service Service identity
UNDEF_LOG_LEVEL INFO Log level
UNDEF_LOG_FORMAT console Renderer: console, json, or pretty
UNDEF_TELEMETRY_ENV dev Deployment environment
UNDEF_TELEMETRY_VERSION 0.0.0 Service version
UNDEF_TRACE_ENABLED true Enable OTel tracing
UNDEF_METRICS_ENABLED true Enable OTel metrics

See the Configuration Reference for all 60+ environment variables.

Event Naming

Event names use 3-5 dot-separated lowercase segments:

# Python
log.info("auth.login.success", user_id="u-123")
log.info(event_name("auth", "login", "failed"), reason="bad_password")
// TypeScript
log.info({ event: 'auth.login.success', userId: 'u-123' });

See Conventions for full naming rules.

API Surface

Both languages export equivalent APIs:

Category Functions
Lifecycle setup_telemetry(), shutdown_telemetry()
Logging get_logger(), bind_context(), clear_context()
Tracing get_tracer(), trace (decorator/wrapper), extract_w3c_context()
Metrics counter(), gauge(), histogram()
Policies set_sampling_policy(), set_queue_policy(), set_exporter_policy()
Safety register_cardinality_limit(), register_pii_rule(), replace_pii_rules(), get_pii_rules()
Health get_health_snapshot()
Runtime update_runtime_config(), reconfigure_telemetry(), reload_runtime_from_env()

Full reference: Python API | TypeScript API

Polyglot Architecture

undef-telemetry/
  src/undef/telemetry/    # Python package
  typescript/             # TypeScript package (@undef-games/telemetry)
  spec/                   # Canonical API spec — all languages validate against it
  e2e/                    # Cross-language E2E tests (W3C trace propagation)

A shared spec/telemetry-api.yaml defines the required API surface. CI validates that both Python and TypeScript exports conform to it. Cross-language distributed tracing is tested end-to-end via W3C traceparent propagation.

Quality

  • 100% branch coverage (Python + TypeScript)
  • 100% mutation kill score (mutmut + Stryker)
  • Strict type checking (mypy + ty + tsc)
  • CodeQL SAST scanning
  • SHA-pinned GitHub Actions
  • Sigstore artifact signing
  • CycloneDX SBOM on releases

Documentation

License

Apache-2.0. See LICENSES/.

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.4.2.tar.gz (44.6 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.4.2-py3-none-any.whl (55.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: undef_telemetry-0.4.2.tar.gz
  • Upload date:
  • Size: 44.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for undef_telemetry-0.4.2.tar.gz
Algorithm Hash digest
SHA256 69a434b07dc7fd62d91bcbbafb938a707cd3273c2c2741923c62b7c2b09423eb
MD5 1ee92fbae6aca3fc1f0058cf336c7113
BLAKE2b-256 a81bb0ba27fbf167a74f9c7be3352f4994a34d314838a581d82cfac2bd642c23

See more details on using hashes here.

Provenance

The following attestation bundles were made for undef_telemetry-0.4.2.tar.gz:

Publisher: release.yml on undef-games/undef-telemetry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for undef_telemetry-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 557f5a169d9ddbba6a24a7eceb6e08dd3d4f6a540366a48e72adca2e3fc0499a
MD5 355fa665a1b82826273d3aed65072b50
BLAKE2b-256 ef9582cf887a2b5ca33067d4fa0a9f4d3acbef5a6789ea96c28bb54c63af9702

See more details on using hashes here.

Provenance

The following attestation bundles were made for undef_telemetry-0.4.2-py3-none-any.whl:

Publisher: release.yml on undef-games/undef-telemetry

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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