@@ -96,6 +96,42 @@ def test_instrument_connection(self, mock_connect):
9696 spans_list = self .memory_exporter .get_finished_spans ()
9797 self .assertEqual (len (spans_list ), 1 )
9898
99+ @mock .patch ("opentelemetry.instrumentation.dbapi.instrument_connection" )
100+ @mock .patch ("MySQLdb.connect" )
101+ # pylint: disable=unused-argument
102+ def test_instrument_connection_enable_commenter (
103+ self ,
104+ mock_connect ,
105+ mock_instrument_connection ,
106+ ):
107+ cnx = MySQLdb .connect (database = "test" )
108+ cnx = MySQLClientInstrumentor ().instrument_connection (
109+ cnx ,
110+ enable_commenter = True ,
111+ commenter_options = {"foo" : True },
112+ )
113+ cursor = cnx .cursor ()
114+ cursor .execute ("SELECT * FROM test" )
115+ kwargs = mock_instrument_connection .call_args [1 ]
116+ self .assertEqual (kwargs ["enable_commenter" ], True )
117+ self .assertEqual (kwargs ["commenter_options" ], {"foo" : True })
118+
119+ @mock .patch ("opentelemetry.instrumentation.dbapi.wrap_connect" )
120+ @mock .patch ("MySQLdb.connect" )
121+ # pylint: disable=unused-argument
122+ def test__instrument_enable_commenter (
123+ self ,
124+ mock_connect ,
125+ mock_wrap_connect ,
126+ ):
127+ MySQLClientInstrumentor ()._instrument (
128+ enable_commenter = True ,
129+ commenter_options = {"foo" : True },
130+ )
131+ kwargs = mock_wrap_connect .call_args [1 ]
132+ self .assertEqual (kwargs ["enable_commenter" ], True )
133+ self .assertEqual (kwargs ["commenter_options" ], {"foo" : True })
134+
99135 @mock .patch ("MySQLdb.connect" )
100136 # pylint: disable=unused-argument
101137 def test_uninstrument_connection (self , mock_connect ):
0 commit comments