Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-aws-xray-sdk for 
openSUSE:Factory checked in at 2021-04-08 21:32:38
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-aws-xray-sdk (Old)
 and      /work/SRC/openSUSE:Factory/.python-aws-xray-sdk.new.2401 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-aws-xray-sdk"

Thu Apr  8 21:32:38 2021 rev:7 rq:883827 version:2.7.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-aws-xray-sdk/python-aws-xray-sdk.changes  
2020-12-09 22:12:59.795162849 +0100
+++ 
/work/SRC/openSUSE:Factory/.python-aws-xray-sdk.new.2401/python-aws-xray-sdk.changes
        2021-04-08 21:32:54.335855865 +0200
@@ -1,0 +2,7 @@
+Thu Apr  8 09:35:29 UTC 2021 - Mark??ta Machov?? <[email protected]>
+
+- Update to 2.7.0
+  * many bugfixes and small improvements
+- Do not care about SLE-12, it does not build anyway
+
+-------------------------------------------------------------------

Old:
----
  aws-xray-sdk-2.6.0.tar.gz

New:
----
  aws-xray-sdk-2.7.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-aws-xray-sdk.spec ++++++
--- /var/tmp/diff_new_pack.lCr3ft/_old  2021-04-08 21:32:54.843856422 +0200
+++ /var/tmp/diff_new_pack.lCr3ft/_new  2021-04-08 21:32:54.843856422 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package python-aws-xray-sdk
 #
-# Copyright (c) 2020 SUSE LLC
+# Copyright (c) 2021 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,11 +17,9 @@
 
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
-%if 0%{?suse_version} >= 1500
 %define skip_python2 1
-%endif
 Name:           python-aws-xray-sdk
-Version:        2.6.0
+Version:        2.7.0
 Release:        0
 Summary:        The AWS X-Ray SDK for Python
 License:        Apache-2.0
@@ -34,13 +32,8 @@
 BuildRequires:  python-rpm-macros
 Requires:       python-botocore >= 1.11.3
 Requires:       python-future
-Requires:       python-jsonpickle
 Requires:       python-wrapt
-%ifpython2
-Requires:       python-enum34
-%endif
 BuildArch:      noarch
-
 %python_subpackages
 
 %description
@@ -64,15 +57,13 @@
 Recommends:     %{name}-Django = %{version}
 Recommends:     %{name}-Flask-SQLAlchemy = %{version}
 Recommends:     %{name}-SQLAlchemy = %{version}
+Recommends:     %{name}-aiobotocore = %{version}
+Recommends:     %{name}-aiohttp = %{version}
 Recommends:     %{name}-mysql-connector-python = %{version}
+Recommends:     %{name}-psycopg2 = %{version}
 Recommends:     %{name}-pymongo = %{version}
 Recommends:     %{name}-pynamodb = %{version}
-Recommends:     %{name}-psycopg2 = %{version}
 Recommends:     %{name}-requests = %{version}
-%ifpython3
-Recommends:     %{name}-aiobotocore = %{version}
-Recommends:     %{name}-aiohttp = %{version}
-%endif
 
 %description    all
 The AWS X-Ray SDK for Python enables Python developers to record and
@@ -215,10 +206,6 @@
 %python_expand $python -O -m compileall -d %{$python_sitelib} 
%{buildroot}%{$python_sitelib}/aws_xray_sdk/ext/psycopg2/
 %python_expand %fdupes %{buildroot}%{$python_sitelib}
 
-# python3 only
-rm -rf %{buildroot}%{python2_sitelib}/aws_xray_sdk/ext/aiobotocore/
-rm -rf %{buildroot}%{python2_sitelib}/aws_xray_sdk/ext/aiohttp/
-
 %files %{python_files}
 %license LICENSE
 %doc README.md
@@ -231,8 +218,8 @@
 %exclude %{python_sitelib}/aws_xray_sdk/ext/pynamodb/
 %exclude %{python_sitelib}/aws_xray_sdk/ext/psycopg2/
 %exclude %{python_sitelib}/aws_xray_sdk/ext/requests/
-%python3_only %exclude %{python_sitelib}/aws_xray_sdk/ext/aiohttp/
-%python3_only %exclude %{python_sitelib}/aws_xray_sdk/ext/aiobotocore/
+%exclude %{python_sitelib}/aws_xray_sdk/ext/aiohttp/
+%exclude %{python_sitelib}/aws_xray_sdk/ext/aiobotocore/
 
 %files %{python_files all}
 %license LICENSE
@@ -269,16 +256,12 @@
 %license LICENSE
 %{python_sitelib}/aws_xray_sdk/ext/requests/
 
-%ifpython3
-
 %files %{python_files aiobotocore}
 %license LICENSE
-%{python3_sitelib}/aws_xray_sdk/ext/aiobotocore/
+%{python_sitelib}/aws_xray_sdk/ext/aiobotocore/
 
 %files %{python_files aiohttp}
 %license LICENSE
-%{python3_sitelib}/aws_xray_sdk/ext/aiohttp/
-
-%endif
+%{python_sitelib}/aws_xray_sdk/ext/aiohttp/
 
 %changelog

