Skip to content

Commit 374130c

Browse files
committed
fixed test for spans
1 parent 5b2bffd commit 374130c

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

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

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -348,22 +348,20 @@ def test_custom_api_router(self):
348348
"""
349349
resp: Final = self._client.get("/custom-router/success")
350350
spans: Final = self.memory_exporter.get_finished_spans()
351-
expected_span_attributes: Final = {
352-
HTTP_TARGET: "/custom-router/success",
353-
HTTP_URL: "https://testserver/",
354-
}
351+
spans_with_http_attributes = [
352+
span
353+
for span in spans
354+
if (HTTP_URL in span.attributes or HTTP_TARGET in span.attributes)
355+
]
355356
self.assertEqual(200, resp.status_code)
356-
self.assertTrue(
357-
all(
358-
all(
359-
(
360-
span.attributes[attribute] == expected
361-
for attribute, expected in expected_span_attributes.items()
362-
)
363-
)
364-
for span in spans
357+
for span in spans_with_http_attributes:
358+
self.assertEqual(
359+
"/custom-router/success", span.attributes[HTTP_TARGET]
360+
)
361+
self.assertEqual(
362+
"https://testserver/custom-router/success",
363+
span.attributes[HTTP_URL],
365364
)
366-
)
367365

368366
def test_host_fastapi_call(self):
369367
client = TestClient(self._app, base_url="https://testserver2:443")

0 commit comments

Comments
 (0)