viktorbarzin-telemetry
The Python client for the viktorbarzin.me telemetry standard: Product events
through Segment's segment-analytics-python to our Event pipeline, errors
through sentry-sdk to GlitchTip, and logs as one OpenTelemetry-shaped JSON
object per line on stdout.
pip install viktorbarzin-telemetry # events and logs
pip install "viktorbarzin-telemetry[sentry]" # plus Sentry
import logging
import viktorbarzin_telemetry as telemetry
telemetry.setup_logging(service_name="tv", service_version="1.4.0")
telemetry.configure(
app="tv",
write_key=settings.segment_write_key,
release="1.4.0",
environment="production", # or set TELEMETRY_ENVIRONMENT=production
host=settings.event_pipeline_url, # or set TELEMETRY_HOST
dsn=settings.sentry_dsn, # https://<key>@tv.viktorbarzin.me/_t/x/<project id>
)
with telemetry.log_context(enduser_id=user.sub):
logging.getLogger(__name__).info("recording started", extra={"channel_id": 4})
telemetry.track("recording.started", {"channel_id": 4})
telemetry.flush() # before exit
hostis the Event pipeline's base URL, from the argument orTELEMETRY_HOST. Inside our cluster it is the event-pipeline Service's URL; elsewhere usetelemetry.public_host("tv.viktorbarzin.me"). Production without a host raisesValueError.- Nothing is sent unless the environment is
production. Invalid events are validated in every environment, dropped and logged as a warning. RequestContextMiddleware(app, resolve_user=...)captures, per HTTP or WebSocket request, theX-Visitor-Idheader (the browser's Rybbit visitor id), the client IP (X-Real-Ip, else the firstX-Forwarded-Forentry, else the peer) and the User-Agent. Events sent during the request use the visitor id as their defaultanonymousIdand carrycontext.ipandcontext.userAgent.resolve_useris optional and works as inEnduserMiddleware. Outside ASGI, wrap the handler inwith telemetry.request_context(request.headers, peer=remote_addr):.tracktakesuserIdfromlog_context(enduser_id=...).anonymousIdis the explicit argument, elselog_context(anonymous_id=...), else the request's visitor id. Without any of those it is omitted when there is auserId, and otherwiseserver:<app>, orconfigure(..., default_anonymous_id=...). It is never a new random id per event.EnduserMiddleware(app, resolve_user=...)setsenduser.idper request in any ASGI app.resolve_usergets the ASGI scope and returns the Person's Authentiksubor None, directly or as an awaitable.trace_idandspan_idcome from the active OpenTelemetry span whenopentelemetry-apiis installed, else fromlog_context.- The JSON formatter masks the write key, values passed as
secrets=, and bearer tokens, Basic credentials, JWTs and PEM blocks.
app.add_middleware(RequestContextMiddleware, resolve_user=person_from_scope)
Upgrading from 0.1.0: call sites keep working. A test double passed as
client= must now accept anonymous_id: str | None, because an event with a
Person and no visitor id sends none.
The standard itself is in the repository README.
Metadata
Release files for viktorbarzin-telemetry 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| viktorbarzin_telemetry-0.2.0.tar.gz | 20.0 kB | With provenance | Details for viktorbarzin_telemetry-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| viktorbarzin_telemetry-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for viktorbarzin_telemetry-0.2.0-py3-none-any.whl |
Total release size: 36.8 kB
Release files / viktorbarzin_telemetry-0.2.0.tar.gz
| Download URL | viktorbarzin_telemetry-0.2.0.tar.gz |
|---|---|
| Size | 20.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
728afc9036ff3532d7a6e314f25fb8f870fdc955aa2e1849aa19fe92b33bfa0d
|
|
BLAKE2b-256 checksum How to use checksums |
73ea1768861fdb88e428efce84a5d051cc4307207d2da4c6debd4deba2d9ae53
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.
Transparency logRelease files / viktorbarzin_telemetry-0.2.0-py3-none-any.whl
| Download URL | viktorbarzin_telemetry-0.2.0-py3-none-any.whl |
|---|---|
| Size | 16.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
50e2e74637f394c46034f20c4c57c04909bc718a91c2668dafba9ca0cf0aacad
|
|
BLAKE2b-256 checksum How to use checksums |
5b26dbe246d1dc3e9af9dc18213c5c859d902d38ad3cfedc2ccbc54f75808d1c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.
Transparency logSecurity for viktorbarzin-telemetry 0.2.0
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for viktorbarzin_telemetry-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.
Transparency logA 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.