New Relic Python Agent

11.4.0 · active · verified Wed Mar 25

Official APM agent for Python applications. Auto-instruments web frameworks (FastAPI, Django, Flask), databases (SQLAlchemy, psycopg, asyncpg), Redis, external HTTP calls, and AI/LLM libraries. Current version is 11.4.0 (Jan 2026). v12.0.0 released March 2026 with breaking removals.

Warnings

Install

Imports

Quickstart

Agent initialization patterns. CLI wrapper is preferred. Manual init requires initialize() before all other imports.

# Option 1: CLI wrapper (recommended — handles ordering automatically)
# NEW_RELIC_CONFIG_FILE=newrelic.ini newrelic-admin run-program gunicorn myapp.wsgi

# Option 2: Manual init — must be absolute first lines of entry point
import newrelic.agent
newrelic.agent.initialize('newrelic.ini')

# Framework imports AFTER initialize()
from fastapi import FastAPI
app = FastAPI()

view raw JSON →