OpenTelemetry Flask tracing

This library builds on the OpenTelemetry WSGI middleware to track web requests in Flask applications. In addition to opentelemetry-ext-wsgi, it supports flask-specific features such as:

  • The Flask endpoint name is used as the Span name.

  • The http.route Span attribute is set so that one can see which URL rule matched a request.


from flask import Flask
from opentelemetry.ext.flask import instrument_app

app = Flask(__name__)
instrument_app(app)  # This is where the magic happens. ✨

def hello():
    return "Hello!"

if __name__ == "__main__":

Module contents


Makes the passed-in Flask object traced by OpenTelemetry.

You must not call this function multiple times on the same Flask object.