From e608df935710c351261e1c233f539fea148be71e Mon Sep 17 00:00:00 2001 From: Akochavi <121871419+Akochavi@users.noreply.github.com> Date: Mon, 13 Feb 2023 09:26:57 +0200 Subject: [PATCH] Audit and test opentelemetry-instrumentation-dbapi NoOpTracerProvider (#1607) --- .../tests/test_dbapi_integration.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/instrumentation/opentelemetry-instrumentation-dbapi/tests/test_dbapi_integration.py b/instrumentation/opentelemetry-instrumentation-dbapi/tests/test_dbapi_integration.py index 25ee279fe..a7fb608c2 100644 --- a/instrumentation/opentelemetry-instrumentation-dbapi/tests/test_dbapi_integration.py +++ b/instrumentation/opentelemetry-instrumentation-dbapi/tests/test_dbapi_integration.py @@ -219,6 +219,21 @@ class TestDBApiIntegration(TestBase): self.assertEqual(span.resource.attributes["db-resource-key"], "value") self.assertIs(span.status.status_code, trace_api.StatusCode.ERROR) + def test_no_op_tracer_provider(self): + db_integration = dbapi.DatabaseApiIntegration( + self.tracer, + "testcomponent", + tracer_provider=trace_api.NoOpTracerProvider(), + ) + + mock_connection = db_integration.wrapped_connection( + mock_connect, {}, {} + ) + cursor = mock_connection.cursor() + cursor.executemany("Test query") + spans_list = self.memory_exporter.get_finished_spans() + self.assertEqual(len(spans_list), 0) + def test_executemany(self): db_integration = dbapi.DatabaseApiIntegration( "testname", "testcomponent"