OpenTelemetry FastAPI Instrumentation
Project description
This library provides automatic and manual instrumentation of FastAPI web frameworks, instrumenting http requests served by applications utilizing the framework.
auto-instrumentation using the opentelemetry-instrumentation package is also supported.
Installation
pip install opentelemetry-instrumentation-fastapi
Configuration
Exclude lists
To exclude certain URLs from being tracked, set the environment variable OTEL_PYTHON_FASTAPI_EXCLUDED_URLS with comma delimited regexes representing which URLs to exclude.
For example,
export OTEL_PYTHON_FASTAPI_EXCLUDED_URLS="client/.*/info,healthcheck"
will exclude requests such as https://site/client/123/info and https://site/xyz/healthcheck.
Usage
import fastapi
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
app = fastapi.FastAPI()
@app.get("/foobar")
async def foobar():
return {"message": "hello world"}
FastAPIInstrumentor.instrument_app(app)
You can also pass the list of urls to exclude explicitly to the instrumentation call:
FastAPIInstrumentor.instrument_app(app, excluded_urls="client/.*/info,healthcheck")
References
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for opentelemetry-instrumentation-fastapi-0.25b0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1eaf12435e654180cbf30a04ed67583b644465e22ff9a35d84711e32c468b704 |
|
MD5 | 494ee34449f5a6a4936a849bc63814be |
|
BLAKE2b-256 | f2f6a7d7376960a29b7dceb32e6c703942413ab097066b9c3c1eab90b0cae1eb |
Hashes for opentelemetry_instrumentation_fastapi-0.25b0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a209a252d32151dbe351966716e5b5d83aabcef856f330a1a676006203b0f916 |
|
MD5 | acf8a8cd3296daf7fce1a5ee19c905d8 |
|
BLAKE2b-256 | f02f777e35f294acba50fa7f705ed9b46fea4eb9d68cfaac2f78fecf808ff9f1 |