TOOL WIKI · OBSERVABILITY
Pydantic Logfire
Provides application observability with integrations for Python and AI workflows.
Jump to a section 10 sections
EXAMPLE USE CASE
Attach a structured outcome to a support trace
A developer needs evidence of what ran, which child operation failed, and how to turn that failure into a reproducible test.
- Input
- An order lookup performed inside a named span.
- Expected output
- A structured status event in the selected Logfire project.
- Success check: One span contains a structured event with status packed in the selected project.
- Try a failure: An exported packed event should correspond to the lookup result, not a hardcoded success on an exception path.
Example scope: Actual trace/log export with a synthetic fixture.
Official reference · Pydantic Logfire
Propagate a trace identifier through models, retrieval, and tools.
Capture meaningful timings and outcomes while excluding unnecessary content.
processTo 03 · Pydantic LogfireCorrelating agent behavior with broader application traces. Inspect the data your instrumentation exports and its retention.
resultTo 04 · InvestigationJoin parent-child spans and compare observed results with task expectations.
Turn verified failures into repeatable evaluation cases.
Use task success, error rates, latency, and cost to decide what to change.
Result or stopping point
Correlating agent behavior with broader application traces. Inspect the data your instrumentation exports and its retention.
When to consider it
- Correlating agent behavior with broader application traces.
A design decision to make
- Inspect the data your instrumentation exports and its retention.
Prerequisites and setup
- Python 3.11+ and synthetic fixtures. Managed tracing sends the recorded data to the configured project.
python3 -m venv .venv
source .venv/bin/activate
pip install logfire
export LOGFIRE_TOKEN="YOUR_PROJECT_WRITE_TOKEN"Try a small integration
trace.py
import os
import logfire
logfire.configure(token=os.environ["LOGFIRE_TOKEN"])
with logfire.span("Read order {order_id}",order_id="A104"):
status = {"A104":"packed"}.get("A104","not_found")
logfire.info("Order lookup completed",status=status)
logfire.force_flush()Run and check the result
python trace.py- One span contains a structured event with status packed in the selected project.
- A span template keeps the operation name stable while attributes carry the synthetic order ID.
Common failures
- No trace: check the project/region, credentials, collector protocol and exporter flush before changing instrumentation.
- Avoid double instrumentation that produces duplicate model spans or conflicting trace providers.
Production decisions
- Redact keys, private prompts, personal data and sensitive tool results before exporting telemetry. Configure sampling and retention.
- Connect request, agent, model and tool spans with parent/child trace context. A successful span is not a quality or authorization verdict.
Keep exploring
Explore the same layer
Compare candidates on your own workload. This entry describes a product’s role; it is not a claim that products in the category are interchangeable.