Skip to content

Commit 10a24a7

Browse files
committed
Fix ruff and spellcheck errors
1 parent b7f6287 commit 10a24a7

File tree

2 files changed

+60
-11
lines changed

2 files changed

+60
-11
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,9 @@ def get_host_port_url_tuple(scope):
451451
host_value = host_header[0]
452452
# Ensure host_value is a string, not bytes
453453
if isinstance(host_value, bytes):
454-
host_value = _decode_header_item(host_value) # use exisiting function
454+
host_value = _decode_header_item(
455+
host_value
456+
) # use existing function
455457

456458
url_host = host_value
457459

instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,10 @@ def test_host_header_url_construction(self):
18961896
# Find the server span (the main span, not internal middleware spans)
18971897
server_span = None
18981898
for span in spans:
1899-
if span.kind == trace.SpanKind.SERVER and HTTP_URL in span.attributes:
1899+
if (
1900+
span.kind == trace.SpanKind.SERVER
1901+
and HTTP_URL in span.attributes
1902+
):
19001903
server_span = span
19011904
break
19021905

@@ -1923,7 +1926,13 @@ def test_host_header_with_port_url_construction(self):
19231926

19241927
spans = self.memory_exporter.get_finished_spans()
19251928
server_span = next(
1926-
(span for span in spans if span.kind == trace.SpanKind.SERVER and HTTP_URL in span.attributes), None
1929+
(
1930+
span
1931+
for span in spans
1932+
if span.kind == trace.SpanKind.SERVER
1933+
and HTTP_URL in span.attributes
1934+
),
1935+
None,
19271936
)
19281937
self.assertIsNotNone(server_span)
19291938

@@ -1940,7 +1949,13 @@ def test_no_host_header_fallback_behavior(self):
19401949

19411950
spans = self.memory_exporter.get_finished_spans()
19421951
server_span = next(
1943-
(span for span in spans if span.kind == trace.SpanKind.SERVER and HTTP_URL in span.attributes), None
1952+
(
1953+
span
1954+
for span in spans
1955+
if span.kind == trace.SpanKind.SERVER
1956+
and HTTP_URL in span.attributes
1957+
),
1958+
None,
19441959
)
19451960
self.assertIsNotNone(server_span)
19461961

@@ -1965,7 +1980,13 @@ def test_production_scenario_host_header(self):
19651980

19661981
spans = self.memory_exporter.get_finished_spans()
19671982
server_span = next(
1968-
(span for span in spans if span.kind == trace.SpanKind.SERVER and HTTP_URL in span.attributes), None
1983+
(
1984+
span
1985+
for span in spans
1986+
if span.kind == trace.SpanKind.SERVER
1987+
and HTTP_URL in span.attributes
1988+
),
1989+
None,
19691990
)
19701991
self.assertIsNotNone(server_span)
19711992

@@ -2012,7 +2033,12 @@ def test_host_header_with_special_characters(self):
20122033

20132034
spans = self.memory_exporter.get_finished_spans()
20142035
server_span = next(
2015-
(span for span in spans if span.kind == trace.SpanKind.SERVER and HTTP_URL in span.attributes),
2036+
(
2037+
span
2038+
for span in spans
2039+
if span.kind == trace.SpanKind.SERVER
2040+
and HTTP_URL in span.attributes
2041+
),
20162042
None,
20172043
)
20182044
self.assertIsNotNone(server_span)
@@ -2032,7 +2058,13 @@ def test_host_header_maintains_span_attributes(self):
20322058

20332059
spans = self.memory_exporter.get_finished_spans()
20342060
server_span = next(
2035-
(span for span in spans if span.kind == trace.SpanKind.SERVER and HTTP_URL in span.attributes), None
2061+
(
2062+
span
2063+
for span in spans
2064+
if span.kind == trace.SpanKind.SERVER
2065+
and HTTP_URL in span.attributes
2066+
),
2067+
None,
20362068
)
20372069
self.assertIsNotNone(server_span)
20382070

@@ -2076,7 +2108,13 @@ def test_host_header_url_new_semconv(self):
20762108
spans = self.memory_exporter.get_finished_spans()
20772109
# With new semantic conventions, look for the main HTTP span with route information
20782110
server_span = next(
2079-
(span for span in spans if span.kind == trace.SpanKind.SERVER and "http.route" in span.attributes), None
2111+
(
2112+
span
2113+
for span in spans
2114+
if span.kind == trace.SpanKind.SERVER
2115+
and "http.route" in span.attributes
2116+
),
2117+
None,
20802118
)
20812119
self.assertIsNotNone(server_span)
20822120

@@ -2090,7 +2128,9 @@ def test_host_header_url_new_semconv(self):
20902128
# Current behavior: Host header may not affect server.address in new semantic conventions
20912129
# This test documents the current behavior rather than enforcing Host header usage
20922130
server_address = server_span.attributes.get("server.address", "")
2093-
self.assertIsNotNone(server_address, "testserver") # Should have some value
2131+
self.assertIsNotNone(
2132+
server_address, "testserver"
2133+
) # Should have some value
20942134

20952135

20962136
class TestFastAPIHostHeaderURLBothSemconv(TestFastAPIHostHeaderURL):
@@ -2105,7 +2145,13 @@ def test_host_header_url_both_semconv(self):
21052145

21062146
spans = self.memory_exporter.get_finished_spans()
21072147
server_span = next(
2108-
(span for span in spans if span.kind == trace.SpanKind.SERVER and HTTP_URL in span.attributes), None
2148+
(
2149+
span
2150+
for span in spans
2151+
if span.kind == trace.SpanKind.SERVER
2152+
and HTTP_URL in span.attributes
2153+
),
2154+
None,
21092155
)
21102156
self.assertIsNotNone(server_span)
21112157

@@ -2143,7 +2189,8 @@ def test_fastapi_unhandled_exception_both_semconv(self):
21432189
server_spans = [
21442190
span
21452191
for span in spans
2146-
if span.kind == trace.SpanKind.SERVER and hasattr(span, "attributes")
2192+
if span.kind == trace.SpanKind.SERVER
2193+
and hasattr(span, "attributes")
21472194
and span.attributes
21482195
and HTTP_URL in span.attributes
21492196
]

0 commit comments

Comments
 (0)