File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
lumigo_opentelemetry/instrumentations/fastapi/parsers
test/integration/fastapi/tests Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -42,10 +42,16 @@ async def new_otel_receive(): # type: ignore
4242 return_value = await original_otel_receive ()
4343 with lumigo_safe_execute ("FastAPIParser: new_otel_receive" ):
4444 with instance .tracer .start_as_current_span ("receive_body" ) as send_span :
45- send_span .set_attribute (
46- "http.request.body" ,
47- dump_with_context ("requestBody" , return_value ),
48- )
45+ if isinstance (return_value , dict ) and "body" in return_value :
46+ send_span .set_attribute (
47+ "http.request.body" ,
48+ dump_with_context ("requestBody" , return_value .get ("body" )),
49+ )
50+ else :
51+ send_span .set_attribute (
52+ "http.request.body" ,
53+ dump_with_context ("requestBody" , return_value ),
54+ )
4955 return return_value
5056
5157 return new_otel_receive
Original file line number Diff line number Diff line change @@ -120,6 +120,12 @@ def test_requests_instrumentation(self):
120120 internals , "http.request.body"
121121 )
122122 )
123+ self .assertEqual (
124+ spans_container .get_attribute_from_list_of_spans (
125+ internals , "http.request.body"
126+ ),
127+ '{"a": "b"}' ,
128+ )
123129 self .assertIsNotNone (
124130 spans_container .get_attribute_from_list_of_spans (
125131 internals , "http.response.headers"
You can’t perform that action at this time.
0 commit comments