From c427ad5bf6f29f22df662b8f13f1039bd472e95c Mon Sep 17 00:00:00 2001 From: "Wali, Sunil Shidrayi" Date: Tue, 18 Jun 2024 13:38:28 +0530 Subject: [PATCH] test_sqlite3.py Added test case for test_no_op_tracer_provider --- .../tests/test_sqlite3.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/instrumentation/opentelemetry-instrumentation-sqlite3/tests/test_sqlite3.py b/instrumentation/opentelemetry-instrumentation-sqlite3/tests/test_sqlite3.py index 581920232b..7300a06984 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlite3/tests/test_sqlite3.py +++ b/instrumentation/opentelemetry-instrumentation-sqlite3/tests/test_sqlite3.py @@ -100,3 +100,15 @@ def test_callproc(self): ): self._cursor.callproc("test", ()) self.validate_spans("test") + + def test_no_op_tracer_provider(self): + """Should not create any spans when using NoOpTracerProvider""" + SQLite3Instrumentor().uninstrument() + SQLite3Instrumentor().instrument(tracer_provider=trace_api.NoOpTracerProvider()) + self._create_tables() + stmt = "INSERT INTO test (id) VALUES (?)" + data = [("1",), ("2",), ("3",)] + with self._tracer.start_as_current_span("rootSpan"): + self._cursor.executemany(stmt, data) + spans = self.memory_exporter.get_finished_spans() + self.assertEqual(len(spans), 0)