Skip to content

Commit 0fae730

Browse files
committed
Improve urllib3 instrumentation example
1 parent 6114b60 commit 0fae730

File tree

1 file changed

+15
-6
lines changed
  • instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3

1 file changed

+15
-6
lines changed

instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,22 +47,31 @@ def strip_query_params(url: str) -> str:
4747
4848
.. code:: python
4949
50+
from typing import Any
51+
52+
from urllib3.connectionpool import HTTPConnectionPool
53+
from urllib3.response import HTTPResponse
54+
55+
from opentelemetry.instrumentation.urllib3 import RequestInfo, URLLib3Instrumentor
56+
from opentelemetry.trace import Span
57+
5058
def request_hook(
5159
span: Span,
52-
pool: urllib3.connectionpool.HTTPConnectionPool,
60+
pool: HTTPConnectionPool,
5361
request_info: RequestInfo,
5462
) -> Any:
55-
...
63+
pass
5664
5765
def response_hook(
5866
span: Span,
59-
pool: urllib3.connectionpool.HTTPConnectionPool,
60-
response: urllib3.response.HTTPResponse,
67+
pool: HTTPConnectionPool,
68+
response: HTTPResponse,
6169
) -> Any:
62-
...
70+
pass
6371
6472
URLLib3Instrumentor().instrument(
65-
request_hook=request_hook, response_hook=response_hook
73+
request_hook=request_hook,
74+
response_hook=response_hook
6675
)
6776
6877
Exclude lists

0 commit comments

Comments
 (0)