Skip to main content

b4n1-telemetry — Python SDK

Drop-in error reporting to your own collector. Standard library only: the SDK adds no dependency to the application it instruments.

Install

pip install b4n1-telemetry

Wire it once

import b4n1_telemetry

b4n1_telemetry.init(app="musicogram")

That single call installs:

  • a root logging handler for ERROR and above (with the real traceback),
  • sys.excepthook and threading.excepthook (uncaught exceptions, level fatal),
  • a flush on interpreter exit.

Configuration comes from the call or the environment:

B4N1_TELEMETRY_URL=http://127.0.0.1:9450
B4N1_TELEMETRY_TOKEN=...        # optional bearer token
B4N1_TELEMETRY_APP=musicogram   # optional default app name

Django

# settings.py
import b4n1_telemetry
b4n1_telemetry.init(app="musicogram")

MIDDLEWARE = [
    "b4n1_telemetry.django.TelemetryMiddleware",
    ...,
]

The middleware gives every request a correlation id (honouring an incoming X-Correlation-Id / X-Request-Id), returns it in the response, and records 5xx responses. Uncaught exceptions are captured by the logging handler Django itself uses, so nothing is counted twice.

Explicit capture

b4n1_telemetry.capture("payment retried", level="warning",
                       module="payments", data={"attempt": 2})
try:
    charge()
except Exception as exc:
    b4n1_telemetry.capture_exception(exc, module="payments")
    raise

b4n1_telemetry.flush() waits for the queue to drain (tests, short-lived scripts).

Contract

  • Sending is asynchronous and bounded (2048 events); overflow is counted, never blocks the application.
  • A collector that is down never raises into the application: failures are counted in client.stats (sent, failed, dropped, last_error).
  • init() is idempotent; shutdown() removes the handler and restores the previous exception hooks.

After a request fails, the whole chain is one lookup:

telemetry-server trace <correlation-id>

Metadata

Release files for b4n1-telemetry 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for b4n1-telemetry 0.1.1
File Interpreter ABI Platform Actions
b4n1_telemetry-0.1.1-py3-none-any.whl Python 3 none any Details for b4n1_telemetry-0.1.1-py3-none-any.whl

Release files / b4n1_telemetry-0.1.1-py3-none-any.whl

Download URL b4n1_telemetry-0.1.1-py3-none-any.whl
Size 16.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c3dd5240181ec7e9b07479b904d23b220ce12a3e03d0fbcc75f3a53ba00ad961
BLAKE2b-256 checksum
How to use checksums
2c8470762106e0b7095d775fe1852afb3382fa90de38ba12e4f6d3ad9f1d5a4c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.12

Security for b4n1-telemetry 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file No provenance

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