Skip to content

Commit

Permalink
Merge branch '0.24-dev' into update-flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
jd committed Apr 2, 2019
2 parents a83684a + 5f28696 commit c5116b1
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ jobs:
steps:
- checkout
- *restore_cache_step
- run: tox -e 'aiobotocore_contrib-{py34,py35,py36}-aiobotocore{02,03,04}' --result-json /tmp/aiobotocore.results
- run: tox -e 'aiobotocore_contrib-py34-aiobotocore{02,03,04},aiobotocore_contrib-{py35,py36}-aiobotocore{02,03,04,05,07,08,09,010}' --result-json /tmp/aiobotocore.results
- persist_to_workspace:
root: /tmp
paths:
Expand Down
54 changes: 35 additions & 19 deletions tests/contrib/aiobotocore/py35/test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# flake8: noqa
# DEV: Skip linting, we lint with Python 2, we'll get SyntaxErrors from `async`
import aiobotocore
from nose.tools import eq_

from ddtrace.contrib.aiobotocore.patch import patch, unpatch
Expand Down Expand Up @@ -36,22 +37,37 @@ async def test_response_context_manager(self):
await stream.read()

traces = self.tracer.writer.pop_traces()
eq_(len(traces), 2)
eq_(len(traces[0]), 1)
eq_(len(traces[1]), 1)

span = traces[0][0]
eq_(span.get_tag('aws.operation'), 'GetObject')
eq_(span.get_tag('http.status_code'), '200')
eq_(span.service, 'aws.s3')
eq_(span.resource, 's3.getobject')

read_span = traces[1][0]
eq_(read_span.get_tag('aws.operation'), 'GetObject')
eq_(read_span.get_tag('http.status_code'), '200')
eq_(read_span.service, 'aws.s3')
eq_(read_span.resource, 's3.getobject')
eq_(read_span.name, 's3.command.read')
# enforce parenting
eq_(read_span.parent_id, span.span_id)
eq_(read_span.trace_id, span.trace_id)

version = aiobotocore.__version__.split(".")
pre_08 = int(version[0]) == 0 and int(version[1]) < 8
# Version 0.8+ generates only one span for reading an object.
if pre_08:
eq_(len(traces), 2)
eq_(len(traces[0]), 1)
eq_(len(traces[1]), 1)

span = traces[0][0]
eq_(span.get_tag('aws.operation'), 'GetObject')
eq_(span.get_tag('http.status_code'), '200')
eq_(span.service, 'aws.s3')
eq_(span.resource, 's3.getobject')

read_span = traces[1][0]
eq_(read_span.get_tag('aws.operation'), 'GetObject')
eq_(read_span.get_tag('http.status_code'), '200')
eq_(read_span.service, 'aws.s3')
eq_(read_span.resource, 's3.getobject')
eq_(read_span.name, 's3.command.read')
# enforce parenting
eq_(read_span.parent_id, span.span_id)
eq_(read_span.trace_id, span.trace_id)
else:
eq_(len(traces[0]), 1)
eq_(len(traces[0]), 1)

span = traces[0][0]
eq_(span.get_tag('aws.operation'), 'GetObject')
eq_(span.get_tag('http.status_code'), '200')
eq_(span.service, 'aws.s3')
eq_(span.resource, 's3.getobject')
eq_(span.name, 's3.command')
30 changes: 19 additions & 11 deletions tests/contrib/aiobotocore/test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# flake8: noqa
# DEV: Skip linting, we lint with Python 2, we'll get SyntaxErrors from `yield from`
import aiobotocore
from botocore.errorfactory import ClientError

from ddtrace.contrib.aiobotocore.patch import patch, unpatch
Expand Down Expand Up @@ -125,25 +126,32 @@ def test_s3_client_read(self):
yield from response['Body'].read()

traces = self.tracer.writer.pop_traces()
self.assertEqual(len(traces), 2)
version = aiobotocore.__version__.split(".")
pre_08 = int(version[0]) == 0 and int(version[1]) < 8
if pre_08:
self.assertEqual(len(traces), 2)
self.assertEqual(len(traces[1]), 1)
else:
self.assertEqual(len(traces), 1)

self.assertEqual(len(traces[0]), 1)
self.assertEqual(len(traces[1]), 1)

span = traces[0][0]
self.assertEqual(span.get_tag('aws.operation'), 'GetObject')
self.assertEqual(span.get_tag('http.status_code'), '200')
self.assertEqual(span.service, 'aws.s3')
self.assertEqual(span.resource, 's3.getobject')

read_span = traces[1][0]
self.assertEqual(read_span.get_tag('aws.operation'), 'GetObject')
self.assertEqual(read_span.get_tag('http.status_code'), '200')
self.assertEqual(read_span.service, 'aws.s3')
self.assertEqual(read_span.resource, 's3.getobject')
self.assertEqual(read_span.name, 's3.command.read')
# enforce parenting
self.assertEqual(read_span.parent_id, span.span_id)
self.assertEqual(read_span.trace_id, span.trace_id)
if pre_08:
read_span = traces[1][0]
self.assertEqual(read_span.get_tag('aws.operation'), 'GetObject')
self.assertEqual(read_span.get_tag('http.status_code'), '200')
self.assertEqual(read_span.service, 'aws.s3')
self.assertEqual(read_span.resource, 's3.getobject')
self.assertEqual(read_span.name, 's3.command.read')
# enforce parenting
self.assertEqual(read_span.parent_id, span.span_id)
self.assertEqual(read_span.trace_id, span.trace_id)

@mark_asyncio
def test_sqs_client(self):
Expand Down
9 changes: 8 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ envlist =
{py27,py34,py35,py36}-test_utils
{py27,py34,py35,py36}-test_logging
# Integrations environments
aiobotocore_contrib-{py34,py35,py36}-aiobotocore{02,03,04}
aiobotocore_contrib-py34-aiobotocore{02,03,04}
aiobotocore_contrib-{py35,py36}-aiobotocore{02,03,04,05,07,08,09,010}
aiohttp_contrib-{py34,py35,py36}-aiohttp{12,13,20,21,22}-aiohttp_jinja{012,013}-yarl
aiohttp_contrib-{py34,py35,py36}-aiohttp{23}-aiohttp_jinja{015}-yarl10
aiopg_contrib-{py34,py35,py36}-aiopg{012,015}
Expand Down Expand Up @@ -134,6 +135,12 @@ deps =
yarl: yarl==0.18.0
yarl10: yarl>=1.0,<1.1
# integrations
aiobotocore010: aiobotocore>=0.10,<0.11
aiobotocore09: aiobotocore>=0.9,<0.10
aiobotocore08: aiobotocore>=0.8,<0.9
aiobotocore07: aiobotocore>=0.7,<0.8
# aiobotocore06 does not work
aiobotocore05: aiobotocore>=0.5,<0.6
aiobotocore04: aiobotocore>=0.4,<0.5
aiobotocore03: aiobotocore>=0.3,<0.4
aiobotocore02: aiobotocore>=0.2,<0.3
Expand Down

0 comments on commit c5116b1

Please sign in to comment.