Pydantic Logfire

Python observability SDK from the Pydantic team, built on OpenTelemetry for tracing, metrics, and logs.

SDK
PyPI
v4.40.0
4,429stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
88/100Excellent
Development Activity100
Maintenance100
Community64
Maturity48
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
87/100Excellent
Architecture88
Code Quality90
Innovation88
Learning Curve82

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.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search