Skip to main content

Installation

Requirements: Python 3.8+

Basic usage

Client configuration

Environment variables

Embedded vs Server mode

Logging events

Labels and context

Default labels

Labels passed to the constructor are merged into every event. Event-level labels override defaults for matching keys.

Querying by labels

Events can be filtered by label values using ?label.<key>=<value> query parameters. Multiple label filters are ANDed together.

Label context

Labels are short identifiers, but dashboards often need richer information. set_context() attaches business data to a label value for dashboard enrichment — for example, attaching a borrower name and loan amount to a loan_id.
The label key must exist in the client’s default labels — otherwise a ValueError is raised. The data is sent as a fire-and-forget PUT /v1/context/{key}/{value} request (or written to SQLite in embedded mode). Transport errors are logged as warnings and never raise. Context is keyed by (label_key, label_value) and upserted — calling set_context again replaces the previous data. You can also push context at construction time with the context parameter:

Querying events

Verifying integrity

Batching and async

Events are ingested non-blocking via a background thread:
  • Batched every 100 events or 1 second (whichever comes first)
  • Never blocks your agent’s execution path
  • Flush explicitly with client.flush()
  • Clean shutdown with client.close()

Context manager

PII redaction

In embedded mode, redaction is automatic — the client loads redaction rules from your config file on startup. In server mode, the server handles redaction. To add custom redaction rules, create a provenlog.yaml config file:
Config file discovery order:
  1. PROVENLOG_CONFIG environment variable
  2. ./provenlog.yaml
  3. ~/.provenlog/config.yaml
You can also use the Redactor class directly for standalone redaction:
See PII Redaction for the full list of built-in patterns.