From 5fce5c5f006ece5a606a0f0f5eb303aa4a624d46 Mon Sep 17 00:00:00 2001 From: BHAWESHBHASKAR Date: Sun, 25 Oct 2026 10:49:47 +0530 Subject: [PATCH] test(tornado): add a NoOpTracerProvider test Instrument with trace.NoOpTracerProvider() and check that a request still succeeds and that no spans are exported, as the flask, requests and urllib3 instrumentation tests already do. The existing test_not_recording uses a mock tracer, so it would not catch the instrumentation relying on SDK-only span attributes. Part of https://github.com/open-telemetry/opentelemetry-python-contrib/issues/958 Fixes https://github.com/open-telemetry/opentelemetry-python-contrib/issues/962 --- .../tests/test_instrumentation.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/instrumentation/opentelemetry-instrumentation-tornado/tests/test_instrumentation.py b/instrumentation/opentelemetry-instrumentation-tornado/tests/test_instrumentation.py index e63f8a2f8b..7a4d111131 100644 --- a/instrumentation/opentelemetry-instrumentation-tornado/tests/test_instrumentation.py +++ b/instrumentation/opentelemetry-instrumentation-tornado/tests/test_instrumentation.py @@ -240,6 +240,17 @@ def test_not_recording(self): self.assertFalse(mock_span.set_attribute.called) self.assertFalse(mock_span.set_status.called) + def test_no_op_tracer_provider(self): + TornadoInstrumentor().uninstrument() + TornadoInstrumentor().instrument(tracer_provider=trace.NoOpTracerProvider()) + + response = self.fetch("/parametrized/hello/") + self.assertEqual(response.code, 200) + self.assertEqual(response.body, b"hello") + + spans = self.memory_exporter.get_finished_spans() + self.assertEqual(len(spans), 0) + def test_async_handler(self): self._test_async_handler("/async", "AsyncHandler")