File tree Expand file tree Collapse file tree
instrumentation/opentelemetry-instrumentation-dbapi
src/opentelemetry/instrumentation/dbapi Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -909,6 +909,9 @@ async def traced_execution_async(
909909 * args : tuple [Any , ...],
910910 ** kwargs : dict [Any , Any ],
911911 ):
912+ if not is_instrumentation_enabled ():
913+ return await query_method (* args , ** kwargs )
914+
912915 operation_name = self .get_operation_name (cursor , args )
913916 name = operation_name
914917 if not name :
Original file line number Diff line number Diff line change @@ -525,6 +525,33 @@ def test_suppress_instrumentation(self):
525525 spans_list = self .memory_exporter .get_finished_spans ()
526526 self .assertEqual (len (spans_list ), 0 )
527527
528+ def test_suppress_instrumentation_async (self ):
529+ db_integration = dbapi .DatabaseApiIntegration (
530+ "instrumenting_module_test_name" ,
531+ "testcomponent" ,
532+ )
533+ cursor_tracer = dbapi .CursorTracer (db_integration )
534+ mock_cursor = MockCursor ()
535+ called = False
536+
537+ async def async_execute (_query , * _args ):
538+ nonlocal called
539+ called = True
540+
541+ with suppress_instrumentation ():
542+ asyncio .run (
543+ cursor_tracer .traced_execution_async (
544+ mock_cursor ,
545+ async_execute ,
546+ "Test query" ,
547+ ("param1Value" , False ),
548+ )
549+ )
550+
551+ spans_list = self .memory_exporter .get_finished_spans ()
552+ self .assertEqual (len (spans_list ), 0 )
553+ self .assertTrue (called )
554+
528555 def _get_metric (self , name ):
529556 return next (
530557 (
You can’t perform that action at this time.
0 commit comments