ASGI instrumentation for OpenTelemetry
Project description
This library provides a ASGI middleware that can be used on any ASGI framework (such as Django, Starlette, FastAPI or Quart) to track requests timing through OpenTelemetry.
Installation
pip install opentelemetry-instrumentation-asgi
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-instrumentation-asgi-0.16b0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b397ea03a5f7f291ca9bcbe9d22e48ee5a51b6911bdda678a190b48c07360de9 |
|
MD5 | 92313ade858cf325339c2c7d364d086c |
|
BLAKE2b-256 | 6f88a57e07f4865331eea084486c6de2de599e6b28324b9c42e5e02aa7b83080 |
Close
Hashes for opentelemetry_instrumentation_asgi-0.16b0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eaacd3ec7dcda4017d07fcc2e89e5bc505bd7531e2668ee33bd01f7e33787ccf |
|
MD5 | b37463c7fd44c3bfcdfba080abbc4194 |
|
BLAKE2b-256 | 005ab817a6308c526ab0c1dd4264a07f34fba9deebcc875933653e5b5f1e8cfb |