Skip to main content

Outputs

Outputs define where captured events are sent. Pass any output class to observe() via the output parameter.

Stdout

Prints a one-line summary to the terminal after every call.
Output format:

SQLite

Persists every event to a local SQLite .db file. File is created automatically if it doesn’t exist.
Query your data:
Schema:

Logger

Writes structured JSON to Python’s standard logging module. In production this automatically routes to CloudWatch, Datadog, GCP Logging, Grafana Loki, or whatever log aggregator is already configured. Zero new infra.
Output format (one line per call):
Works with your existing log setup:

HTTP

POSTs every event as JSON to any HTTP endpoint you control.
Request format:
Important: HTTP output fires in a background thread and times out after 5 seconds. A failed POST is silently dropped — it never crashes your app or blocks your LLM call.

OpenTelemetry (OTEL)

Export your traces natively to Datadog, Grafana, Jaeger, or any other OpenTelemetry compatible observability platform.
Features:
  • Seamless integration with existing APM setups
  • Distributed tracing out of the box
  • Zero-latency background export

Multi

Writes to multiple outputs at once.
If one output fails, the others continue. Failures are silently swallowed per output.

Auto Detection

When no output is specified, TokenSense reads the environment and picks a sensible default:
Reads from: ENV, ENVIRONMENT, APP_ENV — whichever is set first. Override at any time by passing output= explicitly.