Skip to content

Commit b3bea3c

Browse files
committed
Merge branch 'main' into fix-asgi-middleware
2 parents 0870986 + 6daf581 commit b3bea3c

File tree

5 files changed

+58
-17
lines changed

5 files changed

+58
-17
lines changed

dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pylint==3.0.2
22
httpretty==1.1.4
3-
pyright==v1.1.390
3+
pyright==v1.1.396
44
sphinx==7.1.2
55
sphinx-rtd-theme==2.0.0rc4
66
sphinx-autodoc-typehints==1.25.2

instrumentation-genai/opentelemetry-instrumentation-vertexai/src/opentelemetry/instrumentation/vertexai/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def request_to_events(
240240
id_=f"{function_response.name}_{idx}",
241241
role=content.role,
242242
content=json_format.MessageToDict(
243-
function_response._pb.response # type: ignore[reportUnknownMemberType]
243+
function_response._pb.response
244244
)
245245
if capture_content
246246
else None,
@@ -300,7 +300,7 @@ def _extract_tool_calls(
300300
function=ChoiceToolCall.Function(
301301
name=part.function_call.name,
302302
arguments=json_format.MessageToDict(
303-
part.function_call._pb.args # type: ignore[reportUnknownMemberType]
303+
part.function_call._pb.args
304304
)
305305
if capture_content
306306
else None,

instrumentation/opentelemetry-instrumentation-urllib3/README.rst

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,24 @@ Installation
1616

1717
pip install opentelemetry-instrumentation-urllib3
1818

19+
Usage
20+
-----
21+
.. code-block:: python
22+
23+
import urllib3
24+
from opentelemetry.instrumentation.urllib3 import URLLib3Instrumentor
25+
26+
def strip_query_params(url: str) -> str:
27+
return url.split("?")[0]
28+
29+
URLLib3Instrumentor().instrument(
30+
# Remove all query params from the URL attribute on the span.
31+
url_filter=strip_query_params,
32+
)
33+
34+
http = urllib3.PoolManager()
35+
response = http.request("GET", "https://www.example.org/")
36+
1937
Configuration
2038
-------------
2139

@@ -29,17 +47,31 @@ The hooks can be configured as follows:
2947

3048
.. code:: python
3149
32-
# `request` is an instance of urllib3.connectionpool.HTTPConnectionPool
33-
def request_hook(span, request):
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+
58+
def request_hook(
59+
span: Span,
60+
pool: HTTPConnectionPool,
61+
request_info: RequestInfo,
62+
) -> Any:
3463
pass
3564
36-
# `request` is an instance of urllib3.connectionpool.HTTPConnectionPool
37-
# `response` is an instance of urllib3.response.HTTPResponse
38-
def response_hook(span, request, response):
65+
def response_hook(
66+
span: Span,
67+
pool: HTTPConnectionPool,
68+
response: HTTPResponse,
69+
) -> Any:
3970
pass
4071
4172
URLLib3Instrumentor().instrument(
42-
request_hook=request_hook, response_hook=response_hook
73+
request_hook=request_hook,
74+
response_hook=response_hook,
4375
)
4476
4577
Exclude lists

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

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ pythonVersion = "3.8"
196196
reportPrivateUsage = false # Ignore private attributes added by instrumentation packages.
197197
# Add progressively instrumentation packages here.
198198
include = [
199-
"instrumentation/opentelemetry-instrumentation-threading/**/*.py",
200-
"instrumentation-genai/opentelemetry-instrumentation-vertexai/**/*.py",
199+
"instrumentation/opentelemetry-instrumentation-threading",
200+
"instrumentation-genai/opentelemetry-instrumentation-vertexai",
201201
]
202202
# We should also add type hints to the test suite - It helps on finding bugs.
203203
# We are excluding for now because it's easier, and more important to add to the instrumentation packages.

0 commit comments

Comments
 (0)