plog run — CLI wrapper
Wraps any Python command with automatic instrumentation:
How it works
plog run creates a temporary sitecustomize.py (the standard Python startup hook used by ddtrace, OpenTelemetry, etc.) that imports provenlog.auto, then executes your command with a modified PYTHONPATH.
Python automatically runs sitecustomize on startup — before your code runs — so all frameworks are patched before any agent code imports them.
The child process inherits stdin/stdout/stderr transparently. Signals (SIGINT, SIGTERM) are forwarded. The child’s exit code is preserved.
Flags
import provenlog.auto — one-line import
For code you control, add a single import at the top of your entrypoint:
What happens on import
- Reads configuration from environment variables
- Creates a shared
ProvenLogClient - Probes for installed frameworks using
importlib.util.find_spec()(never imports uninstalled packages) - Patches each detected framework using its native hook mechanism
Environment variables
Framework detection
If LangGraph is detected, the separate LangChain patch is skipped — LangGraph’s Trail extends LangChain’s and captures both graph-level and chain-level events.
Safety
- Framework detection uses
importlib.util.find_spec()— it never imports uninstalled packages - Each patch is wrapped in try/except — if one framework fails to patch, the others still work
- The client is registered with
atexitfor clean shutdown - ProvenLog observes passively — it never modifies agent behavior and adds zero latency to the execution path