7
7
8
8
9
9
def patch ():
10
-
11
10
wrapt .wrap_function_wrapper (
12
11
'psycopg2' ,
13
12
'connect' ,
@@ -23,6 +22,10 @@ def patch():
23
22
'quote_ident' ,
24
23
_xray_register_type_fix
25
24
)
25
+
26
+ # We should in general not patch internal methods (pyscopg2._json.register_type in this case).
27
+ # But there isn't a better workaround than this for the time being.
28
+ # Please see the GH issue for details: https://github.com/aws/aws-xray-sdk-python/issues/243
26
29
wrapt .wrap_function_wrapper (
27
30
'psycopg2._json' ,
28
31
'register_type' ,
@@ -31,9 +34,8 @@ def patch():
31
34
32
35
33
36
def _xray_traced_connect (wrapped , instance , args , kwargs ):
34
-
35
37
conn = wrapped (* args , ** kwargs )
36
- parameterized_dsn = { c [0 ]: c [- 1 ] for c in map (methodcaller ('split' , '=' ), conn .dsn .split (' ' ))}
38
+ parameterized_dsn = {c [0 ]: c [- 1 ] for c in map (methodcaller ('split' , '=' ), conn .dsn .split (' ' ))}
37
39
meta = {
38
40
'database_type' : 'PostgreSQL' ,
39
41
'url' : 'postgresql://{}@{}:{}/{}' .format (
@@ -49,6 +51,7 @@ def _xray_traced_connect(wrapped, instance, args, kwargs):
49
51
50
52
return XRayTracedConn (conn , meta )
51
53
54
+
52
55
def _xray_register_type_fix (wrapped , instance , args , kwargs ):
53
56
"""Send the actual connection or curser to register type."""
54
57
our_args = list (copy .copy (args ))
0 commit comments