Skip to content

Commit e608df9

Browse files
authored
Audit and test opentelemetry-instrumentation-dbapi NoOpTracerProvider (#1607)
1 parent bb41b46 commit e608df9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

instrumentation/opentelemetry-instrumentation-dbapi/tests/test_dbapi_integration.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,21 @@ def test_custom_tracer_provider_dbapi(self):
219219
self.assertEqual(span.resource.attributes["db-resource-key"], "value")
220220
self.assertIs(span.status.status_code, trace_api.StatusCode.ERROR)
221221

222+
def test_no_op_tracer_provider(self):
223+
db_integration = dbapi.DatabaseApiIntegration(
224+
self.tracer,
225+
"testcomponent",
226+
tracer_provider=trace_api.NoOpTracerProvider(),
227+
)
228+
229+
mock_connection = db_integration.wrapped_connection(
230+
mock_connect, {}, {}
231+
)
232+
cursor = mock_connection.cursor()
233+
cursor.executemany("Test query")
234+
spans_list = self.memory_exporter.get_finished_spans()
235+
self.assertEqual(len(spans_list), 0)
236+
222237
def test_executemany(self):
223238
db_integration = dbapi.DatabaseApiIntegration(
224239
"testname", "testcomponent"

0 commit comments

Comments
 (0)