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.24b0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e660d54fe495c0ac31f39d5b928d43eb956e36e38f455d6309a710a421c28418 |
|
MD5 | 0d63b8c12dab2463c58d2eabae1d76fa |
|
BLAKE2b-256 | 2a60764afa0fac645aa89bbe2867e5f2594767d34eeff6647774a22fc4a1533b |
Close
Hashes for opentelemetry_util_http-0.24b0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78b9ff1dfa7d5c379911b1b7edad45562ab31cf6441ae741dc3e18499d46b072 |
|
MD5 | 47168c19f7d33a59147f98efa21b24a1 |
|
BLAKE2b-256 | 09d9c0769cc94b2078ea11f75135bb4b837dcecf3c875b95ee2654019f7820c5 |