++++++ aws-xray-sdk-2.6.0.tar.gz -> aws-xray-sdk-2.7.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aws-xray-sdk-2.6.0/PKG-INFO 
new/aws-xray-sdk-2.7.0/PKG-INFO
--- old/aws-xray-sdk-2.6.0/PKG-INFO     2020-06-09 00:01:44.000000000 +0200
+++ new/aws-xray-sdk-2.7.0/PKG-INFO     2021-03-24 18:06:14.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: aws-xray-sdk
-Version: 2.6.0
+Version: 2.7.0
 Summary: The AWS X-Ray SDK for Python (the SDK) enables Python developers to 
record and emit information from within their applications to the AWS X-Ray 
service.
 Home-page: https://github.com/aws/aws-xray-sdk-python
 Author: Amazon Web Services
@@ -480,6 +480,36 @@
         db = XRayFlaskSqlAlchemy(app)
         
         ```
+        
+        ### Ignoring httplib requests
+        
+        If you want to ignore certain httplib requests you can do so based on 
the hostname or URL that is being requsted. The hostname is matched using the 
Python [fnmatch library](https://docs.python.org/3/library/fnmatch.html) which 
does Unix glob style matching.
+        
+        ```python
+        from aws_xray_sdk.ext.httplib import add_ignored as xray_add_ignored
+        
+        # ignore requests to test.myapp.com
+        xray_add_ignored(hostname='test.myapp.com')
+        
+        # ignore requests to a subdomain of myapp.com with a glob pattern
+        xray_add_ignored(hostname='*.myapp.com')
+        
+        # ignore requests to /test-url and /other-test-url
+        xray_add_ignored(urls=['/test-path', '/other-test-path'])
+        
+        # ignore requests to myapp.com for /test-url
+        xray_add_ignored(hostname='myapp.com', urls=['/test-url'])
+        ```
+        
+        If you use a subclass of httplib to make your requests, you can also 
filter on the class name that initiates the request. This must use the complete 
package name to do the match.
+        
+        ```python
+        from aws_xray_sdk.ext.httplib import add_ignored as xray_add_ignored
+        
+        # ignore all requests made by botocore
+        xray_add_ignored(subclass='botocore.awsrequest.AWSHTTPConnection')
+        ```
+        
         ## License
         
         The AWS X-Ray SDK for Python is licensed under the Apache 2.0 License. 
See LICENSE and NOTICE.txt for more information.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aws-xray-sdk-2.6.0/README.md 
new/aws-xray-sdk-2.7.0/README.md
--- old/aws-xray-sdk-2.6.0/README.md    2020-06-05 16:07:23.000000000 +0200
+++ new/aws-xray-sdk-2.7.0/README.md    2021-03-24 17:45:53.000000000 +0100
@@ -473,6 +473,36 @@
 db = XRayFlaskSqlAlchemy(app)
 
 ```
