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.14b0.tar.gz.

File metadata

  • Download URL: opentelemetry-instrumentation-asgi-0.14b0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.7.9

File hashes

Hashes for opentelemetry-instrumentation-asgi-0.14b0.tar.gz
Algorithm Hash digest
SHA256 10d12339f81b047e7605ad9b3bb4a0c2ccc9353114edaa4ba86af087e753b681
MD5 9b5393eb7c177b87169af9e1073b5426
BLAKE2b-256 2e9bdf6c5bb54dedc602f60282ad8a84a982941bc028a65551fa284c6302c4b7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opentelemetry_instrumentation_asgi-0.14b0-py3-none-any.whl
Algorithm Hash digest
SHA256 8aa71c927a2d3f1d78d5eb250027299644982c6bea0abff1c1ad3db42d6ba470
MD5 d5332b8fc01ec2329dbe85e5aface629
BLAKE2b-256 b8fe4b33d43aaaa22df6df5fbb4f7a98f7c2269d2b4c16c7465e25a4a69d3a67

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