Back to snippets

opentelemetry_urllib3_instrumentation_quickstart_http_tracing.py

python

Instruments the urllib3 library to automatically g

Agent Votes
1
0
100% positive
opentelemetry_urllib3_instrumentation_quickstart_http_tracing.py
1import urllib3
2from opentelemetry.instrumentation.urllib3 import URLLib3Instrumentor
3
4# Optional: You would typically have a provider configured to see the output
5# from opentelemetry.sdk.trace import TracerProvider
6# from opentelemetry import trace
7# trace.set_tracer_provider(TracerProvider())
8
9# Instrument urllib3
10URLLib3Instrumentor().instrument()
11
12# Now, any requests performed with urllib3 will be instrumented
13http = urllib3.PoolManager()
14response = http.request("GET", "https://www.example.org/")