Skip to content

Commit

Permalink
fastapi request.body fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugene Orlovsky committed Nov 17, 2024
1 parent 449bc4a commit 5f4c72f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions src/test/integration/fastapi/tests/test_fastapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 5f4c72f

Please sign in to comment.