Skip to content

Commit c78e4a3

Browse files
committed
NoOpTracerProvider test case for sqlite instrumentation update
Signed-off-by: Wali, Sunil Shidrayi <[email protected]>
1 parent 8a37f52 commit c78e4a3

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

instrumentation/opentelemetry-instrumentation-sqlite3/tests/test_sqlite3.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,23 @@ def test_callproc(self):
101101
self._cursor.callproc("test", ())
102102
self.validate_spans("test")
103103

104-
def test_no_op_tracer_provider(self):
104+
def test_noop_tracer_provider(self):
105105
"""Should not create any spans when using NoOpTracerProvider"""
106106
SQLite3Instrumentor().uninstrument()
107-
SQLite3Instrumentor().instrument(tracer_provider=trace_api.NoOpTracerProvider())
107+
SQLite3Instrumentor().instrument(tracer_provider=trace_api.get_tracer_provider())
108+
self._tracer = trace_api.get_tracer(__name__)
108109
self._create_tables()
110+
111+
stmt = "CREATE TABLE IF NOT EXISTS test (id integer)"
112+
with self._tracer.start_as_current_span("rootSpan"):
113+
self._cursor.execute(stmt)
114+
109115
stmt = "INSERT INTO test (id) VALUES (?)"
110116
data = [("1",), ("2",), ("3",)]
111117
with self._tracer.start_as_current_span("rootSpan"):
112118
self._cursor.executemany(stmt, data)
113-
spans = self.memory_exporter.get_finished_spans()
114-
self.assertEqual(len(spans), 2)
119+
120+
with self._tracer.start_as_current_span("rootSpan"), self.assertRaises(Exception):
121+
self._cursor.callproc("test", ())
122+
123+

0 commit comments

Comments
 (0)