+
+### Ignoring httplib requests
+
+If you want to ignore certain httplib requests you can do so based on the 
hostname or URL that is being requsted. The hostname is matched using the 
Python [fnmatch library](https://docs.python.org/3/library/fnmatch.html) which 
does Unix glob style matching.
+
+```python
+from aws_xray_sdk.ext.httplib import add_ignored as xray_add_ignored
+
+# ignore requests to test.myapp.com
+xray_add_ignored(hostname='test.myapp.com')
+
+# ignore requests to a subdomain of myapp.com with a glob pattern
+xray_add_ignored(hostname='*.myapp.com')
+
+# ignore requests to /test-url and /other-test-url
+xray_add_ignored(urls=['/test-path', '/other-test-path'])
+
+# ignore requests to myapp.com for /test-url
+xray_add_ignored(hostname='myapp.com', urls=['/test-url'])
+```
+
+If you use a subclass of httplib to make your requests, you can also filter on 
the class name that initiates the request. This must use the complete package 
name to do the match.
+
+```python
+from aws_xray_sdk.ext.httplib import add_ignored as xray_add_ignored
+
+# ignore all requests made by botocore
+xray_add_ignored(subclass='botocore.awsrequest.AWSHTTPConnection')
+```
+
 ## License
 
 The AWS X-Ray SDK for Python is licensed under the Apache 2.0 License. See 
LICENSE and NOTICE.txt for more information.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/aws-xray-sdk-2.6.0/aws_xray_sdk/core/async_recorder.py 
new/aws-xray-sdk-2.7.0/aws_xray_sdk/core/async_recorder.py
--- old/aws-xray-sdk-2.6.0/aws_xray_sdk/core/async_recorder.py  2020-06-05 
16:07:23.000000000 +0200
+++ new/aws-xray-sdk-2.7.0/aws_xray_sdk/core/async_recorder.py  2021-03-24 
17:45:53.000000000 +0100
@@ -53,7 +53,7 @@
 
     def in_segment_async(self, name=None, **segment_kwargs):
         """
-        Return a segment async context manger.
+        Return a segment async context manager.
 
         :param str name: the name of the segment
         :param dict segment_kwargs: remaining arguments passed directly to 
`begin_segment`
@@ -62,7 +62,7 @@
 
     def in_subsegment_async(self, name=None, **subsegment_kwargs):
         """
-        Return a subsegment async context manger.
+        Return a subsegment async context manager.
 
         :param str name: the name of the segment
         :param dict segment_kwargs: remaining arguments passed directly to 
`begin_segment`
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/aws-xray-sdk-2.6.0/aws_xray_sdk/core/models/entity.py 
new/aws-xray-sdk-2.7.0/aws_xray_sdk/core/models/entity.py
--- old/aws-xray-sdk-2.6.0/aws_xray_sdk/core/models/entity.py   2020-06-05 
16:07:23.000000000 +0200
+++ new/aws-xray-sdk-2.7.0/aws_xray_sdk/core/models/entity.py   2021-03-24 
17:45:53.000000000 +0100
@@ -4,9 +4,10 @@
 import time
 import string
 
-import jsonpickle
+import json
 
 from ..utils.compat import annotation_value_types, string_types
+from ..utils.conversion import metadata_to_dict
 from .throwable import Throwable
 from . import http
 from ..exceptions.exceptions import AlreadyEndedException
@@ -211,7 +212,7 @@
         """
         Add an exception to trace entities.
 
-        :param Exception exception: the catched exception.
+        :param Exception exception: the caught exception.
         :param list stack: the output from python built-in
             `traceback.extract_stack()`.
         :param bool remote: If False it means it's a client error
@@ -224,7 +225,16 @@
             setattr(self, 'cause', getattr(exception, '_cause_id'))
             return
 
-        exceptions = []
+        if not isinstance(self.cause, dict):
+            log.warning("The current cause object is not a dict but an id: {}. 
Resetting the cause and recording the "
+                        "current exception".format(self.cause))
+            self.cause = {}
+
+        if 'exceptions' in self.cause:
+            exceptions = self.cause['exceptions']
+        else:
+            exceptions = []
+
         exceptions.append(Throwable(exception, stack, remote))
 
         self.cause['exceptions'] = exceptions
@@ -247,36 +257,42 @@
     def serialize(self):
         """
         Serialize to JSON document that can be accepted by the
-        X-Ray backend service. It uses jsonpickle to perform
-        serialization.
+        X-Ray backend service. It uses json to perform serialization.
         """
         try:
-            return jsonpickle.encode(self, unpicklable=False)
+            return json.dumps(self.to_dict(), default=str)
         except Exception:
-            log.exception("got an exception during serialization")
+            log.exception("Failed to serialize %s", self.name)
 
-    def _delete_empty_properties(self, properties):
+    def to_dict(self):
         """
-        Delete empty properties before serialization to avoid
-        extra keys with empty values in the output json.
+        Convert Entity(Segment/Subsegment) object to dict
+        with required properties that have non-empty values. 
         """
-        if not self.parent_id:
-            del properties['parent_id']
-        if not self.subsegments:
-            del properties['subsegments']
-        if not self.aws:
-            del properties['aws']
-        if not self.http:
-            del properties['http']
-        if not self.cause:
-            del properties['cause']
-        if not self.annotations:
-            del properties['annotations']
-        if not self.metadata:
-            del properties['metadata']
-        properties.pop(ORIGIN_TRACE_HEADER_ATTR_KEY, None)
-
-        del properties['sampled']
+        entity_dict = {}
+            
+        for key, value in vars(self).items():
+            if isinstance(value, bool) or value:
+                if key == 'subsegments':
+                    # child subsegments are stored as List
+                    subsegments = []
+                    for subsegment in value:
+                        subsegments.append(subsegment.to_dict())
+                    entity_dict[key] = subsegments
+                elif key == 'cause':
+                    entity_dict[key] = {}
+                    entity_dict[key]['working_directory'] = 
self.cause['working_directory']
+                    # exceptions are stored as List
+                    throwables = []
+                    for throwable in value['exceptions']:
+                        throwables.append(throwable.to_dict())
+                    entity_dict[key]['exceptions'] = throwables
+                elif key == 'metadata':
+                    entity_dict[key] = metadata_to_dict(value)
+                elif key != 'sampled' and key != ORIGIN_TRACE_HEADER_ATTR_KEY:
+                   entity_dict[key] = value
+                
+        return entity_dict
 
     def _check_ended(self):
         if not self.in_progress:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/aws-xray-sdk-2.6.0/aws_xray_sdk/core/models/segment.py 
new/aws-xray-sdk-2.7.0/aws_xray_sdk/core/models/segment.py
--- old/aws-xray-sdk-2.6.0/aws_xray_sdk/core/models/segment.py  2020-06-05 
16:07:23.000000000 +0200
+++ new/aws-xray-sdk-2.7.0/aws_xray_sdk/core/models/segment.py  2021-03-24 
17:45:53.000000000 +0100
@@ -155,14 +155,14 @@
             self.aws['xray'] = {}
         self.aws['xray']['sampling_rule_name'] = rule_name
 
-    def __getstate__(self):
+    def to_dict(self):   
         """
-        Used by jsonpikle to remove unwanted fields.
-        """
-        properties = copy.copy(self.__dict__)
-        super(Segment, self)._delete_empty_properties(properties)
-        if not self.user:
-            del properties['user']
-        del properties['ref_counter']
-        del properties['_subsegments_counter']
-        return properties
+        Convert Segment object to dict with required properties
+        that have non-empty values. 
+        """ 
+        segment_dict = super(Segment, self).to_dict()
+          
+        del segment_dict['ref_counter']
+        del segment_dict['_subsegments_counter']
+        
+        return segment_dict
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/aws-xray-sdk-2.6.0/aws_xray_sdk/core/models/subsegment.py 
new/aws-xray-sdk-2.7.0/aws_xray_sdk/core/models/subsegment.py
--- old/aws-xray-sdk-2.6.0/aws_xray_sdk/core/models/subsegment.py       
2020-06-05 16:07:23.000000000 +0200
+++ new/aws-xray-sdk-2.7.0/aws_xray_sdk/core/models/subsegment.py       
2021-03-24 17:45:53.000000000 +0100
@@ -149,12 +149,13 @@
         """
         self.sql = sql
 
-    def __getstate__(self):
-
-        properties = copy.copy(self.__dict__)
-        super(Subsegment, self)._delete_empty_properties(properties)
+    def to_dict(self): 
+        """
+        Convert Subsegment object to dict with required properties
+        that have non-empty values. 
+        """    
+        subsegment_dict = super(Subsegment, self).to_dict()
+        
+        del subsegment_dict['parent_segment']
 
-        del properties['parent_segment']
-        if not self.sql:
-            del properties['sql']
-        return properties
+        return subsegment_dict
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/aws-xray-sdk-2.6.0/aws_xray_sdk/core/models/throwable.py 
new/aws-xray-sdk-2.7.0/aws_xray_sdk/core/models/throwable.py
--- old/aws-xray-sdk-2.6.0/aws_xray_sdk/core/models/throwable.py        
2020-06-05 16:07:23.000000000 +0200
+++ new/aws-xray-sdk-2.7.0/aws_xray_sdk/core/models/throwable.py        
2021-03-24 17:45:53.000000000 +0100
@@ -46,6 +46,19 @@
         if exception:
             setattr(exception, '_recorded', True)
             setattr(exception, '_cause_id', self.id)
+                       
+    def to_dict(self):  
+        """
+        Convert Throwable object to dict with required properties that
+        have non-empty values. 
+        """  
+        throwable_dict = {}
+        
+        for key, value in vars(self).items():  
+            if isinstance(value, bool) or value:
+                throwable_dict[key] = value       
+        
+        return throwable_dict
 
     def _normalize_stack_trace(self, stack):
         if stack is None:
@@ -66,11 +79,3 @@
             normalized['label'] = label.strip()
 
             self.stack.append(normalized)
-
-    def __getstate__(self):
-        properties = copy.copy(self.__dict__)
-
-        if not self.stack:
-            del properties['stack']
-
-        return properties
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aws-xray-sdk-2.6.0/aws_xray_sdk/core/patcher.py 
new/aws-xray-sdk-2.7.0/aws_xray_sdk/core/patcher.py
--- old/aws-xray-sdk-2.6.0/aws_xray_sdk/core/patcher.py 2020-06-05 
16:07:23.000000000 +0200
+++ new/aws-xray-sdk-2.7.0/aws_xray_sdk/core/patcher.py 2021-03-24 
17:45:53.000000000 +0100
@@ -24,6 +24,7 @@
     'pymysql',
     'psycopg2',
     'pg8000',
+    'sqlalchemy_core',
 )
 
 NO_DOUBLE_PATCH = (
@@ -37,6 +38,7 @@
     'pymysql',
     'psycopg2',
     'pg8000',
+    'sqlalchemy_core',
 )
 
 _PATCHED_MODULES = set()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/aws-xray-sdk-2.6.0/aws_xray_sdk/core/plugins/ec2_plugin.py 
new/aws-xray-sdk-2.7.0/aws_xray_sdk/core/plugins/ec2_plugin.py
--- old/aws-xray-sdk-2.6.0/aws_xray_sdk/core/plugins/ec2_plugin.py      
2020-06-05 16:07:23.000000000 +0200
+++ new/aws-xray-sdk-2.7.0/aws_xray_sdk/core/plugins/ec2_plugin.py      
2021-03-24 17:45:53.000000000 +0100
@@ -1,10 +1,10 @@
 import json
 import logging
 from future.standard_library import install_aliases
-from urllib.request import urlopen, Request
-
 install_aliases()
 
+from urllib.request import urlopen, Request
+
 log = logging.getLogger(__name__)
 
 SERVICE_NAME = 'ec2'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aws-xray-sdk-2.6.0/aws_xray_sdk/core/recorder.py 
new/aws-xray-sdk-2.7.0/aws_xray_sdk/core/recorder.py
--- old/aws-xray-sdk-2.6.0/aws_xray_sdk/core/recorder.py        2020-06-05 
16:07:23.000000000 +0200
+++ new/aws-xray-sdk-2.7.0/aws_xray_sdk/core/recorder.py        2021-03-24 
17:45:53.000000000 +0100
@@ -184,7 +184,7 @@
 
     def in_segment(self, name=None, **segment_kwargs):
         """
-        Return a segment context manger.
+        Return a segment context manager.
 
         :param str name: the name of the segment
         :param dict segment_kwargs: remaining arguments passed directly to 
`begin_segment`
@@ -193,7 +193,7 @@
 
     def in_subsegment(self, name=None, **subsegment_kwargs):
         """
-        Return a subsegment context manger.
+        Return a subsegment context manager.
 
         :param str name: the name of the subsegment
         :param dict subsegment_kwargs: remaining arguments passed directly to 
`begin_subsegment`
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aws-xray-sdk-2.6.0/aws_xray_sdk/core/utils/compat.py 
new/aws-xray-sdk-2.7.0/aws_xray_sdk/core/utils/compat.py
--- old/aws-xray-sdk-2.6.0/aws_xray_sdk/core/utils/compat.py    2020-06-05 
16:07:23.000000000 +0200
+++ new/aws-xray-sdk-2.7.0/aws_xray_sdk/core/utils/compat.py    2021-03-24 
17:45:53.000000000 +0100
@@ -6,7 +6,7 @@
 PY35 = sys.version_info >= (3, 5)
 
 if PY2:
-    annotation_value_types = (int, long, float, bool, str)  # noqa: F821
+    annotation_value_types = (int, long, float, bool, str, unicode)  # noqa: 
F821
     string_types = basestring  # noqa: F821
 else:
     annotation_value_types = (int, float, bool, str)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/aws-xray-sdk-2.6.0/aws_xray_sdk/core/utils/conversion.py 
new/aws-xray-sdk-2.7.0/aws_xray_sdk/core/utils/conversion.py
--- old/aws-xray-sdk-2.6.0/aws_xray_sdk/core/utils/conversion.py        
1970-01-01 01:00:00.000000000 +0100
+++ new/aws-xray-sdk-2.7.0/aws_xray_sdk/core/utils/conversion.py        
2021-03-24 17:45:53.000000000 +0100
@@ -0,0 +1,35 @@
+import logging
+
+log = logging.getLogger(__name__)
+
+def metadata_to_dict(obj):
+    """
+    Convert object to dict with all serializable properties like:
+    dict, list, set, tuple, str, bool, int, float, type, object, etc.
+    """
+    try:
+        if isinstance(obj, dict):
+            metadata = {}
+            for key, value in obj.items():
+                metadata[key] = metadata_to_dict(value)
+            return metadata
+        elif isinstance(obj, type):
+            return str(obj)
+        elif hasattr(obj, "_ast"):
+            return metadata_to_dict(obj._ast())
+        elif hasattr(obj, "__iter__") and not isinstance(obj, str):
+            metadata = []
+            for item in obj:
+                metadata.append(metadata_to_dict(item))
+            return metadata
+        elif hasattr(obj, "__dict__"):
+            metadata = {}
+            for key, value in vars(obj).items():
+                if not callable(value) and not key.startswith('_'):
+                    metadata[key] = metadata_to_dict(value)
+            return metadata
+        else:
+            return obj
+    except Exception:
+        log.exception("Failed to convert {} to dict".format(str(obj)))
+        return {}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aws-xray-sdk-2.6.0/aws_xray_sdk/ext/django/apps.py 
new/aws-xray-sdk-2.7.0/aws_xray_sdk/ext/django/apps.py
--- old/aws-xray-sdk-2.6.0/aws_xray_sdk/ext/django/apps.py      2020-06-05 
16:07:23.000000000 +0200
+++ new/aws-xray-sdk-2.7.0/aws_xray_sdk/ext/django/apps.py      2021-03-24 
17:45:53.000000000 +0100
@@ -30,6 +30,7 @@
             daemon_address=settings.AWS_XRAY_DAEMON_ADDRESS,
             sampling=settings.SAMPLING,
             sampling_rules=settings.SAMPLING_RULES,
+            sampler=settings.SAMPLER,
             context_missing=settings.AWS_XRAY_CONTEXT_MISSING,
             plugins=settings.PLUGINS,
             service=settings.AWS_XRAY_TRACING_NAME,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aws-xray-sdk-2.6.0/aws_xray_sdk/ext/django/conf.py 
new/aws-xray-sdk-2.7.0/aws_xray_sdk/ext/django/conf.py
--- old/aws-xray-sdk-2.6.0/aws_xray_sdk/ext/django/conf.py      2020-06-05 
16:07:23.000000000 +0200
+++ new/aws-xray-sdk-2.7.0/aws_xray_sdk/ext/django/conf.py      2021-03-24 
17:45:53.000000000 +0100
@@ -10,6 +10,7 @@
     'PLUGINS': (),
     'SAMPLING': True,
     'SAMPLING_RULES': None,
+    'SAMPLER': None,
     'AWS_XRAY_TRACING_NAME': None,
     'DYNAMIC_NAMING': None,
     'STREAMING_THRESHOLD': None,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/aws-xray-sdk-2.6.0/aws_xray_sdk/ext/flask/middleware.py 
new/aws-xray-sdk-2.7.0/aws_xray_sdk/ext/flask/middleware.py
--- old/aws-xray-sdk-2.6.0/aws_xray_sdk/ext/flask/middleware.py 2020-06-05 
16:07:23.000000000 +0200
+++ new/aws-xray-sdk-2.7.0/aws_xray_sdk/ext/flask/middleware.py 2021-03-24 
17:45:53.000000000 +0100
@@ -17,7 +17,7 @@
         self._recorder = recorder
         self.app.before_request(self._before_request)
         self.app.after_request(self._after_request)
-        self.app.teardown_request(self._handle_exception)
+        self.app.teardown_request(self._teardown_request)
         self.in_lambda_ctx = False
 
         if check_in_lambda() and type(self._recorder.context) == LambdaContext:
@@ -81,15 +81,9 @@
         if cont_len:
             segment.put_http_meta(http.CONTENT_LENGTH, int(cont_len))
 
-        if self.in_lambda_ctx:
-            self._recorder.end_subsegment()
-        else:
-            self._recorder.end_segment()
         return response
 
-    def _handle_exception(self, exception):
-        if not exception:
-            return
+    def _teardown_request(self, exception):
         segment = None
         try:
             if self.in_lambda_ctx:
@@ -101,9 +95,11 @@
         if not segment:
             return
 
-        segment.put_http_meta(http.STATUS, 500)
-        stack = stacktrace.get_stacktrace(limit=self._recorder._max_trace_back)
-        segment.add_exception(exception, stack)
+        if exception:
+            segment.put_http_meta(http.STATUS, 500)
+            stack = 
stacktrace.get_stacktrace(limit=self._recorder._max_trace_back)
+            segment.add_exception(exception, stack)
+
         if self.in_lambda_ctx:
             self._recorder.end_subsegment()
         else:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/aws-xray-sdk-2.6.0/aws_xray_sdk/ext/httplib/__init__.py 
new/aws-xray-sdk-2.7.0/aws_xray_sdk/ext/httplib/__init__.py
--- old/aws-xray-sdk-2.6.0/aws_xray_sdk/ext/httplib/__init__.py 2020-06-05 
16:07:23.000000000 +0200
+++ new/aws-xray-sdk-2.7.0/aws_xray_sdk/ext/httplib/__init__.py 2021-03-24 
17:45:53.000000000 +0100
@@ -1,3 +1,3 @@
-from .patch import patch, unpatch
+from .patch import patch, unpatch, add_ignored, reset_ignored
 
-__all__ = ['patch', 'unpatch']
+__all__ = ['patch', 'unpatch', 'add_ignored', 'reset_ignored']
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aws-xray-sdk-2.6.0/aws_xray_sdk/ext/httplib/patch.py 
new/aws-xray-sdk-2.7.0/aws_xray_sdk/ext/httplib/patch.py
--- old/aws-xray-sdk-2.6.0/aws_xray_sdk/ext/httplib/patch.py    2020-06-05 
16:07:23.000000000 +0200
+++ new/aws-xray-sdk-2.7.0/aws_xray_sdk/ext/httplib/patch.py    2021-03-24 
17:45:53.000000000 +0100
@@ -1,7 +1,7 @@
 from collections import namedtuple
 import sys
 import wrapt
-
+import fnmatch
 import urllib3.connection
 
 from aws_xray_sdk.core import xray_recorder
@@ -22,8 +22,33 @@
 
 _XRAY_PROP = '_xray_prop'
 _XRay_Data = namedtuple('xray_data', ['method', 'host', 'url'])
+_XRay_Ignore = namedtuple('xray_ignore', ['subclass', 'hostname', 'urls'])
 # A flag indicates whether this module is X-Ray patched or not
 PATCH_FLAG = '__xray_patched'
+# Calls that should be ignored
+_XRAY_IGNORE = set()
+
+
+def add_ignored(subclass=None, hostname=None, urls=None):
+    global _XRAY_IGNORE
+    if subclass is not None or hostname is not None or urls is not None:
+        urls = urls if urls is None else tuple(urls)
+        _XRAY_IGNORE.add(_XRay_Ignore(subclass=subclass, hostname=hostname, 
urls=urls))
+
+
+def reset_ignored():
+    global _XRAY_IGNORE
+    _XRAY_IGNORE.clear()
+    _ignored_add_default()
+
+
+def _ignored_add_default():
+    # skip httplib tracing for SDK built-in centralized sampling pollers
+    add_ignored(subclass='botocore.awsrequest.AWSHTTPConnection', 
urls=['/GetSamplingRules', '/SamplingTargets'])
+
+
+# make sure we have the default rules
+_ignored_add_default()
 
 
 def http_response_processor(wrapped, instance, args, kwargs, return_value,
@@ -77,11 +102,26 @@
         subsegment.add_exception(exception, stack)
 
 
+def _ignore_request(instance, hostname, url):
+    global _XRAY_IGNORE
+    module = instance.__class__.__module__
+    if module is None or module == str.__class__.__module__:
+        subclass = instance.__class__.__name__
+    else:
+        subclass = module + '.' + instance.__class__.__name__
+    for rule in _XRAY_IGNORE:
+        subclass_match = subclass == rule.subclass if rule.subclass is not 
None else True
+        host_match = fnmatch.fnmatch(hostname, rule.hostname) if rule.hostname 
is not None else True
+        url_match = url in rule.urls if rule.urls is not None else True
+        if url_match and host_match and subclass_match:
+            return True
+    return False
+
+
 def _send_request(wrapped, instance, args, kwargs):
     def decompose_args(method, url, body, headers, encode_chunked=False):
-        # skip httplib tracing for SDK built-in centralized sampling pollers
-        if (('/GetSamplingRules' in args or '/SamplingTargets' in args) and
-                type(instance).__name__ == 
'botocore.awsrequest.AWSHTTPConnection'):
+        # skip any ignored requests
+        if _ignore_request(instance, instance.host, url):
             return wrapped(*args, **kwargs)
 
         # Only injects headers when the subsegment for the outgoing
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/aws-xray-sdk-2.6.0/aws_xray_sdk/ext/sqlalchemy/util/decorators.py 
new/aws-xray-sdk-2.7.0/aws_xray_sdk/ext/sqlalchemy/util/decorators.py
--- old/aws-xray-sdk-2.6.0/aws_xray_sdk/ext/sqlalchemy/util/decorators.py       
2020-06-05 16:07:23.000000000 +0200
+++ new/aws-xray-sdk-2.7.0/aws_xray_sdk/ext/sqlalchemy/util/decorators.py       
2021-03-24 17:45:53.000000000 +0100
@@ -58,11 +58,14 @@
                 subsegment = xray_recorder.begin_subsegment(sub_name, 
namespace='remote')
             else:
                 subsegment = None
-        res = func(*args, **kw)
-        if subsegment is not None:
-            subsegment.set_sql(sql)
-            subsegment.put_annotation("sqlalchemy", 
class_name+'.'+func.__name__)
-            xray_recorder.end_subsegment()
+
+        try:
+            res = func(*args, **kw)
+        finally:
+            if subsegment is not None:
+                subsegment.set_sql(sql)
+                subsegment.put_annotation("sqlalchemy", 
class_name+'.'+func.__name__)
+                xray_recorder.end_subsegment()
         return res
     return wrapper
 # URL Parse output
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/aws-xray-sdk-2.6.0/aws_xray_sdk/ext/sqlalchemy_core/__init__.py 
new/aws-xray-sdk-2.7.0/aws_xray_sdk/ext/sqlalchemy_core/__init__.py
--- old/aws-xray-sdk-2.6.0/aws_xray_sdk/ext/sqlalchemy_core/__init__.py 
1970-01-01 01:00:00.000000000 +0100
+++ new/aws-xray-sdk-2.7.0/aws_xray_sdk/ext/sqlalchemy_core/__init__.py 
2021-03-24 17:45:53.000000000 +0100
@@ -0,0 +1,3 @@
+from .patch import patch, unpatch
+
+__all__ = ['patch', 'unpatch']
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/aws-xray-sdk-2.6.0/aws_xray_sdk/ext/sqlalchemy_core/patch.py 
new/aws-xray-sdk-2.7.0/aws_xray_sdk/ext/sqlalchemy_core/patch.py
--- old/aws-xray-sdk-2.6.0/aws_xray_sdk/ext/sqlalchemy_core/patch.py    
1970-01-01 01:00:00.000000000 +0100
+++ new/aws-xray-sdk-2.7.0/aws_xray_sdk/ext/sqlalchemy_core/patch.py    
2021-03-24 17:45:53.000000000 +0100
@@ -0,0 +1,86 @@
+import logging
+import sys
+if sys.version_info >= (3, 0, 0):
+    from urllib.parse import urlparse, uses_netloc
+else:
+    from urlparse import urlparse, uses_netloc
+
+import wrapt
+
+from aws_xray_sdk.core import xray_recorder
+from aws_xray_sdk.core.patcher import _PATCHED_MODULES
+from aws_xray_sdk.core.utils import stacktrace
+from aws_xray_sdk.ext.util import unwrap
+
+
+def _sql_meta(instance, args):
+    try:
+        metadata = {}
+        url = urlparse(str(instance.engine.url))
+        # Add Scheme to uses_netloc or // will be missing from url.
+        uses_netloc.append(url.scheme)
+        if url.password is None:
+            metadata['url'] = url.geturl()
+            name = url.netloc
+        else:
+            # Strip password from URL
+            host_info = url.netloc.rpartition('@')[-1]
+            parts = url._replace(netloc='{}@{}'.format(url.username, 
host_info))
+            metadata['url'] = parts.geturl()
+            name = host_info
+        metadata['user'] = url.username
+        metadata['database_type'] = instance.engine.name
+        try:
+            version = getattr(instance.dialect, 
'{}_version'.format(instance.engine.driver))
+            version_str = '.'.join(map(str, version))
+            metadata['driver_version'] = 
"{}-{}".format(instance.engine.driver, version_str)
+        except AttributeError:
+            metadata['driver_version'] = instance.engine.driver
+        if instance.dialect.server_version_info is not None:
+            metadata['database_version'] = '.'.join(map(str, 
instance.dialect.server_version_info))
+        if xray_recorder.stream_sql:
+            metadata['sanitized_query'] = str(args[0])
+    except Exception:
+        metadata = None
+        name = None
+        logging.getLogger(__name__).exception('Error parsing sql metadata.')
+    return name, metadata
+
+
+def _xray_traced_sqlalchemy_execute(wrapped, instance, args, kwargs):
+    name, sql = _sql_meta(instance, args)
+    if sql is not None:
+        subsegment = xray_recorder.begin_subsegment(name, namespace='remote')
+    else:
+        subsegment = None
+    try:
+        res = wrapped(*args, **kwargs)
+    except Exception:
+        if subsegment is not None:
+            exception = sys.exc_info()[1]
+            stack = 
stacktrace.get_stacktrace(limit=xray_recorder._max_trace_back)
+            subsegment.add_exception(exception, stack)
+        raise
+    finally:
+        if subsegment is not None:
+            subsegment.set_sql(sql)
+            xray_recorder.end_subsegment()
+    return res
+
+
+def patch():
+    wrapt.wrap_function_wrapper(
+        'sqlalchemy.engine.base',
+        'Connection.execute',
+        _xray_traced_sqlalchemy_execute
+    )
+
+
+def unpatch():
+    """
+    Unpatch any previously patched modules.
+    This operation is idempotent.
+    """
+    _PATCHED_MODULES.discard('sqlalchemy_core')
+    import sqlalchemy
+    unwrap(sqlalchemy.engine.base.Connection, 'execute')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aws-xray-sdk-2.6.0/aws_xray_sdk/version.py 
new/aws-xray-sdk-2.7.0/aws_xray_sdk/version.py
--- old/aws-xray-sdk-2.6.0/aws_xray_sdk/version.py      2020-06-08 
23:59:48.000000000 +0200
+++ new/aws-xray-sdk-2.7.0/aws_xray_sdk/version.py      2021-03-24 
17:45:53.000000000 +0100
@@ -1 +1 @@
-VERSION = '2.6.0'
+VERSION = '2.7.0'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aws-xray-sdk-2.6.0/aws_xray_sdk.egg-info/PKG-INFO 
new/aws-xray-sdk-2.7.0/aws_xray_sdk.egg-info/PKG-INFO
--- old/aws-xray-sdk-2.6.0/aws_xray_sdk.egg-info/PKG-INFO       2020-06-09 
00:01:44.000000000 +0200
+++ new/aws-xray-sdk-2.7.0/aws_xray_sdk.egg-info/PKG-INFO       2021-03-24 
18:06:14.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: aws-xray-sdk
-Version: 2.6.0
+Version: 2.7.0
 Summary: The AWS X-Ray SDK for Python (the SDK) enables Python developers to 
record and emit information from within their applications to the AWS X-Ray 
service.
 Home-page: https://github.com/aws/aws-xray-sdk-python
 Author: Amazon Web Services
@@ -480,6 +480,36 @@
         db = XRayFlaskSqlAlchemy(app)
         
         ```
+        
+        ### Ignoring httplib requests
+        
+        If you want to ignore certain httplib requests you can do so based on 
the hostname or URL that is being requsted. The hostname is matched using the 
Python [fnmatch library](https://docs.python.org/3/library/fnmatch.html) which 
does Unix glob style matching.
+        
+        ```python
+        from aws_xray_sdk.ext.httplib import add_ignored as xray_add_ignored
+        
+        # ignore requests to test.myapp.com
+        xray_add_ignored(hostname='test.myapp.com')
+        
+        # ignore requests to a subdomain of myapp.com with a glob pattern
+        xray_add_ignored(hostname='*.myapp.com')
+        
+        # ignore requests to /test-url and /other-test-url
+        xray_add_ignored(urls=['/test-path', '/other-test-path'])
+        
+        # ignore requests to myapp.com for /test-url
+        xray_add_ignored(hostname='myapp.com', urls=['/test-url'])
+        ```
+        
+        If you use a subclass of httplib to make your requests, you can also 
filter on the class name that initiates the request. This must use the complete 
package name to do the match.
+        
+        ```python
+        from aws_xray_sdk.ext.httplib import add_ignored as xray_add_ignored
+        
+        # ignore all requests made by botocore
+        xray_add_ignored(subclass='botocore.awsrequest.AWSHTTPConnection')
+        ```
+        
         ## License
         
         The AWS X-Ray SDK for Python is licensed under the Apache 2.0 License. 
See LICENSE and NOTICE.txt for more information.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aws-xray-sdk-2.6.0/aws_xray_sdk.egg-info/SOURCES.txt 
new/aws-xray-sdk-2.7.0/aws_xray_sdk.egg-info/SOURCES.txt
--- old/aws-xray-sdk-2.6.0/aws_xray_sdk.egg-info/SOURCES.txt    2020-06-09 
00:01:44.000000000 +0200
+++ new/aws-xray-sdk-2.7.0/aws_xray_sdk.egg-info/SOURCES.txt    2021-03-24 
18:06:14.000000000 +0100
@@ -57,6 +57,7 @@
 aws_xray_sdk/core/utils/__init__.py
 aws_xray_sdk/core/utils/atomic_counter.py
 aws_xray_sdk/core/utils/compat.py
+aws_xray_sdk/core/utils/conversion.py
 aws_xray_sdk/core/utils/search_pattern.py
 aws_xray_sdk/core/utils/stacktrace.py
 aws_xray_sdk/ext/__init__.py
@@ -103,5 +104,7 @@
 aws_xray_sdk/ext/sqlalchemy/query.py
 aws_xray_sdk/ext/sqlalchemy/util/__init__.py
 aws_xray_sdk/ext/sqlalchemy/util/decorators.py
+aws_xray_sdk/ext/sqlalchemy_core/__init__.py
+aws_xray_sdk/ext/sqlalchemy_core/patch.py
 aws_xray_sdk/ext/sqlite3/__init__.py
 aws_xray_sdk/ext/sqlite3/patch.py
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/aws-xray-sdk-2.6.0/aws_xray_sdk.egg-info/requires.txt 
new/aws-xray-sdk-2.7.0/aws_xray_sdk.egg-info/requires.txt
--- old/aws-xray-sdk-2.6.0/aws_xray_sdk.egg-info/requires.txt   2020-06-09 
00:01:44.000000000 +0200
+++ new/aws-xray-sdk-2.7.0/aws_xray_sdk.egg-info/requires.txt   2021-03-24 
18:06:14.000000000 +0100
@@ -1,4 +1,3 @@
-jsonpickle
 wrapt
 future
 botocore>=1.11.3
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/aws-xray-sdk-2.6.0/setup.py 
new/aws-xray-sdk-2.7.0/setup.py
--- old/aws-xray-sdk-2.6.0/setup.py     2020-06-05 16:07:23.000000000 +0200
+++ new/aws-xray-sdk-2.7.0/setup.py     2021-03-24 17:45:53.000000000 +0100
@@ -44,7 +44,6 @@
     ],
 
     install_requires=[
-        'jsonpickle',
         'enum34;python_version<"3.4"',
         'wrapt',
         'future',

Reply via email to