1616
1717from newrelic .api .database_trace import register_database_client
1818from newrelic .api .function_trace import FunctionTrace
19- from newrelic .common .object_wrapper import ObjectProxy , wrap_object , wrap_function_wrapper
2019from newrelic .common .object_names import callable_name
21-
22- from newrelic .hooks .database_dbapi2_async import AsyncConnectionFactory as DBAPI2AsyncConnectionFactory
23- from newrelic .hooks .database_dbapi2_async import AsyncConnectionWrapper as DBAPI2AsyncConnectionWrapper
24- from newrelic .hooks .database_dbapi2_async import AsyncCursorWrapper as DBAPI2AsyncCursorWrapper
20+ from newrelic .common .object_wrapper import (
21+ ObjectProxy ,
22+ wrap_function_wrapper ,
23+ wrap_object ,
24+ )
25+ from newrelic .hooks .database_dbapi2_async import (
26+ AsyncConnectionFactory as DBAPI2AsyncConnectionFactory ,
27+ )
28+ from newrelic .hooks .database_dbapi2_async import (
29+ AsyncConnectionWrapper as DBAPI2AsyncConnectionWrapper ,
30+ )
31+ from newrelic .hooks .database_dbapi2_async import (
32+ AsyncCursorWrapper as DBAPI2AsyncCursorWrapper ,
33+ )
2534
2635
2736class AsyncCursorContextManagerWrapper (ObjectProxy ):
@@ -36,9 +45,7 @@ def __init__(self, context_manager, dbapi2_module, connect_params, cursor_args):
3645
3746 async def __aenter__ (self ):
3847 cursor = await self .__wrapped__ .__aenter__ ()
39- return self .__cursor_wrapper__ (
40- cursor , self ._nr_dbapi2_module , self ._nr_connect_params , self ._nr_cursor_args
41- )
48+ return self .__cursor_wrapper__ (cursor , self ._nr_dbapi2_module , self ._nr_connect_params , self ._nr_cursor_args )
4249
4350 async def __aexit__ (self , exc , val , tb ):
4451 return await self .__wrapped__ .__aexit__ (exc , val , tb )
@@ -67,8 +74,7 @@ async def _wrap_pool__acquire(wrapped, instance, args, kwargs):
6774
6875
6976def instance_info (args , kwargs ):
70- def _bind_params (host = None , user = None , password = None , db = None ,
71- port = None , * args , ** kwargs ):
77+ def _bind_params (host = None , user = None , password = None , db = None , port = None , * args , ** kwargs ):
7278 return host , port , db
7379
7480 host , port , db = _bind_params (* args , ** kwargs )
@@ -77,15 +83,20 @@ def _bind_params(host=None, user=None, password=None, db=None,
7783
7884
7985def instrument_aiomysql (module ):
80- register_database_client (module , database_product = 'MySQL' ,
81- quoting_style = 'single+double' , explain_query = 'explain' ,
82- explain_stmts = ('select' ,), instance_info = instance_info )
86+ register_database_client (
87+ module ,
88+ database_product = "MySQL" ,
89+ quoting_style = "single+double" ,
90+ explain_query = "explain" ,
91+ explain_stmts = ("select" ,),
92+ instance_info = instance_info ,
93+ )
8394
8495 # Only instrument the connect method directly, don't instrument
8596 # Connection. This follows the DBAPI2 spec and what was done for
8697 # PyMySQL which this library is based on.
8798
88- wrap_object (module , ' connect' , AsyncConnectionFactory , (module ,))
99+ wrap_object (module , " connect" , AsyncConnectionFactory , (module ,))
89100
90101
91102def instrument_aiomysql_pool (module ):
0 commit comments