From 5f4c72fc7fc7db3bbd83508a70e619221a3f0c34 Mon Sep 17 00:00:00 2001 From: Eugene Orlovsky Date: Sun, 17 Nov 2024 20:23:26 +0100 Subject: [PATCH 1/3] fastapi request.body fix --- .../instrumentations/fastapi/parsers/__init__.py | 2 +- src/test/integration/fastapi/tests/test_fastapi.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) 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" From f91385f1c97414c3fe1a6f9c6bf59894562273f1 Mon Sep 17 00:00:00 2001 From: Eugene Orlovsky Date: Mon, 18 Nov 2024 09:33:44 +0100 Subject: [PATCH 2/3] try to fix test circle CI --- .pre-commit-config.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e125150d..1bf10615 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ repos: rev: 20.8b1 hooks: - id: black - language_version: python3.7 + language_version: python3.8 exclude: '(src/lumigo_opentelemetry/external/.*|src/test/integration/grpcio/app/helloworld_pb2.*)' additional_dependencies: ['click==8.0.4'] @@ -12,6 +12,7 @@ repos: hooks: - id: mypy entry: mypy + language_version: python3.8 additional_dependencies: - types-attrs==19.1.0 - types-boto==2.49.17 From 757664154e8295e7e64576d34582df626a115c6f Mon Sep 17 00:00:00 2001 From: Eugene Orlovsky Date: Mon, 18 Nov 2024 09:45:25 +0100 Subject: [PATCH 3/3] revert, --- .pre-commit-config.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1bf10615..e125150d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ repos: rev: 20.8b1 hooks: - id: black - language_version: python3.8 + language_version: python3.7 exclude: '(src/lumigo_opentelemetry/external/.*|src/test/integration/grpcio/app/helloworld_pb2.*)' additional_dependencies: ['click==8.0.4'] @@ -12,7 +12,6 @@ repos: hooks: - id: mypy entry: mypy - language_version: python3.8 additional_dependencies: - types-attrs==19.1.0 - types-boto==2.49.17