Web util for OpenTelemetry
Project description
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)
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.
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)
from opentelemetry.instrumentation.asgi import OpenTelemetryMiddleware
app = ... # An ASGI application.
app = OpenTelemetryMiddleware(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 Distribution
Built Distribution
Close
Hashes for opentelemetry_util_http-0.42b0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 665e7d372837811aa08cbb9102d4da862441d1c9b1795d649ef08386c8a3cbbd |
|
MD5 | 9056f83d59c1619667c6fae02a0f576b |
|
BLAKE2b-256 | 9c5126e526f9d278a355d445763252fcb92149092ac5f77b53a642d25ab9f548 |
Close
Hashes for opentelemetry_util_http-0.42b0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 764069ed2f7e9a98ed1a7a87111f838000484e388e81f467405933be4b0306c6 |
|
MD5 | 335cc56428a1bf24d782fd7adf054e18 |
|
BLAKE2b-256 | 3f337528bd28710e3fd669ee7c5d98bc3392eb4588d451e28352696bb23c1520 |