From 4fe9ddab03eb5b5b93f02186d1c5ff4370d3e3f9 Mon Sep 17 00:00:00 2001 From: "Qiu, David" Date: Tue, 28 May 2024 13:13:14 +0800 Subject: [PATCH] Audit and test opentelemetry-instrumentation-fastapi NoOpTracerProvider Signed-off-by: Qiu, David --- .../tests/test_fastapi_instrumentation.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py b/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py index 03fdd6749d..91ed514096 100644 --- a/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py +++ b/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py @@ -1069,6 +1069,18 @@ def test_uninstrument_after_instrument(self): spans = self.memory_exporter.get_finished_spans() self.assertEqual(len(spans), 3) + def test_no_op_tracer_provider(self): + self._instrumentor.uninstrument() + self._instrumentor.instrument( + tracer_provider=trace.NoOpTracerProvider() + ) + + app = self._create_fastapi_app() + client = TestClient(app) + client.get("/foobar") + spans = self.memory_exporter.get_finished_spans() + self.assertEqual(len(spans), 0) + def tearDown(self): self._instrumentor.uninstrument() super().tearDown()