Skip to content

Commit

Permalink
add linter
Browse files Browse the repository at this point in the history
  • Loading branch information
axel584 committed May 4, 2024
1 parent d9bf6eb commit eeeaba8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ class OpenTelemetryMiddleware:
incoming request.
tracer_provider: Optional tracer provider to use. If omitted the current
globally configured one is used.
excluded_urls: list of urls to exclude
excluded_urls: list of urls to exclude
"""

def __init__(
Expand Down Expand Up @@ -627,7 +627,7 @@ def __call__(self, environ, start_response):
start_response: The WSGI start_response callable.
"""
if environ.get("PATH_INFO") in self.excluded_urls:
return self.wsgi(environ, start_response)
return self.wsgi(environ, start_response)
req_attrs = collect_request_attributes(
environ, self._sem_conv_opt_in_mode
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ def validate_response(
if old_sem_conv:
expected_attributes[SpanAttributes.HTTP_METHOD] = http_method
if new_sem_conv:
expected_attributes[SpanAttributes.HTTP_REQUEST_METHOD] = (
http_method
)
expected_attributes[
SpanAttributes.HTTP_REQUEST_METHOD
] = http_method
self.assertEqual(span_list[0].attributes, expected_attributes)

def test_basic_wsgi_call(self):
Expand All @@ -274,10 +274,12 @@ def test_basic_wsgi_call_both_semconv(self):
self.validate_response(response, old_sem_conv=True, new_sem_conv=True)

def test_basic_wsgi_call_with_excluded_urls(self):
app = otel_wsgi.OpenTelemetryMiddleware(simple_wsgi, excluded_urls="/test")
app = otel_wsgi.OpenTelemetryMiddleware(
simple_wsgi, excluded_urls="/test"
)
self.environ["PATH_INFO"] = "/test"
response = app(self.environ, self.start_response)
assert(isinstance(response,list))
assert isinstance(response, list)

def test_hooks(self):
hook_headers = (
Expand Down Expand Up @@ -570,9 +572,9 @@ def validate_url(
parts.path, 1
)[1]
if parts.query:
expected_new[SpanAttributes.URL_QUERY] = (
expected_url.split(parts.query, 1)[1]
)
expected_new[
SpanAttributes.URL_QUERY
] = expected_url.split(parts.query, 1)[1]
else:
expected_new[SpanAttributes.HTTP_URL] = expected_url
if has_host:
Expand Down Expand Up @@ -718,9 +720,9 @@ def test_request_attributes_pathless(self):
def test_request_attributes_with_full_request_uri(self):
self.environ["HTTP_HOST"] = "127.0.0.1:8080"
self.environ["REQUEST_METHOD"] = "CONNECT"
self.environ["REQUEST_URI"] = (
"http://docs.python.org:80/3/library/urllib.parse.html?highlight=params#url-parsing" # Might happen in a CONNECT request
)
self.environ[
"REQUEST_URI"
] = "http://docs.python.org:80/3/library/urllib.parse.html?highlight=params#url-parsing" # Might happen in a CONNECT request
expected_old = {
SpanAttributes.HTTP_HOST: "127.0.0.1:8080",
SpanAttributes.HTTP_TARGET: "http://docs.python.org:80/3/library/urllib.parse.html?highlight=params#url-parsing",
Expand Down

0 comments on commit eeeaba8

Please sign in to comment.