File tree 2 files changed +16
-4
lines changed
lumigo_opentelemetry/instrumentations/fastapi/parsers
test/integration/fastapi/tests
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
42
42
return_value = await original_otel_receive ()
43
43
with lumigo_safe_execute ("FastAPIParser: new_otel_receive" ):
44
44
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
+ )
49
55
return return_value
50
56
51
57
return new_otel_receive
Original file line number Diff line number Diff line change @@ -120,6 +120,12 @@ def test_requests_instrumentation(self):
120
120
internals , "http.request.body"
121
121
)
122
122
)
123
+ self .assertEqual (
124
+ spans_container .get_attribute_from_list_of_spans (
125
+ internals , "http.request.body"
126
+ ),
127
+ '{"a": "b"}' ,
128
+ )
123
129
self .assertIsNotNone (
124
130
spans_container .get_attribute_from_list_of_spans (
125
131
internals , "http.response.headers"
You can’t perform that action at this time.
0 commit comments