From f1f017fd15489afaa816831b0708c4a13221bb92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Em=C3=ADdio=20Neto?= <9735060+emdneto@users.noreply.github.com> Date: Mon, 12 Aug 2024 16:51:34 -0300 Subject: [PATCH 1/3] opentelemetry-bootstrap: remove aws-lambda from default instrumentations (#2786) --- CHANGELOG.md | 5 ++++- .../src/opentelemetry/instrumentation/bootstrap_gen.py | 1 - scripts/generate_instrumentation_bootstrap.py | 9 +++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4d996caeb..d1a113a91e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,10 +11,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `opentelemetry-instrumentation-kafka-python` Instrument temporary fork, kafka-python-ng inside kafka-python's instrumentation - ([#2537](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2537))) + ([#2537](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2537)) ## Breaking changes +- `opentelemetry-bootstrap` Remove `opentelemetry-instrumentation-aws-lambda` from the defaults instrumentations + ([#2786](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2786)) + ## Fixed - `opentelemetry-instrumentation-fastapi` fix `fastapi` auto-instrumentation by removing `fastapi-slim` support, `fastapi-slim` itself is discontinued from maintainers diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py index a701dbc5f4..c31863bd31 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/bootstrap_gen.py @@ -187,7 +187,6 @@ ] default_instrumentations = [ "opentelemetry-instrumentation-asyncio==0.48b0.dev", - "opentelemetry-instrumentation-aws-lambda==0.48b0.dev", "opentelemetry-instrumentation-dbapi==0.48b0.dev", "opentelemetry-instrumentation-logging==0.48b0.dev", "opentelemetry-instrumentation-sqlite3==0.48b0.dev", diff --git a/scripts/generate_instrumentation_bootstrap.py b/scripts/generate_instrumentation_bootstrap.py index 1c0cc30f7b..57af33e303 100755 --- a/scripts/generate_instrumentation_bootstrap.py +++ b/scripts/generate_instrumentation_bootstrap.py @@ -53,12 +53,21 @@ "bootstrap_gen.py", ) +# AWS Lambda instrumentation is excluded from the default list because it often +# requires specific configurations and dependencies that may not be set up +# in all environments. Instead, users who need AWS Lambda support can opt-in +# by manually adding it to their environment. +# See https://github.com/open-telemetry/opentelemetry-python-contrib/issues/2787 +packages_to_exclude = ["opentelemetry-instrumentation-aws-lambda"] + def main(): # pylint: disable=no-member default_instrumentations = ast.List(elts=[]) libraries = ast.List(elts=[]) for pkg in get_instrumentation_packages(): + if pkg.get("name") in packages_to_exclude: + continue if not pkg["instruments"]: default_instrumentations.elts.append(ast.Str(pkg["requirement"])) for target_pkg in pkg["instruments"]: From 9c327eae00a17f97c9929bf7edda7eb15247c184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Em=C3=ADdio=20Neto?= <9735060+emdneto@users.noreply.github.com> Date: Tue, 13 Aug 2024 17:48:46 -0300 Subject: [PATCH 2/3] bump aiohttp to 3.10.2 (#2796) --- .../test-requirements.txt | 2 +- .../tests/test_aiohttp_client_integration.py | 2 +- .../test-requirements.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-client/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-aiohttp-client/test-requirements.txt index fd44fbbc62..be0311238f 100644 --- a/instrumentation/opentelemetry-instrumentation-aiohttp-client/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-client/test-requirements.txt @@ -1,4 +1,4 @@ -aiohttp==3.9.4 +aiohttp==3.10.2 aiosignal==1.3.1 asgiref==3.7.2 async-timeout==4.0.3 diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py b/instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py index adf54c295b..8474bd436f 100644 --- a/instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-client/tests/test_aiohttp_client_integration.py @@ -468,7 +468,7 @@ async def request_handler(request): [ ( "GET", - (StatusCode.ERROR, "ServerTimeoutError"), + (StatusCode.ERROR, "SocketTimeoutError"), { SpanAttributes.HTTP_METHOD: "GET", SpanAttributes.HTTP_URL: f"http://{host}:{port}/test_timeout", diff --git a/instrumentation/opentelemetry-instrumentation-aiohttp-server/test-requirements.txt b/instrumentation/opentelemetry-instrumentation-aiohttp-server/test-requirements.txt index b83eff27f0..9cd6a3c111 100644 --- a/instrumentation/opentelemetry-instrumentation-aiohttp-server/test-requirements.txt +++ b/instrumentation/opentelemetry-instrumentation-aiohttp-server/test-requirements.txt @@ -1,4 +1,4 @@ -aiohttp==3.9.4 +aiohttp==3.10.2 aiosignal==1.3.1 asgiref==3.7.2 async-timeout==4.0.3 From af9e841742c0f540476cba80d4eeea6673fb9a55 Mon Sep 17 00:00:00 2001 From: shijiadong2022 Date: Thu, 15 Aug 2024 01:26:39 +0800 Subject: [PATCH 3/3] Fix issue opentelemetry-instrumentation-asgi: do not set url.full attribute for server spans (#2735) --- CHANGELOG.md | 2 ++ .../instrumentation/asgi/__init__.py | 10 ++++++---- .../tests/test_asgi_middleware.py | 19 ++++++++----------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d1a113a91e..39236a33f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ([#2750](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2750)) - `opentelemetry-instrumentation-django` Fix regression - `http.target` re-added back to old semconv duration metrics ([#2746](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2746)) +- `opentelemetry-instrumentation-asgi` do not set `url.full` attribute for server spans + ([#2735](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2735)) - `opentelemetry-instrumentation-grpc` Fixes the issue with the gRPC instrumentation not working with the 1.63.0 and higher version of gRPC ([#2483](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2484)) - `opentelemetry-instrumentation-aws-lambda` Fixing w3c baggage support diff --git a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py index 0525181eac..8e3199cef8 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py @@ -354,10 +354,12 @@ def collect_request_attributes( result, path, path, query_string, sem_conv_opt_in_mode ) if http_url: - _set_http_url( - result, remove_url_credentials(http_url), sem_conv_opt_in_mode - ) - + if _report_old(sem_conv_opt_in_mode): + _set_http_url( + result, + remove_url_credentials(http_url), + _HTTPStabilityMode.DEFAULT, + ) http_method = scope.get("method", "") if http_method: _set_http_method( diff --git a/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py b/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py index 5bb04adb25..af51faa808 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py +++ b/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py @@ -58,7 +58,6 @@ SERVER_PORT, ) from opentelemetry.semconv.attributes.url_attributes import ( - URL_FULL, URL_PATH, URL_QUERY, URL_SCHEME, @@ -410,7 +409,6 @@ def validate_outputs( SERVER_ADDRESS: "127.0.0.1", NETWORK_PROTOCOL_VERSION: "1.0", URL_PATH: "/", - URL_FULL: "http://127.0.0.1/", CLIENT_ADDRESS: "127.0.0.1", CLIENT_PORT: 32767, HTTP_RESPONSE_STATUS_CODE: 200, @@ -447,7 +445,6 @@ def validate_outputs( SERVER_ADDRESS: "127.0.0.1", NETWORK_PROTOCOL_VERSION: "1.0", URL_PATH: "/", - URL_FULL: "http://127.0.0.1/", CLIENT_ADDRESS: "127.0.0.1", CLIENT_PORT: 32767, HTTP_RESPONSE_STATUS_CODE: 200, @@ -693,7 +690,6 @@ def update_expected_server(expected): { SERVER_ADDRESS: "0.0.0.0", SERVER_PORT: 80, - URL_FULL: "http://0.0.0.0/", } ) return expected @@ -721,7 +717,6 @@ def update_expected_server(expected): SpanAttributes.HTTP_URL: "http://0.0.0.0/", SERVER_ADDRESS: "0.0.0.0", SERVER_PORT: 80, - URL_FULL: "http://0.0.0.0/", } ) return expected @@ -1009,7 +1004,6 @@ def test_websocket_new_semconv(self): SERVER_ADDRESS: self.scope["server"][0], NETWORK_PROTOCOL_VERSION: self.scope["http_version"], URL_PATH: self.scope["path"], - URL_FULL: f'{self.scope["scheme"]}://{self.scope["server"][0]}{self.scope["path"]}', CLIENT_ADDRESS: self.scope["client"][0], CLIENT_PORT: self.scope["client"][1], HTTP_RESPONSE_STATUS_CODE: 200, @@ -1095,7 +1089,6 @@ def test_websocket_both_semconv(self): SERVER_ADDRESS: self.scope["server"][0], NETWORK_PROTOCOL_VERSION: self.scope["http_version"], URL_PATH: self.scope["path"], - URL_FULL: f'{self.scope["scheme"]}://{self.scope["server"][0]}{self.scope["path"]}', CLIENT_ADDRESS: self.scope["client"][0], CLIENT_PORT: self.scope["client"][1], HTTP_RESPONSE_STATUS_CODE: 200, @@ -1639,7 +1632,6 @@ def test_request_attributes_new_semconv(self): SERVER_ADDRESS: "127.0.0.1", URL_PATH: "/", URL_QUERY: "foo=bar", - URL_FULL: "http://127.0.0.1/?foo=bar", SERVER_PORT: 80, URL_SCHEME: "http", NETWORK_PROTOCOL_VERSION: "1.0", @@ -1676,7 +1668,6 @@ def test_request_attributes_both_semconv(self): SERVER_ADDRESS: "127.0.0.1", URL_PATH: "/", URL_QUERY: "foo=bar", - URL_FULL: "http://127.0.0.1/?foo=bar", SERVER_PORT: 80, URL_SCHEME: "http", NETWORK_PROTOCOL_VERSION: "1.0", @@ -1698,7 +1689,10 @@ def test_query_string_new_semconv(self): self.scope, _HTTPStabilityMode.HTTP, ) - self.assertEqual(attrs[URL_FULL], "http://127.0.0.1/?foo=bar") + self.assertEqual(attrs[URL_SCHEME], "http") + self.assertEqual(attrs[SERVER_ADDRESS], "127.0.0.1") + self.assertEqual(attrs[URL_PATH], "/") + self.assertEqual(attrs[URL_QUERY], "foo=bar") def test_query_string_both_semconv(self): self.scope["query_string"] = b"foo=bar" @@ -1706,10 +1700,13 @@ def test_query_string_both_semconv(self): self.scope, _HTTPStabilityMode.HTTP_DUP, ) - self.assertEqual(attrs[URL_FULL], "http://127.0.0.1/?foo=bar") self.assertEqual( attrs[SpanAttributes.HTTP_URL], "http://127.0.0.1/?foo=bar" ) + self.assertEqual(attrs[URL_SCHEME], "http") + self.assertEqual(attrs[SERVER_ADDRESS], "127.0.0.1") + self.assertEqual(attrs[URL_PATH], "/") + self.assertEqual(attrs[URL_QUERY], "foo=bar") def test_query_string_percent_bytes(self): self.scope["query_string"] = b"foo%3Dbar"