Skip to content

Integrations

Instrument the libraries you already use (your web framework, database driver, HTTP client, LLM SDK) and their work shows up in Logfire automatically, as spans (one unit of work: a single operation, with a name, a start, and a duration) nested inside the request that triggered them. You don’t add logging by hand; you turn on the integration once and get the traces (the full journey of one request, made of nested spans) for free.

Most integrations are a single logfire.instrument_<package>() call, made once after logfire.configure(). For example, to instrument FastAPI and HTTPX:

from fastapi import FastAPI

import logfire

app = FastAPI()

logfire.configure()
logfire.instrument_fastapi(app)
logfire.instrument_httpx()

# ... your application code here ...

If a package you are using is not listed in this documentation, please let us know on our Slack!

Documented integrations

Logfire has documented integrations with many technologies, including:

  • LLM Clients and AI Frameworks: Pydantic AI, OpenAI, Anthropic, LangChain, LlamaIndex, Mirascope, LiteLLM, Magentic
  • Web Frameworks: FastAPI, Django, Flask, Starlette, AIOHTTP, ASGI, WSGI
  • Database Clients: Psycopg, SQLAlchemy, Asyncpg, PyMongo, MySQL, SQLite3, Redis, BigQuery
  • HTTP Clients: HTTPX, Requests, AIOHTTP
  • Task Queues and Schedulers: Airflow, FastStream, Celery
  • Logging Libraries: Standard Library Logging, Loguru, Structlog
  • Testing: Pytest
  • and more, such as Stripe, AWS Lambda, and system metrics.

The below table lists these integrations and any corresponding logfire.instrument_<package>() calls:

PackageTypeLogfire Instrument Call / Notes
Pydantic ValidationData Validationlogfire.instrument_pydantic()
Pydantic AIAIlogfire.instrument_pydantic_ai()
AIOHTTPHTTP Clientlogfire.instrument_aiohttp_client(), logfire.instrument_aiohttp_server()
AirflowTask SchedulerN/A (built in, config needed)
AnthropicAIlogfire.instrument_anthropic()
ASGIWeb Framework Interfacelogfire.instrument_asgi()
AWS LambdaCloud Functionlogfire.instrument_aws_lambda()
AsyncpgDatabaselogfire.instrument_asyncpg()
BigQueryDatabaseN/A (built in, no config needed)
CeleryTask Queuelogfire.instrument_celery()
DjangoWeb Frameworklogfire.instrument_django()
FastAPIWeb Frameworklogfire.instrument_fastapi()
FastStreamTask QueueN/A (built in, config needed)
FlaskWeb Frameworklogfire.instrument_flask()
HTTPXHTTP Clientlogfire.instrument_httpx()
LangChainAI FrameworkN/A (built-in OpenTelemetry support)
LlamaIndexAI FrameworkN/A (requires LlamaIndex OpenTelemetry package)
LiteLLMAI GatewayN/A (requires LiteLLM callback setup)
LoguruLoggingSee documentation
MagenticAI FrameworkN/A (built-in Logfire support)
MirascopeAI FrameworkN/A (use mirascope @with_logfire decorator)
MySQLDatabaselogfire.instrument_mysql()
OpenAIAIlogfire.instrument_openai()
PsycopgDatabaselogfire.instrument_psycopg()
PytestTestingN/A (built-in plugin, use pytest --logfire)
PyMongoDatabaselogfire.instrument_pymongo()
RedisDatabaselogfire.instrument_redis()
RequestsHTTP Clientlogfire.instrument_requests()
SQLAlchemyDatabaselogfire.instrument_sqlalchemy()
SQLite3Databaselogfire.instrument_sqlite3()
Standard Library LoggingLoggingSee documentation
StarletteWeb Frameworklogfire.instrument_starlette()
StripePayment GatewayN/A (requires other instrumentations)
StructlogLoggingSee documentation
System MetricsSystem Metricslogfire.instrument_system_metrics()
WSGIWeb Framework Interfacelogfire.instrument_wsgi()

If you are using Logfire with a web application, we also recommend reviewing our Web Frameworks documentation.

OpenTelemetry Integrations

Since Logfire is OpenTelemetry compatible, it can be used with any OpenTelemetry instrumentation package. You can find the list of all OpenTelemetry instrumentation packages here.

Many of the integrations documented in the previous section are based upon the OpenTelemetry instrumentation packages with first-class support built into Logfire.

Creating custom integrations

If you are a maintainer of a package and would like to create an integration for Logfire, you can do it!

We’ve created a shim package called logfire-api, which can be used to integrate your package with Logfire.

The idea of logfire-api is that it doesn’t have any dependencies. It’s a very small package that matches the API of Logfire. We created it so that you can create an integration for Logfire without having to install Logfire itself.

You can use logfire-api as a lightweight dependency of your own package. If logfire is installed, then logfire-api will use it. If not, it will use a no-op implementation. This way users of your package can decide whether or not they want to install logfire, and you don’t need to check whether or not it’s installed.

Here’s how you can use logfire-api:

import logfire_api as logfire

logfire.info('Hello, Logfire!')

All the Logfire API methods are available in logfire-api.