Pydantic Logfire
Python observability SDK from the Pydantic team, built on OpenTelemetry for tracing, metrics, and logs.
Repository Health
Technical Analysis
Pydantic Logfire is the Python SDK for the Logfire observability platform, created by the team behind Pydantic Validation. It instruments your application with distributed tracing, metrics, and structured logging, sending the data to Logfire’s hosted dashboard or any OpenTelemetry-compatible backend.
Logfire is designed to be Python-centric and easy to adopt: a single import plus autoinstrumentation captures rich telemetry from web frameworks, database calls, HTTP clients, and LLM/agent workflows. Because it is built on OpenTelemetry, teams keep vendor-neutral, standards-based data while gaining Pydantic’s ergonomic API and dashboard.
What You Get
- A concise logfire.span / logfire.info API for manual tracing and structured logging
- One-line autoinstrumentation for FastAPI, Django, HTTPX, SQLAlchemy, OpenAI, Pydantic AI, and many more
- OpenTelemetry-native data export to Logfire’s dashboard or any OTLP backend
- Rich Python object display, event-loop telemetry, and code profiling
- A companion logfire-api no-op package for instrumenting libraries without a hard dependency
Common Use Cases
- Tracing requests through FastAPI or Django web applications in production
- Observing LLM and agent pipelines including token usage and tool calls
- Monitoring database queries and outbound HTTP calls via autoinstrumentation
- Emitting structured, queryable logs and custom metrics from Python services
Under The Hood
Architecture - The logfire package exposes a thin, ergonomic facade over the OpenTelemetry SDK. The top-level module configures a tracer/meter/logger provider and offers span, log, and metric helpers, while an _internal package handles exporters, sampling, scrubbing of sensitive data, and configuration. An integrations subpackage provides per-library instrumentors (FastAPI, Django, SQLAlchemy, HTTPX, OpenAI, Pydantic AI, and more), and a companion logfire-api package ships no-op stubs so third-party libraries can instrument without a hard dependency.
Tech Stack - Pure Python (3.10+), built with hatchling and managed with uv. It depends on the OpenTelemetry SDK and OTLP exporters, integrates deeply with Pydantic, and exports data over the standard OTLP protocol to Logfire or any compatible backend.
Code Quality - The repository is production-grade: extensive tests, CI with coverage reporting, a py.typed marker for full type hints, and a large curated CHANGELOG. Code is organized by concern with a clear public/_internal boundary and documented integration modules.
API Design - Getting started takes a single logfire.configure() call plus autoinstrumentation one-liners, yet the manual span and structured-logging API remains expressive. Naming mirrors familiar logging idioms, lowering the barrier for developers new to OpenTelemetry.
Used by 3 apps in this directory
Dify
No Code Platforms · AI Development · Developer Tools
Visual LLM workflow platform with RAG pipelines, agent capabilities, and model management for building production AI applications.
knowhere
AI Development · Developer Tools
Transform messy, unstructured documents into persistent, navigable memory that AI agents can actually use.
Polar
Ecommerce · Developer Tools · Invoicing Finance
Open source payments infrastructure that turns software into a business — subscriptions, usage-based billing, digital products, and merchant-of-record compliance in one platform.