Skip to content

Commit 8fb4ebd

Browse files
authored
Merge branch '0.24-dev' into fix-aiohttp-test-race
2 parents b5ba9d1 + 364b626 commit 8fb4ebd

File tree

5 files changed

+31
-33
lines changed

5 files changed

+31
-33
lines changed

.circleci/config.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,13 +253,11 @@ jobs:
253253
steps:
254254
- checkout
255255
- *restore_cache_step
256-
- run: tox -e 'aiohttp_contrib-{py34,py35,py36}-aiohttp{12,13,20,21,22}-aiohttp_jinja{012,013}-yarl' --result-json /tmp/aiohttp.1.results
257-
- run: tox -e 'aiohttp_contrib-{py34,py35,py36}-aiohttp{23}-aiohttp_jinja{015}-yarl10' --result-json /tmp/aiohttp.2.results
256+
- run: tox -e 'aiohttp_contrib-{py34,py35,py36}-aiohttp{12,13,20,21,22}-aiohttp_jinja{012,013}-yarl,aiohttp_contrib-{py34,py35,py36}-aiohttp23-aiohttp_jinja015-yarl10,aiohttp_contrib-{py35,py36}-aiohttp{30,31,32,33,34,35}-aiohttp_jinja015-yarl10' --result-json /tmp/aiohttp.results
258257
- persist_to_workspace:
259258
root: /tmp
260259
paths:
261-
- aiohttp.1.results
262-
- aiohttp.2.results
260+
- aiohttp.results
263261
- *save_cache_step
264262

265263
tornado:

ddtrace/sampler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(self, sample_rate=1):
3838

3939
self.set_sample_rate(sample_rate)
4040

41-
log.info("initialized RateSampler, sample %s%% of traces", 100 * sample_rate)
41+
log.debug("initialized RateSampler, sample %s%% of traces", 100 * sample_rate)
4242

4343
def set_sample_rate(self, sample_rate):
4444
self.sample_rate = sample_rate

tests/contrib/aiohttp/app/web.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def delayed_handler(request):
9494

9595
@asyncio.coroutine
9696
def noop_middleware(app, handler):
97+
@asyncio.coroutine
9798
def middleware_handler(request):
9899
# noop middleware
99100
response = yield from handler(request)

tests/opentracer/test_tracer_asyncio.py

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,34 @@
88
from ddtrace.opentracer.utils import get_context_provider_for_scope_manager
99

1010
from tests.contrib.asyncio.utils import AsyncioTestCase, mark_asyncio
11-
from .conftest import dd_tracer, ot_tracer_factory, writer
11+
from .conftest import ot_tracer_factory
1212

1313

