Skip to main content
Logfire for Python

Trace, monitor and debug your Python app

Python Observability from the team behind Pydantic: one line instruments FastAPI, Django, SQLAlchemy or httpx, and everything is queryable in plain SQL. Standard OpenTelemetry, no lock-in.

Install the SDK
pip install \
  'logfire[fastapi,sqlalchemy,httpx]'
logfire auth  # or set LOGFIRE_TOKEN
Instrument your app
import logfire

logfire.configure()

# one call per library you use
logfire.instrument_fastapi(app)
logfire.instrument_httpx()
logfire.instrument_sqlalchemy(
    engine=engine)

Full details are in the Python setup guide.

What you get

One request, one trace

A Logfire trace of a Python batch worker: the manual process-inbox span, Pydantic validation of each record, the Postgres query and outbound HTTP call per order, and a rejected record whose validation failed

Every request through your Python app becomes a trace: the full timeline of that request, built from nested spans. Each span is one timed unit of work — a database query, an outbound call, a Pydantic validation — with its timing, attributes, and errors attached.

Try it on your stack

See your own Python trace

Start free with 10 million spans, logs, and metrics each month. No credit card required.

How it works

Instrument the edges, see the whole request

Auto-instrument your whole stack

The high-value telemetry comes from the libraries you already use. Each integration is one line: logfire.instrument_fastapi(app), logfire.instrument_django(), logfire.instrument_sqlalchemy(engine=engine), logfire.instrument_psycopg(), logfire.instrument_httpx(). Every request opens a trace, and every query and outbound call inside it becomes a timed child span. You add instrumentation at the edges and let the request carry the context.

Trace your own logic

For the code that is actually yours, open a span where a business operation begins with logfire.span("process_order", order_id=order_id), or decorate a function with @logfire.instrument(). Attributes like order_id are queryable, so "every order over $500 that took longer than two seconds" is a real question you can ask.

It understands Pydantic

Most of the Python world validates data with Pydantic, and Logfire is built by the same team. Call logfire.instrument_pydantic() and validation runs show up as spans, with the model, the inputs, and any validation errors captured. When a request fails because a payload did not match your schema, you see exactly which field and why, in production.

Traces, metrics, and logs in one place

Send your own metrics and structured logs alongside spans, all in the same project and queryable with the same SQL. Add the system-metrics extra and call logfire.instrument_system_metrics(base='full') to capture CPython runtime metrics, including GC collections, thread count, context switches, and memory.

OpenTelemetry-native, no lock-in

Because Logfire speaks OpenTelemetry natively, you are never trapped. Standard opentelemetry-instrument usage and manual OTel spans work unchanged, and you can send the same data to another backend or self-host without touching your instrumentation. Your instrumentation is an asset you own, not rented from a vendor.

Coverage

One line each, for the Python libraries you already use

Query

Query your Python telemetry with SQL

If you can ask it, SQL can find out

  • Query your traces, metrics and logs with real SQL
  • No proprietary query language to learn
  • AI models are great at writing SQL
  • From a one-off investigation to an alert, dashboard, or SLO
select
  attributes->>'http.route' as route,
  count(*) as requests,
  avg(duration) as avg_seconds
from records
where duration > 1
group by route
order by avg_seconds desc;
Proof

In production

We are finding and fixing issues in five minutes instead of an hour, which is obviously increasing uptime for our clients.
Zach Silver, Staff Software Engineer, BoostedAI Read the case study
Decision guide

Is Logfire right for your Python app?

Choose Logfire if

  • You want observability for a Python app without wiring up a backend yourself
  • You want auto-instrumentation for FastAPI, Django, SQLAlchemy, httpx, and more in one line each
  • You want to query traces, metrics, and logs with PostgreSQL-compatible SQL
  • You want validation and Pydantic models visible in your traces
  • You want the portability of OpenTelemetry with a product that feels like Python

Choose a traditional APM if

  • You are already deeply integrated with a specific APM vendor's ecosystem
  • You need a vendor-only integration or compliance capability Logfire does not offer
  • You want one vendor's agent and dashboards, and are comfortable with their pricing model
FAQ

Common questions

How do I add OpenTelemetry to a Python application?

Install an OpenTelemetry-compatible SDK and instrument your libraries. With Pydantic Logfire it is pip install with the extras for the integrations you use, for example pip install 'logfire[fastapi,sqlalchemy]', then logfire.configure(), then one line per library such as logfire.instrument_fastapi(app). Logfire is OpenTelemetry-native, so standard opentelemetry-instrument usage and manual OTel spans also work unchanged.

What is the difference between logging and observability in Python?

Logs are individual events. Observability connects them: a trace ties a request to every database query, external call, and function it triggered, with timing and attributes. That is what lets you see why a specific request was slow, rather than scrolling through disconnected log lines.

Does OpenTelemetry instrumentation slow down my Python app?

Auto-instrumentation is designed for production and adds minimal overhead. Telemetry is batched and exported asynchronously, and you can sample traces to control volume. The visibility you gain into slow queries and failing calls typically pays for the small cost many times over.

Is Pydantic Logfire locked to a proprietary format?

No. Logfire is built on OpenTelemetry, the open industry standard. Your instrumentation is portable: you can export the same data to another OTel-compatible backend, and the SDK works with standard OpenTelemetry tooling. Logfire adds Python-first ergonomics and SQL querying on top of the open standard.

Can I query my Python traces directly?

Yes. Logfire lets you query your traces, metrics, and logs with SQL. Any question you can express in SQL becomes a dashboard, an alert, or an ad-hoc investigation, with no proprietary query language to learn.

Keep reading

If you are still comparing

Start seeing your Python app

Get started with 10 million free spans, logs, and metrics per month. No credit card required.