@@ -111,6 +111,42 @@ def test_instrument_connection(self, mock_connect):
111111 spans_list = self .memory_exporter .get_finished_spans ()
112112 self .assertEqual (len (spans_list ), 1 )
113113
114+ @mock .patch ("opentelemetry.instrumentation.dbapi.instrument_connection" )
115+ @mock .patch ("pymysql.connect" )
116+ # pylint: disable=unused-argument
117+ def test_instrument_connection_enable_commenter (
118+ self ,
119+ mock_connect ,
120+ mock_instrument_connection ,
121+ ):
122+ cnx = pymysql .connect (database = "test" )
123+ cnx = PyMySQLInstrumentor ().instrument_connection (
124+ cnx ,
125+ enable_commenter = True ,
126+ commenter_options = {"foo" : True },
127+ )
128+ cursor = cnx .cursor ()
129+ cursor .execute ("SELECT * FROM test" )
130+ kwargs = mock_instrument_connection .call_args [1 ]
131+ self .assertEqual (kwargs ["enable_commenter" ], True )
132+ self .assertEqual (kwargs ["commenter_options" ], {"foo" : True })
133+
134+ @mock .patch ("opentelemetry.instrumentation.dbapi.wrap_connect" )
135+ @mock .patch ("pymysql.connect" )
136+ # pylint: disable=unused-argument
137+ def test__instrument_enable_commenter (
138+ self ,
139+ mock_connect ,
140+ mock_wrap_connect ,
141+ ):
142+ PyMySQLInstrumentor ()._instrument (
143+ enable_commenter = True ,
144+ commenter_options = {"foo" : True },
145+ )
146+ kwargs = mock_wrap_connect .call_args [1 ]
147+ self .assertEqual (kwargs ["enable_commenter" ], True )
148+ self .assertEqual (kwargs ["commenter_options" ], {"foo" : True })
149+
114150 @mock .patch ("pymysql.connect" )
115151 # pylint: disable=unused-argument
116152 def test_uninstrument_connection (self , mock_connect ):
0 commit comments