Skip to content

Commit

Permalink
Fixing lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashutosh Goel committed Feb 17, 2022
1 parent bf35d98 commit dadd49c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,7 @@ def capture_custom_request_headers(environ, attributes):
)
for header_name in custom_request_headers:
wsgi_env_var = header_name.upper().replace("-", "_")
header_values = environ.get(
"HTTP_{wsgi_env_var}".format(wsgi_env_var=wsgi_env_var)
)
header_values = environ.get(f"HTTP_{wsgi_env_var}")

if header_values:
key = normalise_request_header_name(header_name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,13 @@ def remove_url_credentials(url: str) -> str:


def normalise_request_header_name(header):
return "http.request.header.{key}".format(
key=header.lower().replace("-", "_")
)
key = header.lower().replace("-", "_")
return f"http.request.header.{key}"


def normalise_response_header_name(header):
return "http.response.header.{key}".format(
key=header.lower().replace("-", "_")
)
key=header.lower().replace("-", "_")
return f"http.response.header.{key}"


def get_custom_headers(env_var):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_get_custom_request_header(self):
custom_headers_to_capture = get_custom_headers(
OTEL_PYTHON_CAPTURE_REQUEST_HEADERS
)
assert custom_headers_to_capture == ["User-Agent", "Test-Header"]
self.assertEqual(custom_headers_to_capture, ["User-Agent", "Test-Header"])

@patch.dict(
"os.environ",
Expand All @@ -45,16 +45,16 @@ def test_get_custom_response_header(self):
custom_headers_to_capture = get_custom_headers(
OTEL_PYTHON_CAPTURE_RESPONSE_HEADERS
)
assert custom_headers_to_capture == [
self.assertEqual(custom_headers_to_capture, [
"content-type",
"content-length",
"test-header",
]
])

def test_normalise_request_header_name(self):
key = normalise_request_header_name("Test-Header")
assert key == "http.request.header.test_header"
self.assertEqual(key, "http.request.header.test_header")

def test_normalise_response_header_name(self):
key = normalise_response_header_name("Test-Header")
assert key == "http.response.header.test_header"
self.assertEqual(key, "http.response.header.test_header")

0 comments on commit dadd49c

Please sign in to comment.