From 1970a3fe105168d0a3e00e24345558278c035dc2 Mon Sep 17 00:00:00 2001 From: dh Date: Wed, 22 May 2024 00:08:45 +0200 Subject: [PATCH] code comments adjusted as proposed in review --- .../src/opentelemetry/instrumentation/asgi/__init__.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) 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 fea264137a..1d05d81c2c 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py @@ -370,18 +370,12 @@ def get_host_port_url_tuple(scope): server = scope.get("server") or ["0.0.0.0", 80] port = server[1] server_host = server[0] + (":" + str(port) if str(port) != "80" else "") - # To get the correct virtual url path within the hosting application (e.g also in a subapplication scenario) - # we have to remove the root_path from the path - # see: + # using the scope path is enough, see: # - https://asgi.readthedocs.io/en/latest/specs/www.html#http-connection-scope (see: root_path and path) # - https://asgi.readthedocs.io/en/latest/specs/www.html#wsgi-compatibility (see: PATH_INFO) # PATH_INFO can be derived by stripping root_path from path # -> that means that the path should contain the root_path already, so prefixing it again is not necessary # - https://wsgi.readthedocs.io/en/latest/definitions.html#envvar-PATH_INFO - # - # From investigation it seems (that at least for fastapi), the path is already correctly set. That means - # that root_path is already included in the path, so we can use it directly for full path. - # old way: full_path = scope.get("root_path", "") + scope.get("path", "") full_path = scope.get("path", "") http_url = scope.get("scheme", "http") + "://" + server_host + full_path return server_host, port, http_url