Skip to main content

ASGI instrumentation for OpenTelemetry

Project description

pypi

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

File details

Details for the file opentelemetry-instrumentation-asgi-0.16b0.tar.gz.

File metadata

  • Download URL: opentelemetry-instrumentation-asgi-0.16b0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.7.9

File hashes

Hashes for opentelemetry-instrumentation-asgi-0.16b0.tar.gz
Algorithm Hash digest
SHA256 b397ea03a5f7f291ca9bcbe9d22e48ee5a51b6911bdda678a190b48c07360de9
MD5 92313ade858cf325339c2c7d364d086c
BLAKE2b-256 6f88a57e07f4865331eea084486c6de2de599e6b28324b9c42e5e02aa7b83080

See more details on using hashes here.

File details

Details for the file opentelemetry_instrumentation_asgi-0.16b0-py3-none-any.whl.

File metadata

File hashes

Hashes for opentelemetry_instrumentation_asgi-0.16b0-py3-none-any.whl
Algorithm Hash digest
SHA256 eaacd3ec7dcda4017d07fcc2e89e5bc505bd7531e2668ee33bd01f7e33787ccf
MD5 b37463c7fd44c3bfcdfba080abbc4194
BLAKE2b-256 005ab817a6308c526ab0c1dd4264a07f34fba9deebcc875933653e5b5f1e8cfb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page