Skip to content

Commit ac3d231

Browse files
authored
Merge branch 'master' into doc_update
2 parents 4bea199 + 2976b25 commit ac3d231

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+245
-381
lines changed

.github/workflows/UnitTesting.yaml

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,31 @@ on:
99

1010
jobs:
1111
test:
12-
# "setup-python" action doesn't provide python 3.4 binaries for ubuntu-latest.
13-
# Sticking to Ubuntu 18.04 as recommended here:
14-
# https://github.com/actions/setup-python/issues/185#issuecomment-768232756
15-
runs-on: ubuntu-18.04
12+
runs-on: ubuntu-22.04
1613
env:
17-
py27: 2.7
18-
py34: 3.4
19-
py35: 3.5
20-
py36: 3.6
2114
py37: 3.7
2215
py38: 3.8
2316
py39: 3.9
17+
py310: '3.10'
18+
py311: '3.11'
19+
DB_DATABASE: test_db
20+
DB_USER: root
21+
DB_PASSWORD: root
2422
strategy:
2523
fail-fast: false
2624
matrix:
27-
python-version: [py27, py34, py35, py36, py37, py38, py39]
25+
python-version: [py37, py38, py39, py310, py311]
2826
testenv: [core, ext]
2927
steps:
3028
- name: Checkout repo
3129
uses: actions/checkout@v3
3230

31+
- name: Start MySQL
32+
if: ${{ matrix.testenv == 'ext' }}
33+
run: |
34+
sudo /etc/init.d/mysql start
35+
mysql -e 'CREATE DATABASE ${{ env.DB_DATABASE }};' -u${{ env.DB_USER }} -p${{ env.DB_PASSWORD }}
36+
3337
- name: Setup Python
3438
uses: actions/setup-python@v4
3539
with:

.travis.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

CHANGELOG.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@ CHANGELOG
55
Unreleased
66
==========
77

8+
2.12.0
9+
==========
10+
* improvement: Default Context Missing Strategy set to Log Error `PR372 https://github.com/aws/aws-xray-sdk-python/pull/372`
11+
* bugfix: Pin tox version to <=3.27.1 to fix CI tests `PR374 https://github.com/aws/aws-xray-sdk-python/pull/374`
12+
* improvement: Sample app dependency update `PR373 https://github.com/aws/aws-xray-sdk-python/pull/373`
13+
* bugfix: Fix pynamodb tests for Python < 3.6 `PR375 https://github.com/aws/aws-xray-sdk-python/pull/375`
14+
* improvement: Use latest GH Actions versions in CI tests `PR365 https://github.com/aws/aws-xray-sdk-python/pull/365`
15+
* improvement: Simplify setup script `PR363 https://github.com/aws/aws-xray-sdk-python/pull/363`
16+
* bugfix: Fix deprecation warnings related to asyncio `PR364 https://github.com/aws/aws-xray-sdk-python/pull/364`
17+
* improvement: Run tests against Python 3.10 and 3.11 `PR376 https://github.com/aws/aws-xray-sdk-python/pull/376`
18+
* improvement: Sample app dependency update `PR380 https://github.com/aws/aws-xray-sdk-python/pull/380`
19+
* bugfix: Pin sqlalchemy version to 1.x to fix tests `PR381 https://github.com/aws/aws-xray-sdk-python/pull/381`
20+
* bugfix: Fix sample app dependencies incompatibility with XRay SDK `PR382 https://github.com/aws/aws-xray-sdk-python/pull/382`
21+
* bugfix: Start MySQL from GH Actions, upgrade Ubuntu, and remove Python versions for unit tests `PR384 https://github.com/aws/aws-xray-sdk-python/pull/384`
22+
823
2.11.0
924
==========
1025
* bugfix: Fix TypeError by patching register_default_jsonb from psycopg2 `PR350 https://github.com/aws/aws-xray-sdk-python/pull/350`

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ AWS X-Ray supports using OpenTelemetry Python and the AWS Distro for OpenTelemet
77

