Skip to content

Commit 70f229a

Browse files
committed
better handling for query_string
1 parent bc6f0a9 commit 70f229a

File tree

1 file changed

+5
-5
lines changed
  • ext/opentelemetry-ext-asgi/src/opentelemetry/ext/asgi

1 file changed

+5
-5
lines changed

ext/opentelemetry-ext-asgi/src/opentelemetry/ext/asgi/__init__.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ def collect_request_attributes(scope):
8383
server_host = server[0] + (":" + str(port) if port != 80 else "")
8484
full_path = scope.get("root_path", "") + scope.get("path", "")
8585
http_url = scope.get("scheme", "http") + "://" + server_host + full_path
86-
if scope.get("query_string") and http_url:
87-
if isinstance(scope["query_string"], bytes):
88-
http_url = http_url + ("?" + scope.get("query_string").decode("utf8"))
89-
else:
90-
http_url = http_url + ("?" + urllib.parse.unquote(scope.get("query_string")))
86+
query_string = scope.get("query_string")
87+
if query_string and http_url:
88+
if isinstance(query_string, bytes):
89+
query_string = query_string.decode("utf8")
90+
http_url = http_url + ("?" + urllib.parse.unquote(query_string))
9191

9292
result = {
9393
"component": scope["type"],

0 commit comments

Comments
 (0)