Skip to main content

Web util for OpenTelemetry

Project description

pypi

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opentelemetry_util_http-0.49b0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file opentelemetry_util_http-0.49b0.tar.gz.

File metadata

File hashes

Hashes for opentelemetry_util_http-0.49b0.tar.gz
Algorithm Hash digest
SHA256 02928496afcffd58a7c15baf99d2cedae9b8325a8ac52b0d0877b2e8f936dd1b
MD5 1a195ea1b905546f5b96de1792bf2f1a
BLAKE2b-256 a399377ef446928808211b127b9ab31c348bc465c8da4514ebeec6e4a3de3d21

See more details on using hashes here.

File details

Details for the file opentelemetry_util_http-0.49b0-py3-none-any.whl.

File metadata

File hashes

Hashes for opentelemetry_util_http-0.49b0-py3-none-any.whl
Algorithm Hash digest
SHA256 8661bbd6aea1839badc44de067ec9c15c05eab05f729f496c856c50a1203caf1
MD5 4b1ad839196a1c93654c000e5622402c
BLAKE2b-256 660eab0a89b315d0bacdd355a345bb69b20c50fc1f0804b52b56fe1c35a60e68

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