Skip to content

Commit 0fcd925

Browse files
committed
add test case, pass commenter_options to trace_integration method
1 parent fc314c8 commit 0fcd925

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,27 @@ def test_commenter_options_propagation(self):
276276
span = spans_list[0]
277277
self.assertEqual(span.attributes.get("db.system"), "testcomponent")
278278
self.assertIn("opentelemetry_values", db_integration.commenter_options)
279-
self.assertFalse(db_integration.commenter_options["opentelemetry_values"])
279+
self.assertFalse(
280+
db_integration.commenter_options["opentelemetry_values"]
281+
)
282+
283+
@mock.patch("opentelemetry.instrumentation.dbapi.wrap_connect")
284+
def test_trace_integration_passes_commenter_options(
285+
self, mock_wrap_connect
286+
):
287+
fake_connect_module = mock.Mock()
288+
fake_options = {"opentelemetry_values": False, "foo": "bar"}
289+
dbapi.trace_integration(
290+
connect_module=fake_connect_module,
291+
connect_method_name="connect",
292+
database_system="testdb",
293+
commenter_options=fake_options,
294+
)
295+
mock_wrap_connect.assert_called_once()
296+
_, _, kwargs = mock_wrap_connect.mock_calls[0]
297+
298+
self.assertIn("commenter_options", kwargs)
299+
self.assertEqual(kwargs["commenter_options"], fake_options)
280300

281301
def test_executemany(self):
282302
db_integration = dbapi.DatabaseApiIntegration(

0 commit comments

Comments
 (0)