Skip to content

Commit 0fb268f

Browse files
committed
Fixed ruff
1 parent 2d7fa97 commit 0fb268f

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
> Use [this search for a list of all CHANGELOG.md files in this repo](https://github.com/search?q=repo%3Aopen-telemetry%2Fopentelemetry-python-contrib+path%3A**%2FCHANGELOG.md&type=code).
1111
1212
## Unreleased
13-
- `opentelemetry-util-http` Added support for redacting specific url query string values and url credentials in instrumentations
14-
([#3508](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3508))
1513

1614
## Version 1.34.0/0.55b0 (2025-06-04)
1715

@@ -24,6 +22,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2422

2523
- `opentelemetry-instrumentation-aiokafka` Add instrumentation of `consumer.getmany` (batch)
2624
([#3257](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3257))
25+
- `opentelemetry-util-http` Added support for redacting specific url query string values and url credentials in instrumentations
26+
([#3508](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3508))
2727

2828
### Fixed
2929

instrumentation/opentelemetry-instrumentation-httpx/tests/test_httpx_integration.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,8 +1316,11 @@ def test_remove_sensitive_params(self):
13161316
)
13171317
else:
13181318
# If credentials are removed completely, the query string should still be redacted
1319-
self.assertIn("http://mock/status/200?sig=REDACTED", actual_url,
1320-
f"Basic URL structure is incorrect: {actual_url}")
1319+
self.assertIn(
1320+
"http://mock/status/200?sig=REDACTED",
1321+
actual_url,
1322+
f"Basic URL structure is incorrect: {actual_url}",
1323+
)
13211324

13221325

13231326
class TestAsyncIntegration(BaseTestCases.BaseManualTest):
@@ -1393,12 +1396,15 @@ def test_remove_sensitive_params(self):
13931396

13941397
if "@" in actual_url:
13951398
self.assertEqual(
1396-
span.attributes[SpanAttributes.HTTP_URL],
1397-
"http://REDACTED:REDACTED@mock/status/200?Signature=REDACTED",
1399+
span.attributes[SpanAttributes.HTTP_URL],
1400+
"http://REDACTED:REDACTED@mock/status/200?Signature=REDACTED",
13981401
)
13991402
else:
1400-
self.assertIn("http://mock/status/200?Signature=REDACTED", actual_url,
1401-
f"If credentials are removed, the query string still should be redacted {actual_url}")
1403+
self.assertIn(
1404+
"http://mock/status/200?Signature=REDACTED",
1405+
actual_url,
1406+
f"If credentials are removed, the query string still should be redacted {actual_url}",
1407+
)
14021408

14031409

14041410
class TestSyncInstrumentationIntegration(BaseTestCases.BaseInstrumentorTest):

util/opentelemetry-util-http/tests/test_redact_query_parameters.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@ def test_password_key_not_in_redact_list(self):
7070
)
7171

7272
def test_url_with_at_symbol_in_path_and_query(self):
73-
url = "https://github.com/p@th?foo=b@r"
73+
url = "https://example.com/p@th?foo=b@r"
7474
self.assertEqual(
75-
redact_query_parameters(url), "https://github.com/p@th?foo=b@r"
75+
redact_query_parameters(url), "https://example.com/p@th?foo=b@r"
7676
)
7777

7878
def test_aws_access_key_with_real_format(self):
79-
url = "https://microsoft.com?AWSAccessKeyId=AKIAIOSFODNN7"
79+
url = "https://mock.com?AWSAccessKeyId=AKIAIOSFODNN7"
8080
self.assertEqual(
8181
redact_query_parameters(url),
82-
"https://microsoft.com?AWSAccessKeyId=REDACTED",
82+
"https://mock.com?AWSAccessKeyId=REDACTED",
8383
)
8484

8585
def test_signature_parameter(self):

util/opentelemetry-util-http/tests/test_remove_credentials.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@
1919

2020
class TestRemoveUrlCredentials(unittest.TestCase):
2121
def test_remove_no_credentials(self):
22-
url = "http://opentelemetry.io:8080/test/path?query=value"
22+
url = "http://mock/status/200/test/path?query=value"
2323
cleaned_url = remove_url_credentials(url)
2424
self.assertEqual(cleaned_url, url)
2525

2626
def test_remove_credentials(self):
27-
url = "http://someuser:somepass@opentelemetry.io:8080/test/path?sig=value"
27+
url = "http://someuser:somepass@mock/status/200/test/path?sig=value"
2828
cleaned_url = remove_url_credentials(url)
2929
self.assertEqual(
3030
cleaned_url,
31-
"http://REDACTED:REDACTED@opentelemetry.io:8080/test/path?sig=value",
31+
"http://REDACTED:REDACTED@mock/status/200/test/path?sig=value",
3232
)
3333

3434
def test_remove_credentials_ipv4_literal(self):

0 commit comments

Comments
 (0)