Skip to content

Commit 96c8d16

Browse files
committed
fix: pre-commit run
1 parent d8cb55d commit 96c8d16

File tree

1 file changed

+13
-4
lines changed
  • instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi

1 file changed

+13
-4
lines changed

instrumentation/opentelemetry-instrumentation-wsgi/src/opentelemetry/instrumentation/wsgi/__init__.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,9 @@ def response_hook(span: Span, environ: WSGIEnvironment, status: str, response_he
219219

220220
import functools
221221
import wsgiref.util as wsgiref_util
222-
from urllib.parse import quote
223222
from timeit import default_timer
224223
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, TypeVar, cast
224+
from urllib.parse import quote
225225

226226
from opentelemetry import context, trace
227227
from opentelemetry.instrumentation._semconv import (
@@ -373,13 +373,22 @@ def collect_request_attributes(
373373
# old semconv v1.20.0
374374
if _report_old(sem_conv_opt_in_mode):
375375
try:
376-
result[HTTP_URL] = redact_url(wsgiref_util.request_uri(environ))
376+
result[HTTP_URL] = redact_url(
377+
wsgiref_util.request_uri(environ)
378+
)
377379
except UnicodeEncodeError:
378380
# The underlying wsgiref library seems to hardcode latin1 into this call
379381
# This can cause issues for some characters and you can hit decode errors
380-
path_info = quote(environ.get("PATH_INFO", ""), safe="/;=,", encoding="utf-8", errors="replace")
382+
path_info = quote(
383+
environ.get("PATH_INFO", ""),
384+
safe="/;=,",
385+
encoding="utf-8",
386+
errors="replace",
387+
)
381388
scheme = environ.get("wsgi.url_scheme", "http")
382-
host = environ.get("HTTP_HOST", environ.get("SERVER_NAME", "localhost"))
389+
host = environ.get(
390+
"HTTP_HOST", environ.get("SERVER_NAME", "localhost")
391+
)
383392
url = f"{scheme}://{host}{path_info}"
384393

385394
if environ.get("QUERY_STRING"):

0 commit comments

Comments
 (0)