Skip to main content

punt-observe

Shared private diagnostics and privacy-safe local telemetry for Punt Labs Python tools. Python 3.13+, Linux and macOS. Licensed under MIT.

Install

uv add punt-observe
# Optional network exporter:
uv add 'punt-observe[otlp]'

Diagnostics

Each CLI, MCP, hook, daemon and detached worker configures its own role. Libraries only create module loggers. No output is written to stdout.

import logging
from punt_observe.logging import configure_logging

configure_logging("my-tool", "cli")
logger = logging.getLogger(__name__)
logger.info("Completed operation: items=%d", 3)

Files live at ~/.punt-labs/my-tool/logs/my-tool.log, UTF-8, INFO by default, 5 MiB plus five backups. Directories are 0700; files and backups are 0600. Rotation is safe across cooperating processes using a stable flock lock. Setup permission failures raise LoggingSetupError; append failures are best-effort. Final formatted records are redacted, control-escaped and bounded to 64 KiB including their newline. Redaction is defense in depth: never log content or secrets. Home-directory prefixes become ~ on path-component boundaries, including in tracebacks and direct AtomicAppendLog.append() calls. Candidates include the current HOME (read at redaction time), the current uid's passwd home and their resolved aliases. Alias resolution is cached by input; empty, relative and root homes are ignored. This does not mask standalone account names or other users' homes, and cached aliases do not track symlink retargeting. Direct appends also apply the redactor's 64 KiB text cap before single-line escaping.

Telemetry

Declare schemas once; instrument through the facade, never an exporter.

from punt_observe.telemetry import (
    EnumAttr,
    HashAttr,
    SignalSchema,
    TelemetryConfig,
    open_telemetry,
)

schemas = [
    SignalSchema(
        "my-tool.cli.run",
        1,
        "span",
        {
            "outcome": EnumAttr(("ok", "error")),
            "item": HashAttr(),
        },
    )
]
telemetry = open_telemetry("my-tool", schemas, TelemetryConfig())
with telemetry.span("my-tool.cli.run", 1, item=telemetry.hash_id("local-id")):
    pass  # Perform the operation. Exceptions propagate without recording text.
telemetry.shutdown(timeout_s=2)

Use event(name, version, **attrs), count(name, version, n=1, **attrs) or record(name, version, value, **attrs) with matching event/counter/histogram schemas. Attribute types: closed EnumAttr, BoolAttr, IntAttr, DurationAttr (ms), CountAttr, SizeAttr (By), LengthAttr and HashAttr. Unknown attributes/versions, wrong types, free text and arbitrary strings posing as hashes are dropped before OTel. Only explicit schema-derived lengths and salted hashes may derive from content.

Local SQLite capture defaults on at ~/.punt-labs/my-tool/telemetry.db, separate from diagnostics. Store and SQLite sidecars are private, retained 90 days by default (configurable 1–3650); startup and hourly export-triggered pruning reclaim space incrementally. Per-install salt is ~/.punt-labs/telemetry.salt (0600).

Any off switch wins: PUNT_TELEMETRY=off, MY_TOOL_TELEMETRY=off, or TelemetryConfig(enabled=False). Also accepts 0/false/no, case-insensitively. Disabled telemetry creates no store, salt, provider or worker.

Network export requires TelemetryConfig(exporter="otlp", otlp_consent=True, otlp_endpoint="https://collector.example"). Environment variables PUNT_TELEMETRY_EXPORTER and PUNT_TELEMETRY_OTLP_ENDPOINT may select the exporter/endpoint but cannot grant consent. Missing optional OTLP dependency falls back to SQLite. Instrumentation stays identical.

Providers are private, never process-global. Pending span export is bounded at 2048; saturation drops records, not tool results. Shutdown bounds waiting; a misbehaving exporter may finish on a daemon thread after the deadline. shutdown(timeout_s=2) force-flushes pending metrics, spans and events without waiting for their periodic export interval. As a fallback, normal Python exit (including sys.exit or an uncaught KeyboardInterrupt) flushes pending live providers through one atexit registry, with a two-second total wait across all instances. Explicitly shut-down instances and forked children that have not emitted do no exit work. Explicit shutdown remains the preferred lifecycle.

The library never installs signal handlers. A SIGTERM with its default disposition skips atexit, as do SIGKILL and os._exit. Daemons must convert SIGTERM into normal Python unwinding (for example, raise SystemExit), or call shutdown before terminating. A server that restores and re-raises default SIGTERM before an outer telemetry context unwinds still skips that context and atexit; move explicit shutdown into its graceful lifecycle instead.

Development

uv sync --frozen; make check; make build. CI checks Linux and macOS. make help lists targets. The original append protocol is from punt-labs/vox; redaction and URL grammar are from punt-labs/quarry (MIT, Punt Labs).

Metadata

Release files for punt-observe 0.1.1

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

Source distribution (sdist)

Source distribution for punt-observe 0.1.1
File Size Uploaded Provenance Actions
punt_observe-0.1.1.tar.gz 38.3 kB With provenance Details for punt_observe-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for punt-observe 0.1.1
File Interpreter ABI Platform Actions
punt_observe-0.1.1-py3-none-any.whl Python 3 none any Details for punt_observe-0.1.1-py3-none-any.whl

Total release size: 86.3 kB

Release files / punt_observe-0.1.1.tar.gz

Download URL punt_observe-0.1.1.tar.gz
Size 38.3 kB
Tags Source
SHA-256 checksum
How to use checksums
48db7f6f9072531b77636e698ed9e21f89743a2eaede2c74a5de7e62a7fe8acf
BLAKE2b-256 checksum
How to use checksums
b82cd583ccbf26072533d1ab3105f1b22cb42c4abd688cc057f91acf3d253068
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 22, 2026.

Transparency log

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

Download URL punt_observe-0.1.1-py3-none-any.whl
Size 48.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
602dac07e0214e0879e858069becb69003480dd9a17d73175fd4b743ec83d0c0
BLAKE2b-256 checksum
How to use checksums
62c21ad4e79c38ecf4d04140814cce259574d8049ec4ef00b084656b5f821954
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 22, 2026.

Transparency log

Security for punt-observe 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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for punt_observe-0.1.1.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 22, 2026.

Transparency log

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

2 release files Full 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