File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
aws_xray_sdk/ext/pynamodb Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change 1
- import botocore .vendored .requests .sessions
2
1
import json
3
2
import wrapt
4
3
import pynamodb
9
8
10
9
PYNAMODB4 = int (pynamodb .__version__ .split ('.' )[0 ]) >= 4
11
10
11
+ if PYNAMODB4 :
12
+ import botocore .httpsession
13
+ else :
14
+ import botocore .vendored .requests .sessions
15
+
12
16
13
17
def patch ():
14
18
"""Patch PynamoDB so it generates subsegements when calling DynamoDB."""
15
19
16
- if hasattr (botocore .vendored .requests .sessions , '_xray_enabled' ):
17
- return
18
- setattr (botocore .vendored .requests .sessions , '_xray_enabled' , True )
19
-
20
20
if PYNAMODB4 :
21
+ if hasattr (botocore .httpsession , '_xray_enabled' ):
22
+ return
23
+ setattr (botocore .httpsession , '_xray_enabled' , True )
24
+
21
25
module = 'botocore.httpsession'
22
26
name = 'URLLib3Session.send'
23
27
else :
28
+ if hasattr (botocore .vendored .requests .sessions , '_xray_enabled' ):
29
+ return
30
+ setattr (botocore .vendored .requests .sessions , '_xray_enabled' , True )
31
+
24
32
module = 'botocore.vendored.requests.sessions'
25
33
name = 'Session.send'
34
+
26
35
wrapt .wrap_function_wrapper (
27
36
module , name , _xray_traced_pynamodb ,
28
37
)
You can’t perform that action at this time.
0 commit comments