Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.rst

OpenCensus FastAPI Integration

pypi

Installation

pip install opencensus-ext-fastapi

Usage

from fastapi import FastAPI
from opencensus.ext.fastapi.fastapi_middleware import FastAPIMiddleware

app = FastAPI(__name__)
app.add_middleware(FastAPIMiddleware)

@app.get('/')
def hello():
    return 'Hello World!'

Additional configuration can be provided, please read Customization for a complete reference.

app.add_middleware(
    FastAPIMiddleware,
    excludelist_paths=["paths"],
    excludelist_hostnames=["hostnames"],
    sampler=sampler,
    exporter=exporter,
    propagator=propagator,
)

References