FastAPI Instrumentation
FastAPI is a modern, high-performance web framework for building APIs with Python.
Install the Instrumentation
First, install the opentelemetry-instrumentation-fastapi
package. To add it to your project, add the following line to your requirements.txt
file:
# requirements.txt opentelemetry-instrumentation-fastapi
Setup
Start AppSignal and define your FastAPI application. Then use the FastAPIInstrumentor
to instrument your FastAPI application:
# app.py from fastapi import FastAPI from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor from __appsignal__ import appsignal appsignal.start() app = FastAPI() # ... your app's code goes here ... FastAPIInstrumentor().instrument_app(app)