PKGBUILDs/community/python-aws-xray-sdk/python-aws-xray-sdk-botocore-1.13.patch
2019-11-14 14:43:05 +00:00

81 lines
2.7 KiB
Diff

From a9fb17f9f9d9edd44a2eafc2add36607b2aff98a Mon Sep 17 00:00:00 2001
From: Daniel Roschka <daniel.roschka@connected-health.eu>
Date: Mon, 11 Nov 2019 10:30:52 +0100
Subject: [PATCH 1/2] Fix patching for PynamoDB 4.x with botocore 1.13
---
aws_xray_sdk/ext/pynamodb/patch.py | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/aws_xray_sdk/ext/pynamodb/patch.py b/aws_xray_sdk/ext/pynamodb/patch.py
index 74b7825..2be2d41 100644
--- a/aws_xray_sdk/ext/pynamodb/patch.py
+++ b/aws_xray_sdk/ext/pynamodb/patch.py
@@ -1,4 +1,3 @@
-import botocore.vendored.requests.sessions
import json
import wrapt
import pynamodb
@@ -13,16 +12,18 @@
def patch():
"""Patch PynamoDB so it generates subsegements when calling DynamoDB."""
- if hasattr(botocore.vendored.requests.sessions, '_xray_enabled'):
- return
- setattr(botocore.vendored.requests.sessions, '_xray_enabled', True)
-
if PYNAMODB4:
module = 'botocore.httpsession'
name = 'URLLib3Session.send'
else:
+ import botocore.vendored.requests.sessions
+ if hasattr(botocore.vendored.requests.sessions, '_xray_enabled'):
+ return
+ setattr(botocore.vendored.requests.sessions, '_xray_enabled', True)
+
module = 'botocore.vendored.requests.sessions'
name = 'Session.send'
+
wrapt.wrap_function_wrapper(
module, name, _xray_traced_pynamodb,
)
From f1f8cd4e6635d1beb7c703717971afed54813a6a Mon Sep 17 00:00:00 2001
From: Daniel Roschka <daniel.roschka@connected-health.eu>
Date: Mon, 11 Nov 2019 13:17:37 +0100
Subject: [PATCH 2/2] Make PynamoDB patching idempotent for PynamoDB 4
---
aws_xray_sdk/ext/pynamodb/patch.py | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/aws_xray_sdk/ext/pynamodb/patch.py b/aws_xray_sdk/ext/pynamodb/patch.py
index 2be2d41..1478808 100644
--- a/aws_xray_sdk/ext/pynamodb/patch.py
+++ b/aws_xray_sdk/ext/pynamodb/patch.py
@@ -8,15 +8,23 @@
PYNAMODB4 = int(pynamodb.__version__.split('.')[0]) >= 4
+if PYNAMODB4:
+ import botocore.httpsession
+else:
+ import botocore.vendored.requests.sessions
+
def patch():
"""Patch PynamoDB so it generates subsegements when calling DynamoDB."""
if PYNAMODB4:
+ if hasattr(botocore.httpsession, '_xray_enabled'):
+ return
+ setattr(botocore.httpsession, '_xray_enabled', True)
+
module = 'botocore.httpsession'
name = 'URLLib3Session.send'
else:
- import botocore.vendored.requests.sessions
if hasattr(botocore.vendored.requests.sessions, '_xray_enabled'):
return
setattr(botocore.vendored.requests.sessions, '_xray_enabled', True)