88
If you want additional features when tracing your Python applications, please [open an issue on the OpenTelemetry Python Instrumentation repository](https://github.com/open-telemetry/opentelemetry-python-contrib/issues/new?labels=feature-request&template=feature_request.md&title=X-Ray%20Compatible%20Feature%20Request).
99

10+
### :mega: Python Versions End-of-Support Notice
11+
12+
AWS X-Ray SDK for Python versions `>2.11.0` has dropped support for Python 2.7, 3.4, 3.5, and 3.6.
13+
1014
# AWS X-Ray SDK for Python
1115

1216
![Screenshot of the AWS X-Ray console](/images/example_servicemap.png?raw=true)
1317

1418
## Installing
1519

16-
The AWS X-Ray SDK for Python is compatible with Python 2.7, 3.4, 3.5, 3.6, 3.7, 3.8, and 3.9.
20+
The AWS X-Ray SDK for Python is compatible with Python 3.7, 3.8, 3.9, 3.10, and 3.11.
1721

1822
Install the SDK using the following command (the SDK's non-testing dependencies will be installed).
1923

aws_xray_sdk/core/__init__.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1+
from .async_recorder import AsyncAWSXRayRecorder
2+
from .patcher import patch, patch_all
13
from .recorder import AWSXRayRecorder
2-
from .patcher import patch_all, patch
3-
from .utils.compat import PY35
44

5-
6-
if not PY35:
7-
xray_recorder = AWSXRayRecorder()
8-
else:
9-
from .async_recorder import AsyncAWSXRayRecorder
10-
xray_recorder = AsyncAWSXRayRecorder()
5+
xray_recorder = AsyncAWSXRayRecorder()
116

127
__all__ = [
138
'patch',

aws_xray_sdk/core/async_context.py

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import asyncio
2-
import sys
32
import copy
43

54
from .context import Context as _Context
65

7-
_GTE_PY37 = sys.version_info.major == 3 and sys.version_info.minor >= 7
8-
96

107
class AsyncContext(_Context):
118
"""
@@ -16,7 +13,7 @@ class AsyncContext(_Context):
1613
Also overrides clear_trace_entities
1714
"""
1815
def __init__(self, *args, loop=None, use_task_factory=True, **kwargs):
19-
super(AsyncContext, self).__init__(*args, **kwargs)
16+
super().__init__(*args, **kwargs)
2017

2118
self._loop = loop
2219
if loop is None:
@@ -35,7 +32,7 @@ def clear_trace_entities(self):
3532
self._local.clear()
3633

3734

38-
class TaskLocalStorage(object):
35+
class TaskLocalStorage:
3936
"""
4037
Simple task local storage
4138
"""
@@ -51,10 +48,7 @@ def __setattr__(self, name, value):
5148

5249
else:
5350
# Set task local attributes
54-
if _GTE_PY37:
55-
task = asyncio.current_task(loop=self._loop)
56-
else:
57-
task = asyncio.Task.current_task(loop=self._loop)
51+
task = asyncio.current_task(loop=self._loop)
5852
if task is None:
5953
return None
6054

@@ -68,10 +62,7 @@ def __getattribute__(self, item):
6862
# Return references to local objects
6963
return object.__getattribute__(self, item)
7064

71-
if _GTE_PY37:
72-
task = asyncio.current_task(loop=self._loop)
73-
else:
74-
task = asyncio.Task.current_task(loop=self._loop)
65+
task = asyncio.current_task(loop=self._loop)
7566
if task is None:
7667
return None
7768

@@ -82,10 +73,7 @@ def __getattribute__(self, item):
8273

8374
def clear(self):
8475
# If were in a task, clear the context dictionary
85-
if _GTE_PY37:
86-
task = asyncio.current_task(loop=self._loop)
87-
else:
88-
task = asyncio.Task.current_task(loop=self._loop)
76+
task = asyncio.current_task(loop=self._loop)
8977
if task is not None and hasattr(task, 'context'):
9078
task.context.clear()
9179

@@ -104,10 +92,7 @@ def task_factory(loop, coro):
10492
del task._source_traceback[-1] # flake8: noqa
10593

10694
# Share context with new task if possible
107-
if _GTE_PY37:
108-
current_task = asyncio.current_task(loop=loop)
109-
else:
110-
current_task = asyncio.Task.current_task(loop=loop)
95+
current_task = asyncio.current_task(loop=loop)
11196
if current_task is not None and hasattr(current_task, 'context'):
11297
if current_task.context.get('entities'):
11398
# NOTE: (enowell) Because the `AWSXRayRecorder`'s `Context` decides

aws_xray_sdk/core/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
CXT_MISSING_STRATEGY_KEY = 'AWS_XRAY_CONTEXT_MISSING'
1515

1616

17-
class Context(object):
17+
class Context:
1818
"""
1919
The context storage class to store trace entities(segments/subsegments).
2020
The default implementation uses threadlocal to store these entities.

aws_xray_sdk/core/daemon_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
DEFAULT_ADDRESS = '127.0.0.1:2000'
77

88

9-
class DaemonConfig(object):
9+
class DaemonConfig:
1010
"""The class that stores X-Ray daemon configuration about
1111
the ip address and port for UDP and TCP port. It gets the address
1212
string from ``AWS_TRACING_DAEMON_ADDRESS`` and then from recorder's

aws_xray_sdk/core/emitters/udp_emitter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
DEFAULT_DAEMON_ADDRESS = '127.0.0.1:2000'
1313

1414

15-
class UDPEmitter(object):
15+
class UDPEmitter:
1616
"""
1717
The default emitter the X-Ray recorder uses to send segments/subsegments
1818
to the X-Ray daemon over UDP using a non-blocking socket. If there is an

aws_xray_sdk/core/models/default_dynamic_naming.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from ..utils.search_pattern import wildcard_match
22

33

4-
class DefaultDynamicNaming(object):
4+
class DefaultDynamicNaming:
55
"""
66
Decides what name to use on a segment generated from an incoming request.
77
By default it takes the host name and compares it to a pre-defined pattern.

aws_xray_sdk/core/models/dummy_entities.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ class DummySegment(Segment):
1818
def __init__(self, name='dummy'):
1919
no_op_id = os.getenv('AWS_XRAY_NOOP_ID')
2020
if no_op_id and no_op_id.lower() == 'false':
21-
super(DummySegment, self).__init__(name=name, traceid=TraceId().to_id())
21+
super().__init__(name=name, traceid=TraceId().to_id())
2222
else:
23-
super(DummySegment, self).__init__(name=name, traceid=NoOpTraceId().to_id(), entityid='0000000000000000')
23+
super().__init__(name=name, traceid=NoOpTraceId().to_id(), entityid='0000000000000000')
2424
self.sampled = False
2525

2626
def set_aws(self, aws_meta):
@@ -87,7 +87,7 @@ class DummySubsegment(Subsegment):
8787
"""
8888

8989
def __init__(self, segment, name='dummy'):
90-
super(DummySubsegment, self).__init__(name, 'dummy', segment)
90+
super().__init__(name, 'dummy', segment)
9191
no_op_id = os.getenv('AWS_XRAY_NOOP_ID')
9292
if no_op_id and no_op_id.lower() == 'false':
9393
super(Subsegment, self).__init__(name)

aws_xray_sdk/core/models/entity.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import json
88

9-
from ..utils.compat import annotation_value_types, string_types
9+
from ..utils.compat import annotation_value_types
1010
from ..utils.conversion import metadata_to_dict
1111
from .throwable import Throwable
1212
from . import http
@@ -21,7 +21,7 @@
2121
ORIGIN_TRACE_HEADER_ATTR_KEY = '_origin_trace_header'
2222

2323

24-
class Entity(object):
24+
class Entity:
2525
"""
2626
The parent class for segment/subsegment. It holds common properties
2727
and methods on segment and subsegment.
@@ -113,7 +113,7 @@ def put_http_meta(self, key, value):
113113
return
114114

115115
if key == http.STATUS:
116-
if isinstance(value, string_types):
116+
if isinstance(value, str):
117117
value = int(value)
118118
self.apply_status_code(value)
119119

@@ -139,7 +139,7 @@ def put_annotation(self, key, value):
139139
"""
140140
self._check_ended()
141141

142-
if not isinstance(key, string_types):
142+
if not isinstance(key, str):
143143
log.warning("ignoring non string type annotation key with type %s.", type(key))
144144
return
145145

@@ -165,7 +165,7 @@ def put_metadata(self, key, value, namespace='default'):
165165
"""
166166
self._check_ended()
167167

168-
if not isinstance(namespace, string_types):
168+
if not isinstance(namespace, str):
169169
log.warning("ignoring non string type metadata namespace")
170170
return
171171

@@ -271,7 +271,7 @@ def serialize(self):
271271
def to_dict(self):
272272
"""
273273
Convert Entity(Segment/Subsegment) object to dict
274-
with required properties that have non-empty values.
274+
with required properties that have non-empty values.
275275
"""
276276
entity_dict = {}
277277

aws_xray_sdk/core/models/facade_segment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self, name, entityid, traceid, sampled):
2222
sampled=sampled,
2323
)
2424

25-
super(FacadeSegment, self).__init__(
25+
super().__init__(
2626
name=name,
2727
entityid=entityid,
2828
traceid=traceid,

aws_xray_sdk/core/models/segment.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def __init__(self, name, entityid=None, traceid=None,
6363
if not name:
6464
raise SegmentNameMissingException("Segment name is required.")
6565

66-
super(Segment, self).__init__(name)
66+
super().__init__(name)
6767

6868
if not traceid:
6969
traceid = TraceId().to_id()
@@ -85,7 +85,7 @@ def add_subsegment(self, subsegment):
8585
Add input subsegment as a child subsegment and increment
8686
reference counter and total subsegments counter.
8787
"""
88-
super(Segment, self).add_subsegment(subsegment)
88+
super().add_subsegment(subsegment)
8989
self.increment()
9090

9191
def increment(self):
@@ -127,15 +127,15 @@ def remove_subsegment(self, subsegment):
127127
"""
128128
Remove the reference of input subsegment.
129129
"""
130-
super(Segment, self).remove_subsegment(subsegment)
130+
super().remove_subsegment(subsegment)
131131
self.decrement_subsegments_size()
132132

133133
def set_user(self, user):
134134
"""
135135
set user of a segment. One segment can only have one user.
136136
User is indexed and can be later queried.
137137
"""
138-
super(Segment, self)._check_ended()
138+
super()._check_ended()
139139
self.user = user
140140

141141
def set_service(self, service_info):
@@ -160,7 +160,7 @@ def to_dict(self):
160160
Convert Segment object to dict with required properties
161161
that have non-empty values.
162162
"""
163-
segment_dict = super(Segment, self).to_dict()
163+
segment_dict = super().to_dict()
164164

165165
del segment_dict['ref_counter']
166166
del segment_dict['_subsegments_counter']

0 commit comments

Comments
 (0)