Skip to content

Commit fd52a83

Browse files
authored
Merge branch 'main' into redis_additional_attributes
2 parents c53b08e + af9e841 commit fd52a83

File tree

10 files changed

+42
-24
lines changed

10 files changed

+42
-24
lines changed

Diff for: CHANGELOG.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- `opentelemetry-instrumentation-kafka-python` Instrument temporary fork, kafka-python-ng
1313
inside kafka-python's instrumentation
14-
([#2537](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2537)))
14+
([#2537](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2537))
1515

1616
## Breaking changes
1717

18+
- `opentelemetry-bootstrap` Remove `opentelemetry-instrumentation-aws-lambda` from the defaults instrumentations
19+
([#2786](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2786))
20+
1821
## Fixed
1922

2023
- `opentelemetry-instrumentation-fastapi` fix `fastapi` auto-instrumentation by removing `fastapi-slim` support, `fastapi-slim` itself is discontinued from maintainers
@@ -23,12 +26,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2326
([#2750](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2750))
2427
- `opentelemetry-instrumentation-django` Fix regression - `http.target` re-added back to old semconv duration metrics
2528
([#2746](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2746))
29+
- `opentelemetry-instrumentation-asgi` do not set `url.full` attribute for server spans
30+
([#2735](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2735))
2631
- `opentelemetry-instrumentation-grpc` Fixes the issue with the gRPC instrumentation not working with the 1.63.0 and higher version of gRPC
2732
([#2483](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2484))
2833
- `opentelemetry-instrumentation-aws-lambda` Fixing w3c baggage support
2934
([#2589](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2589))
3035
- `opentelemetry-instrumentation-celery` propagates baggage
3136
([#2385](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2385))
37+
- `opentelemetry-instrumentation-asyncio` Fixes async generator coroutines not being awaited
38+
([#2792](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2792))
3239

3340
## Version 1.26.0/0.47b0 (2024-07-23)
3441

Diff for: instrumentation/opentelemetry-instrumentation-aiohttp-client/test-requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
aiohttp==3.9.4
1+
aiohttp==3.10.2
22
aiosignal==1.3.1
33
asgiref==3.7.2
44
async-timeout==4.0.3

Diff for: instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ async def request_handler(request):
468468
[
469469
(
470470
"GET",
471-
(StatusCode.ERROR, "ServerTimeoutError"),
471+
(StatusCode.ERROR, "SocketTimeoutError"),
472472
{
473473
SpanAttributes.HTTP_METHOD: "GET",
474474
SpanAttributes.HTTP_URL: f"http://{host}:{port}/test_timeout",

Diff for: instrumentation/opentelemetry-instrumentation-aiohttp-server/test-requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
aiohttp==3.9.4
1+
aiohttp==3.10.2
22
aiosignal==1.3.1
33
asgiref==3.7.2
44
async-timeout==4.0.3

Diff for: instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,12 @@ def collect_request_attributes(
354354
result, path, path, query_string, sem_conv_opt_in_mode
355355
)
356356
if http_url:
357-
_set_http_url(
358-
result, remove_url_credentials(http_url), sem_conv_opt_in_mode
359-
)
360-
357+
if _report_old(sem_conv_opt_in_mode):
358+
_set_http_url(
359+
result,
360+
remove_url_credentials(http_url),
361+
_HTTPStabilityMode.DEFAULT,
362+
)
361363
http_method = scope.get("method", "")
362364
if http_method:
363365
_set_http_method(

Diff for: instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py

+8-11
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
SERVER_PORT,
5959
)
6060
from opentelemetry.semconv.attributes.url_attributes import (
61-
URL_FULL,
6261
URL_PATH,
6362
URL_QUERY,
6463
URL_SCHEME,
@@ -410,7 +409,6 @@ def validate_outputs(
410409
SERVER_ADDRESS: "127.0.0.1",
411410
NETWORK_PROTOCOL_VERSION: "1.0",
412411
URL_PATH: "/",
413-
URL_FULL: "http://127.0.0.1/",
414412
CLIENT_ADDRESS: "127.0.0.1",
415413
CLIENT_PORT: 32767,
416414
HTTP_RESPONSE_STATUS_CODE: 200,
@@ -447,7 +445,6 @@ def validate_outputs(
447445
SERVER_ADDRESS: "127.0.0.1",
448446
NETWORK_PROTOCOL_VERSION: "1.0",
449447
URL_PATH: "/",
450-
URL_FULL: "http://127.0.0.1/",
451448
CLIENT_ADDRESS: "127.0.0.1",
452449
CLIENT_PORT: 32767,
453450
HTTP_RESPONSE_STATUS_CODE: 200,
@@ -693,7 +690,6 @@ def update_expected_server(expected):
693690
{
694691
SERVER_ADDRESS: "0.0.0.0",
695692
SERVER_PORT: 80,
696-
URL_FULL: "http://0.0.0.0/",
697693
}
698694
)
699695
return expected
@@ -721,7 +717,6 @@ def update_expected_server(expected):
721717
SpanAttributes.HTTP_URL: "http://0.0.0.0/",
722718
SERVER_ADDRESS: "0.0.0.0",
723719
SERVER_PORT: 80,
724-
URL_FULL: "http://0.0.0.0/",
725720
}
726721
)
727722
return expected
@@ -1009,7 +1004,6 @@ def test_websocket_new_semconv(self):
10091004
SERVER_ADDRESS: self.scope["server"][0],
10101005
NETWORK_PROTOCOL_VERSION: self.scope["http_version"],
10111006
URL_PATH: self.scope["path"],
1012-
URL_FULL: f'{self.scope["scheme"]}://{self.scope["server"][0]}{self.scope["path"]}',
10131007
CLIENT_ADDRESS: self.scope["client"][0],
10141008
CLIENT_PORT: self.scope["client"][1],
10151009
HTTP_RESPONSE_STATUS_CODE: 200,
@@ -1095,7 +1089,6 @@ def test_websocket_both_semconv(self):
10951089
SERVER_ADDRESS: self.scope["server"][0],
10961090
NETWORK_PROTOCOL_VERSION: self.scope["http_version"],
10971091
URL_PATH: self.scope["path"],
1098-
URL_FULL: f'{self.scope["scheme"]}://{self.scope["server"][0]}{self.scope["path"]}',
10991092
CLIENT_ADDRESS: self.scope["client"][0],
11001093
CLIENT_PORT: self.scope["client"][1],
11011094
HTTP_RESPONSE_STATUS_CODE: 200,
@@ -1639,7 +1632,6 @@ def test_request_attributes_new_semconv(self):
16391632
SERVER_ADDRESS: "127.0.0.1",
16401633
URL_PATH: "/",
16411634
URL_QUERY: "foo=bar",
1642-
URL_FULL: "http://127.0.0.1/?foo=bar",
16431635
SERVER_PORT: 80,
16441636
URL_SCHEME: "http",
16451637
NETWORK_PROTOCOL_VERSION: "1.0",
@@ -1676,7 +1668,6 @@ def test_request_attributes_both_semconv(self):
16761668
SERVER_ADDRESS: "127.0.0.1",
16771669
URL_PATH: "/",
16781670
URL_QUERY: "foo=bar",
1679-
URL_FULL: "http://127.0.0.1/?foo=bar",
16801671
SERVER_PORT: 80,
16811672
URL_SCHEME: "http",
16821673
NETWORK_PROTOCOL_VERSION: "1.0",
@@ -1698,18 +1689,24 @@ def test_query_string_new_semconv(self):
16981689
self.scope,
16991690
_HTTPStabilityMode.HTTP,
17001691
)
1701-
self.assertEqual(attrs[URL_FULL], "http://127.0.0.1/?foo=bar")
1692+
self.assertEqual(attrs[URL_SCHEME], "http")
1693+
self.assertEqual(attrs[SERVER_ADDRESS], "127.0.0.1")
1694+
self.assertEqual(attrs[URL_PATH], "/")
1695+
self.assertEqual(attrs[URL_QUERY], "foo=bar")
17021696

17031697
def test_query_string_both_semconv(self):
17041698
self.scope["query_string"] = b"foo=bar"
17051699
attrs = otel_asgi.collect_request_attributes(
17061700
self.scope,
17071701
_HTTPStabilityMode.HTTP_DUP,
17081702
)
1709-
self.assertEqual(attrs[URL_FULL], "http://127.0.0.1/?foo=bar")
17101703
self.assertEqual(
17111704
attrs[SpanAttributes.HTTP_URL], "http://127.0.0.1/?foo=bar"
17121705
)
1706+
self.assertEqual(attrs[URL_SCHEME], "http")
1707+
self.assertEqual(attrs[SERVER_ADDRESS], "127.0.0.1")
1708+
self.assertEqual(attrs[URL_PATH], "/")
1709+
self.assertEqual(attrs[URL_QUERY], "foo=bar")
17131710

17141711
def test_query_string_percent_bytes(self):
17151712
self.scope["query_string"] = b"foo%3Dbar"

Diff for: instrumentation/opentelemetry-instrumentation-asyncio/src/opentelemetry/instrumentation/asyncio/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def trace_item(self, coro_or_future):
262262

263263
async def trace_coroutine(self, coro):
264264
if not hasattr(coro, "__name__"):
265-
return coro
265+
return await coro
266266
start = default_timer()
267267
attr = {
268268
"type": "coroutine",

Diff for: instrumentation/opentelemetry-instrumentation-asyncio/tests/test_asyncio_anext.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,23 @@ def tearDown(self):
4343

4444
# Asyncio anext() does not have __name__ attribute, which is used to determine if the coroutine should be traced.
4545
# This test is to ensure that the instrumentation does not break when the coroutine does not have __name__ attribute.
46+
# Additionally, ensure the coroutine is actually awaited.
4647
@skipIf(
4748
sys.version_info < (3, 10), "anext is only available in Python 3.10+"
4849
)
4950
def test_asyncio_anext(self):
5051
async def main():
5152
async def async_gen():
52-
for it in range(2):
53+
# nothing special about this range other than to avoid returning a zero
54+
# from a function named 'main' (which might cause confusion about intent)
55+
for it in range(2, 4):
5356
yield it
5457

5558
async_gen_instance = async_gen()
5659
agen = anext(async_gen_instance)
57-
await asyncio.create_task(agen)
60+
return await asyncio.create_task(agen)
5861

59-
asyncio.run(main())
62+
ret = asyncio.run(main())
63+
self.assertEqual(ret, 2) # first iteration from range()
6064
spans = self.memory_exporter.get_finished_spans()
6165
self.assertEqual(len(spans), 0)

Diff for: opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py

-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@
187187
]
188188
default_instrumentations = [
189189
"opentelemetry-instrumentation-asyncio==0.48b0.dev",
190-
"opentelemetry-instrumentation-aws-lambda==0.48b0.dev",
191190
"opentelemetry-instrumentation-dbapi==0.48b0.dev",
192191
"opentelemetry-instrumentation-logging==0.48b0.dev",
193192
"opentelemetry-instrumentation-sqlite3==0.48b0.dev",

Diff for: scripts/generate_instrumentation_bootstrap.py

+9
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,21 @@
5353
"bootstrap_gen.py",
5454
)
5555

56+
# AWS Lambda instrumentation is excluded from the default list because it often
57+
# requires specific configurations and dependencies that may not be set up
58+
# in all environments. Instead, users who need AWS Lambda support can opt-in
59+
# by manually adding it to their environment.
60+
# See https://github.com/open-telemetry/opentelemetry-python-contrib/issues/2787
61+
packages_to_exclude = ["opentelemetry-instrumentation-aws-lambda"]
62+
5663

5764
def main():
5865
# pylint: disable=no-member
5966
default_instrumentations = ast.List(elts=[])
6067
libraries = ast.List(elts=[])
6168
for pkg in get_instrumentation_packages():
69+
if pkg.get("name") in packages_to_exclude:
70+
continue
6271
if not pkg["instruments"]:
6372
default_instrumentations.elts.append(ast.Str(pkg["requirement"]))
6473
for target_pkg in pkg["instruments"]:

0 commit comments

Comments
 (0)