Skip to content

Commit 4aaadf8

Browse files
committed
Audit and test opentelemetry-instrumentation-fastapi NoOpTracerProvider
Signed-off-by: Qiu, David <[email protected]>
1 parent eb8e456 commit 4aaadf8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py

+12
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,18 @@ def test_uninstrument_after_instrument(self):
440440
spans = self.memory_exporter.get_finished_spans()
441441
self.assertEqual(len(spans), 3)
442442

443+
def test_no_op_tracer_provider(self):
444+
self._instrumentor.uninstrument()
445+
self._instrumentor.instrument(
446+
tracer_provider=trace.NoOpTracerProvider()
447+
)
448+
449+
app = self._create_fastapi_app()
450+
client = TestClient(app)
451+
client.get("/foobar")
452+
spans = self.memory_exporter.get_finished_spans()
453+
self.assertEqual(len(spans), 0)
454+
443455
def tearDown(self):
444456
self._instrumentor.uninstrument()
445457
super().tearDown()

0 commit comments

Comments
 (0)