diff --git a/src/lumigo_opentelemetry/instrumentations/fastapi/parsers/__init__.py b/src/lumigo_opentelemetry/instrumentations/fastapi/parsers/__init__.py index c8a52b15..7f97dac7 100644 --- a/src/lumigo_opentelemetry/instrumentations/fastapi/parsers/__init__.py +++ b/src/lumigo_opentelemetry/instrumentations/fastapi/parsers/__init__.py @@ -44,7 +44,7 @@ async def new_otel_receive(): # type: ignore with instance.tracer.start_as_current_span("receive_body") as send_span: send_span.set_attribute( "http.request.body", - dump_with_context("requestBody", return_value), + dump_with_context("requestBody", return_value.get("body")), ) return return_value diff --git a/src/test/integration/fastapi/tests/test_fastapi.py b/src/test/integration/fastapi/tests/test_fastapi.py index f8656b64..a095e973 100644 --- a/src/test/integration/fastapi/tests/test_fastapi.py +++ b/src/test/integration/fastapi/tests/test_fastapi.py @@ -120,6 +120,12 @@ def test_requests_instrumentation(self): internals, "http.request.body" ) ) + self.assertEqual( + spans_container.get_attribute_from_list_of_spans( + internals, "http.request.body" + ), + '{"a": "b"}', + ) self.assertIsNotNone( spans_container.get_attribute_from_list_of_spans( internals, "http.response.headers"