logfire_skill
- Python
2
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill jiatastic/open-python-skills --skill logfire- SKILL.md7.1 KB
Overview
This skill provides structured observability for Python services using Pydantic Logfire with OpenTelemetry compatibility. It bundles fast setup, framework instrumentation, tracing spans, metrics, sampling, and scrubbing features to make observability predictable and low-effort. Use it to add consistent traces and logs across FastAPI, HTTPX, SQLAlchemy, LLMs, and other integrations.
How this skill works
The skill configures Logfire at process startup to set service metadata and global behavior, then instruments supported frameworks and clients to emit spans and structured logs. It exposes APIs for manual spans, counters/gauges/histograms, scrubbing callbacks, and sampling rules so you can control trace/metric volume and sensitive data handling. A testing helper captures exported spans for assertions in unit tests.
When to use it
- Adding traces and structured logs to Python APIs or microservices
- Instrumenting FastAPI, HTTPX, SQLAlchemy, or other supported frameworks
- Observability for LLM interactions using Pydantic AI or OpenAI integrations
- Configuring sampling to limit trace volume or scrubbing to remove secrets
- Writing tests that assert tracing and logging behavior
Best practices
- Call logfire.configure(...) very early in process startup and set service_name/service_version
- Instrument libraries before creating clients or apps to ensure spans are captured
- Avoid high-cardinality attributes — use IDs or reduced payloads as span attributes
- Use scrubbing patterns and callbacks to protect sensitive fields before they are exported
- Apply sampling and disable unnecessary metrics in high-traffic environments to control costs
Example use cases
- FastAPI app: configure once, instrument FastAPI/HTTPX, then create the app to get automatic request traces
- Database tracing: instrument SQLAlchemy and add span attributes like result_count for query visibility
- LLM observability: instrument Pydantic AI or OpenAI to trace prompts, responses, and token usage
- Testing: use CaptureLogfire in tests to assert spans and attributes are emitted during business logic
- Ad-hoc spans & metrics: wrap critical operations in logfire.span and record custom counters/histograms
FAQ
No — many common libs have built-in instrument_* helpers. Instrument supported frameworks before creating clients or apps.
How do I avoid leaking secrets in logs?
Configure ScrubbingOptions with patterns and an optional callback to selectively preserve or scrub fields before export.