Files
opentelemetry-python-contrib/util/opentelemetry-util-http
Emídio Neto 22e31a5571 Add python 3.14 support (#4193)
* try 3.14 in pyramid

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* see what's broken

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix pyramid

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix pyramid ci

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix sqlalchemy

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix httpx tests

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix pymssql

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix grpc tests

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix exporter-prometheus-write tests

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* try fastapi fix

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix django tests

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix aiopg

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix aiohttp-client

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix django

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix aiopg

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix httpx

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix fastapi

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix vertexai

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix workflows

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix openai-v2

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix contributing.md and lint to use py314

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix lint

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* Update tox.ini

Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>

* Update instrumentation/opentelemetry-instrumentation-asyncio/tests/test_asyncio_run_coroutine_threadsafe.py

Co-authored-by: Aaron Abbott <aaronabbott@google.com>

* Apply suggestion from @emdneto

* Apply suggestion from @emdneto

* Update tox.ini

* Update tox.ini

* fix lint

Signed-off-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>

* add changelog

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* add trove classifiers

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

* fix

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>

---------

Signed-off-by: emdneto <9735060+emdneto@users.noreply.github.com>
Signed-off-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
Co-authored-by: Aaron Abbott <aaronabbott@google.com>
2026-02-19 14:37:02 -05:00
..
2026-02-19 14:37:02 -05:00

OpenTelemetry Util HTTP
=======================

|pypi|

.. |pypi| image:: https://badge.fury.io/py/opentelemetry-util-http.svg
   :target: https://pypi.org/project/opentelemetry-util-http/


This library provides ASGI, WSGI middleware and other HTTP-related
functionality that is common to instrumented web frameworks (such as Django,
Starlette, FastAPI, etc.) to track requests timing through OpenTelemetry.

Installation
------------

::

    pip install opentelemetry-util-http


Usage (Quart)
-------------

.. code-block:: python

    from quart import Quart
    from opentelemetry.instrumentation.asgi import OpenTelemetryMiddleware

    app = Quart(__name__)
    app.asgi_app = OpenTelemetryMiddleware(app.asgi_app)

    @app.route("/")
    async def hello():
        return "Hello!"

    if __name__ == "__main__":
        app.run(debug=True)


Usage (Django 3.0)
------------------

Modify the application's ``asgi.py`` file as shown below.

.. code-block:: python

    import os
    from django.core.asgi import get_asgi_application
    from opentelemetry.instrumentation.asgi import OpenTelemetryMiddleware

    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'asgi_example.settings')

    application = get_asgi_application()
    application = OpenTelemetryMiddleware(application)


Usage (Raw ASGI)
----------------

.. code-block:: python

    from opentelemetry.instrumentation.asgi import OpenTelemetryMiddleware

    app = ...  # An ASGI application.
    app = OpenTelemetryMiddleware(app)


References
----------

* `OpenTelemetry Project <https://opentelemetry.io/>`_