OpenTelemetry Starlette Instrumentation

pypi

This library provides automatic and manual instrumentation of Starlette 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-starlette

Usage

from opentelemetry.instrumentation.starlette import StarletteInstrumentor
from starlette import applications
from starlette.responses import PlainTextResponse
from starlette.routing import Route

def home(request):
    return PlainTextResponse("hi")

app = applications.Starlette(
    routes=[Route("/foobar", home)]
)
StarletteInstrumentor.instrument_app(app)

API

class opentelemetry.instrumentation.starlette.StarletteInstrumentor[source]

Bases: opentelemetry.instrumentation.instrumentor.BaseInstrumentor

An instrumentor for starlette

See BaseInstrumentor

static instrument_app(app)[source]

Instrument an uninstrumented Starlette application.