mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-08-02 19:47:17 +08:00
Add psycopg2 native tags to sqlcommenter (#1203)
This commit is contained in:
@ -229,8 +229,20 @@ class TestDBApiIntegration(TestBase):
|
||||
)
|
||||
|
||||
def test_executemany_comment(self):
|
||||
|
||||
connect_module = mock.MagicMock()
|
||||
connect_module.__version__ = mock.MagicMock()
|
||||
connect_module.__libpq_version__ = 123
|
||||
connect_module.apilevel = 123
|
||||
connect_module.threadsafety = 123
|
||||
connect_module.paramstyle = "test"
|
||||
|
||||
db_integration = dbapi.DatabaseApiIntegration(
|
||||
"testname", "testcomponent", enable_commenter=True
|
||||
"testname",
|
||||
"testcomponent",
|
||||
enable_commenter=True,
|
||||
commenter_options={"db_driver": False, "dbapi_level": False},
|
||||
connect_module=connect_module,
|
||||
)
|
||||
mock_connection = db_integration.wrapped_connection(
|
||||
mock_connect, {}, {}
|
||||
@ -239,7 +251,7 @@ class TestDBApiIntegration(TestBase):
|
||||
cursor.executemany("Select 1;")
|
||||
self.assertRegex(
|
||||
cursor.query,
|
||||
r"Select 1 /\*traceparent='\d{1,2}-[a-zA-Z0-9_]{32}-[a-zA-Z0-9_]{16}-\d{1,2}'\*/;",
|
||||
r"Select 1 /\*dbapi_threadsafety=123,driver_paramstyle='test',libpq_version=123,traceparent='\d{1,2}-[a-zA-Z0-9_]{32}-[a-zA-Z0-9_]{16}-\d{1,2}'\*/;",
|
||||
)
|
||||
|
||||
def test_callproc(self):
|
||||
|
Reference in New Issue
Block a user