OpenTelemetry HTTP Utilities
Provides HTTP-related utilities for OpenTelemetry instrumentation, currently at version 0.61b0, with a beta release cadence.
Warnings
- breaking The 'http.target' attribute has been split into 'url.path' and 'url.query' as part of the stabilization of HTTP Semantic Conventions. Ensure your instrumentation and observability tools are updated accordingly.
- deprecated The 'http.client_ip' attribute has been replaced with 'client.address' in the latest semantic conventions. Update your code to use 'client.address' for client IP information.
Install
-
pip install opentelemetry-util-http
Imports
- HttpInstrumentation
from opentelemetry.instrumentation.httpx import HttpInstrumentation
Quickstart
import os
from opentelemetry.instrumentation.httpx import HttpInstrumentation
# Initialize the HTTPX instrumentation
httpx_instrumentor = HttpInstrumentation()
httpx_instrumentor.enable()
# Your application code here
# For example, making an HTTP request using httpx
import httpx
client = httpx.Client()
response = client.get('http://example.com')
print(response.status_code)
# Disable the instrumentation when done
httpx_instrumentor.disable()