1414
@pytest.fixture()
15-
def ot_tracer(ot_tracer_factory):
16-
return ot_tracer_factory(
15+
def ot_tracer(request, ot_tracer_factory):
16+
# use the dummy asyncio ot tracer
17+
request.instance.ot_tracer = ot_tracer_factory(
1718
"asyncio_svc",
1819
config={},
1920
scope_manager=AsyncioScopeManager(),
2021
context_provider=ddtrace.contrib.asyncio.context_provider,
2122
)
23+
request.instance.ot_writer = request.instance.ot_tracer._dd_tracer.writer
24+
request.instance.dd_tracer = request.instance.ot_tracer._dd_tracer
2225

23-
26+
@pytest.mark.usefixtures("ot_tracer")
2427
class TestTracerAsyncio(AsyncioTestCase):
25-
def setUp(self):
26-
super(TestTracerAsyncio, self).setUp()
27-
28-
# use the dummy asyncio ot tracer
29-
self.tracer = ot_tracer(ot_tracer_factory())
30-
self.writer = writer(self.tracer)
3128

3229
def reset(self):
33-
self.writer.pop_traces()
30+
self.ot_writer.pop_traces()
3431

3532
@mark_asyncio
3633
def test_trace_coroutine(self):
3734
# it should use the task context when invoked in a coroutine
38-
with self.tracer.start_span("coroutine"):
35+
with self.ot_tracer.start_span("coroutine"):
3936
pass
4037

41-
traces = self.writer.pop_traces()
38+
traces = self.ot_writer.pop_traces()
4239

4340
assert len(traces) == 1
4441
assert len(traces[0]) == 1
@@ -51,16 +48,16 @@ def test_trace_multiple_coroutines(self):
5148
@asyncio.coroutine
5249
def coro():
5350
# another traced coroutine
54-
with self.tracer.start_active_span("coroutine_2"):
51+
with self.ot_tracer.start_active_span("coroutine_2"):
5552
return 42
5653

57-
with self.tracer.start_active_span("coroutine_1"):
54+
with self.ot_tracer.start_active_span("coroutine_1"):
5855
value = yield from coro()
5956

6057
# the coroutine has been called correctly
6158
assert value == 42
6259
# a single trace has been properly reported
63-
traces = self.writer.pop_traces()
60+
traces = self.ot_writer.pop_traces()
6461
assert len(traces) == 1
6562
assert len(traces[0]) == 2
6663
assert traces[0][0].name == "coroutine_1"
@@ -73,13 +70,13 @@ def coro():
7370
def test_exception(self):
7471
@asyncio.coroutine
7572
def f1():
76-
with self.tracer.start_span("f1"):
73+
with self.ot_tracer.start_span("f1"):
7774
raise Exception("f1 error")
7875

7976
with pytest.raises(Exception):
8077
yield from f1()
8178

82-
traces = self.writer.pop_traces()
79+
traces = self.ot_writer.pop_traces()
8380
assert len(traces) == 1
8481
spans = traces[0]
8582
assert len(spans) == 1
@@ -95,29 +92,24 @@ def test_trace_multiple_calls(self):
9592
@asyncio.coroutine
9693
def coro():
9794
# another traced coroutine
98-
with self.tracer.start_span("coroutine"):
95+
with self.ot_tracer.start_span("coroutine"):
9996
yield from asyncio.sleep(0.01)
10097

10198
futures = [asyncio.ensure_future(coro()) for x in range(10)]
10299
for future in futures:
103100
yield from future
104101

105-
traces = self.writer.pop_traces()
102+
traces = self.ot_writer.pop_traces()
106103

107104
assert len(traces) == 10
108105
assert len(traces[0]) == 1
109106
assert traces[0][0].name == "coroutine"
110107

111108

109+
@pytest.mark.usefixtures("ot_tracer")
112110
class TestTracerAsyncioCompatibility(AsyncioTestCase):
113111
"""Ensure the opentracer works in tandem with the ddtracer and asyncio."""
114112

115-
def setUp(self):
116-
super(TestTracerAsyncioCompatibility, self).setUp()
117-
self.ot_tracer = ot_tracer(ot_tracer_factory())
118-
self.dd_tracer = dd_tracer(self.ot_tracer)
119-
self.writer = writer(self.ot_tracer)
120-
121113
@mark_asyncio
122114
def test_trace_multiple_coroutines_ot_dd(self):
123115
"""

tox.ini

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ envlist =
3838
aiobotocore_contrib-py34-aiobotocore{02,03,04}
3939
aiobotocore_contrib-{py35,py36}-aiobotocore{02,03,04,05,07,08,09,010}
4040
aiohttp_contrib-{py34,py35,py36}-aiohttp{12,13,20,21,22}-aiohttp_jinja{012,013}-yarl
41-
aiohttp_contrib-{py34,py35,py36}-aiohttp{23}-aiohttp_jinja{015}-yarl10
41+
aiohttp_contrib-{py34,py35,py36}-aiohttp23-aiohttp_jinja{015}-yarl10
42+
aiohttp_contrib-{py35,py36}-aiohttp{30,31,32,33,34,35}-aiohttp_jinja{015}-yarl10
4243
aiopg_contrib-{py34,py35,py36}-aiopg{012,015}
4344
asyncio_contrib-{py34,py35,py36}
4445
boto_contrib-{py27,py34}-boto
@@ -127,7 +128,7 @@ deps =
127128
# distribution build.
128129
!ddtracerun: wrapt
129130
!msgpack03-!msgpack04-!msgpack05-!ddtracerun: msgpack-python
130-
pytest>=3.0.0,<4.0.0
131+
pytest>=3
131132
opentracing
132133
# test dependencies installed in all envs
133134
mock
@@ -156,6 +157,12 @@ deps =
156157
aiohttp21: aiohttp>=2.1,<2.2
157158
aiohttp22: aiohttp>=2.2,<2.3
158159
aiohttp23: aiohttp>=2.3,<2.4
160+
aiohttp30: aiohttp>=3.0,<3.1
161+
aiohttp31: aiohttp>=3.1,<3.2
162+
aiohttp32: aiohttp>=3.2,<3.3
163+
aiohttp33: aiohttp>=3.3,<3.4
164+
aiohttp34: aiohttp>=3.4,<3.5
165+
aiohttp35: aiohttp>=3.5,<3.6
159166
aiohttp_jinja012: aiohttp_jinja2>=0.12,<0.13
160167
aiohttp_jinja013: aiohttp_jinja2>=0.13,<0.14
161168
aiohttp_jinja015: aiohttp_jinja2>=0.15,<0.16

0 commit comments

Comments
 (0)