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.
Install
Python:
pip install undef-telemetry # core (structlog)
pip install "undef-telemetry[otel]" # + OpenTelemetry export
TypeScript:
npm install @undef/telemetry # core (pino + @opentelemetry/api)
Quick Start
Python:
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()
TypeScript:
import { setupTelemetry, getLogger, shutdownTelemetry } from '@undef/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_TRACE_ENABLED |
false |
Enable OTel tracing |
UNDEF_METRICS_ENABLED |
false |
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() |
| Health | get_health_snapshot() |
| Runtime | update_runtime_config(), reconfigure_telemetry() |
Full reference: Python API | TypeScript API
Polyglot Architecture
undef-telemetry/
src/undef/telemetry/ # Python package
typescript/ # TypeScript package (@undef/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
- Configuration Reference — all environment variables
- API Reference — Python function signatures and examples
- Architecture — component design and data flow
- Internals — implementation details
- Conventions — event naming and schema rules
- Operations Runbook — troubleshooting and CQ matrix
- Production Profiles — recommended configs
- Release Runbook — versioning and publishing
- TypeScript README — TypeScript-specific docs
- Examples — Python and TypeScript examples
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file undef_telemetry-0.3.tar.gz.
File metadata
- Download URL: undef_telemetry-0.3.tar.gz
- Upload date:
- Size: 42.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b13484ede7be44437cc886cd36b2e135e7d0628a27526d609f8db4105bf8ecd
|
|
| MD5 |
e985dc36f9f81b7e0893bfededc4a604
|
|
| BLAKE2b-256 |
156e54aeebde7ab07fa56e72acd3e8fd72dd9b6d7783dad0e09aa209dfcd31f7
|
Provenance
The following attestation bundles were made for undef_telemetry-0.3.tar.gz:
Publisher:
release.yml on undef-games/undef-telemetry
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
undef_telemetry-0.3.tar.gz -
Subject digest:
0b13484ede7be44437cc886cd36b2e135e7d0628a27526d609f8db4105bf8ecd - Sigstore transparency entry: 1191624659
- Sigstore integration time:
-
Permalink:
undef-games/undef-telemetry@27d6043976fac438b0cded64b17790ac477e4248 -
Branch / Tag:
refs/tags/undef-telemetry-v0.4.0 - Owner: https://github.com/undef-games
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@27d6043976fac438b0cded64b17790ac477e4248 -
Trigger Event:
release
-
Statement type:
File details
Details for the file undef_telemetry-0.3-py3-none-any.whl.
File metadata
- Download URL: undef_telemetry-0.3-py3-none-any.whl
- Upload date:
- Size: 53.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6e18c71bb5585beaa40f69f2f5c5b329f759afb7844b89d6330b5c0812aee0f
|
|
| MD5 |
8ddc1ec6afd53ddd7e8b63134c72f3a4
|
|
| BLAKE2b-256 |
713a91d065b445de4b022bbfd4b3be1bc52ea89b69c329cff3101321c08f5194
|
Provenance
The following attestation bundles were made for undef_telemetry-0.3-py3-none-any.whl:
Publisher:
release.yml on undef-games/undef-telemetry
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
undef_telemetry-0.3-py3-none-any.whl -
Subject digest:
b6e18c71bb5585beaa40f69f2f5c5b329f759afb7844b89d6330b5c0812aee0f - Sigstore transparency entry: 1191624661
- Sigstore integration time:
-
Permalink:
undef-games/undef-telemetry@27d6043976fac438b0cded64b17790ac477e4248 -
Branch / Tag:
refs/tags/undef-telemetry-v0.4.0 - Owner: https://github.com/undef-games
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@27d6043976fac438b0cded64b17790ac477e4248 -
Trigger Event:
release
-
Statement type: