Skip to main content

OpenTelemetry FastAPI Instrumentation

Project description

pypi

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)

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

File details

Details for the file opentelemetry_instrumentation_fastapi-0.18b1-py3-none-any.whl.

File metadata

File hashes

Hashes for opentelemetry_instrumentation_fastapi-0.18b1-py3-none-any.whl
Algorithm Hash digest
SHA256 ee207f75071c6e3ba6acf646261395ae265ba66f0cbbbc72347c8a1c155fa968
MD5 ea4f0129d309870628382fcb3152be64
BLAKE2b-256 bfc9493d5c650ad88aa33063bedc3d408a7799526b59ae8567f045011e99a255

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page