Skip to content

Commit 4e5acbd

Browse files
authored
Merge pull request #704 from DataDog/0.16-dev
v0.16.0
2 parents 7db12f1 + 7b53dcf commit 4e5acbd

Some content is hidden

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

83 files changed

+5324
-539
lines changed

.circleci/config.yml

Lines changed: 88 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,23 @@ jobs:
143143
TOX_SKIP_DIST: False
144144
steps:
145145
- checkout
146-
- *restore_cache_step
147146
- run: tox -e '{py27,py34,py35,py36}-ddtracerun' --result-json /tmp/ddtracerun.results
148147
- persist_to_workspace:
149148
root: /tmp
150149
paths:
151150
- ddtracerun.results
151+
152+
test_utils:
153+
docker:
154+
- *test_runner
155+
steps:
156+
- checkout
157+
- *restore_cache_step
158+
- run: tox -e '{py27,py34,py35,py36}-test_utils' --result-json /tmp/test_utils.results
159+
- persist_to_workspace:
160+
root: /tmp
161+
paths:
162+
- test_utils.results
152163
- *save_cache_step
153164

154165
asyncio:
@@ -213,13 +224,11 @@ jobs:
213224
steps:
214225
- checkout
215226
- *restore_cache_step
216-
- run: tox -e 'bottle_contrib-{py27,py34,py35,py36}-bottle{11,12}-webtest' --result-json /tmp/bottle.1.results
217-
- run: TOX_SKIP_DIST=False tox -e 'bottle_contrib_autopatch-{py27,py34,py35,py36}-bottle{11,12}-webtest' --result-json /tmp/bottle.2.results
227+
- run: tox -e 'bottle_contrib{,_autopatch}-{py27,py34,py35,py36}-bottle{11,12}-webtest' --result-json /tmp/bottle.results
218228
- persist_to_workspace:
219229
root: /tmp
220230
paths:
221-
- bottle.1.results
222-
- bottle.2.results
231+
- bottle.results
223232
- *save_cache_step
224233

225234
cassandra:
@@ -245,12 +254,14 @@ jobs:
245254

246255
celery:
247256
docker:
248-
- *test_runner
257+
- <<: *test_runner
258+
env:
259+
TOX_SKIP_DIST: False
249260
- image: redis:3.2-alpine
250261
steps:
251262
- checkout
252263
- *restore_cache_step
253-
- run: TOX_SKIP_DIST=False tox -e 'celery_contrib-{py27,py34,py35,py36}-celery{31,40,41,42}-redis{210}' --result-json /tmp/celery.results
264+
- run: tox -e 'celery_contrib-{py27,py34,py35,py36}-celery{31,40,41,42}-redis{210}' --result-json /tmp/celery.results
254265
- persist_to_workspace:
255266
root: /tmp
256267
paths:
@@ -264,7 +275,7 @@ jobs:
264275
steps:
265276
- checkout
266277
- *restore_cache_step
267-
- run: TOX_SKIP_DIST=False tox -e 'elasticsearch_contrib-{py27,py34,py35,py36}-elasticsearch{16,17,18,23,24,51,52,53,54,63}' --result-json /tmp/elasticsearch.results
278+
- run: tox -e 'elasticsearch_contrib-{py27,py34,py35,py36}-elasticsearch{16,17,18,23,24,51,52,53,54,63}' --result-json /tmp/elasticsearch.results
268279
- persist_to_workspace:
269280
root: /tmp
270281
paths:
@@ -277,13 +288,11 @@ jobs:
277288
steps:
278289
- checkout
279290
- *restore_cache_step
280-
- run: tox -e 'falcon_contrib-{py27,py34,py35,py36}-falcon{10,11,12,13,14}' --result-json /tmp/falcon.1.results
281-
- run: TOX_SKIP_DIST=False tox -e 'falcon_contrib_autopatch-{py27,py34,py35,py36}-falcon{10,11,12,13,14}' --result-json /tmp/falcon.2.results
291+
- run: tox -e 'falcon_contrib{,_autopatch}-{py27,py34,py35,py36}-falcon{10,11,12,13,14}' --result-json /tmp/falcon.results
282292
- persist_to_workspace:
283293
root: /tmp
284294
paths:
285-
- falcon.1.results
286-
- falcon.2.results
295+
- falcon.results
287296
- *save_cache_step
288297

289298
django:
@@ -299,21 +308,17 @@ jobs:
299308
steps:
300309
- checkout
301310
- *restore_cache_step
302-
- run: tox -e 'django_contrib-{py27,py34,py35,py36}-django{18,111}-djangopylibmc06-djangoredis45-pylibmc-redis{210}-memcached' --result-json /tmp/django.1.results
303-
- run: TOX_SKIP_DIST=False tox -e 'django_contrib_autopatch-{py27,py34,py35,py36}-django{18,111}-djangopylibmc06-djangoredis45-pylibmc-redis{210}-memcached' --result-json /tmp/django.2.results
304-
- run: tox -e 'django_drf_contrib-{py27,py34,py35,py36}-django{111}-djangorestframework{34,37,38}' --result-json /tmp/django.3.results
305-
- run: tox -e 'django_contrib-{py34,py35,py36}-django{200}-djangopylibmc06-djangoredis45-pylibmc-redis{210}-memcached' --result-json /tmp/django.4.results
306-
- run: TOX_SKIP_DIST=False tox -e 'django_contrib_autopatch-{py34,py35,py36}-django{200}-djangopylibmc06-djangoredis45-pylibmc-redis{210}-memcached' --result-json /tmp/django.5.results
307-
- run: tox -e 'django_drf_contrib-{py34,py35,py36}-django{200}-djangorestframework{37,38}' --result-json /tmp/django.6.results
311+
- run: tox -e 'django_contrib{,_autopatch}-{py27,py34,py35,py36}-django{18,111}-djangopylibmc06-djangoredis45-pylibmc-redis{210}-memcached' --result-json /tmp/django.1.results
312+
- run: tox -e 'django_drf_contrib-{py27,py34,py35,py36}-django{111}-djangorestframework{34,37,38}' --result-json /tmp/django.2.results
313+
- run: tox -e 'django_contrib{,_autopatch}-{py34,py35,py36}-django{200}-djangopylibmc06-djangoredis45-pylibmc-redis{210}-memcached' --result-json /tmp/django.3.results
314+
- run: tox -e 'django_drf_contrib-{py34,py35,py36}-django{200}-djangorestframework{37,38}' --result-json /tmp/django.4.results
308315
- persist_to_workspace:
309316
root: /tmp
310317
paths:
311318
- django.1.results
312319
- django.2.results
313320
- django.3.results
314321
- django.4.results
315-
- django.5.results
316-
- django.6.results
317322
- *save_cache_step
318323

319324
flask:
@@ -326,10 +331,12 @@ jobs:
326331
- *restore_cache_step
327332
- run: tox -e 'flask_contrib-{py27,py34,py35,py36}-flask{010,011,012,10}-blinker' --result-json /tmp/flask.1.results
328333
- run: TOX_SKIP_DIST=False tox -e 'flask_contrib_autopatch-{py27,py34,py35,py36}-flask{010,011,012,10}-blinker' --result-json /tmp/flask.2.results
329-
- run: tox -e 'flask_cache_contrib-{py27,py34,py35,py36}-flask{010,011,012}-flaskcache{013}-memcached-redis{210}-blinker' --result-json /tmp/flask.3.results
330-
- run: TOX_SKIP_DIST=False tox -e 'flask_cache_contrib_autopatch-{py27,py34,py35,py36}-flask{010,011,012}-flaskcache{013}-memcached-redis{210}-blinker' --result-json /tmp/flask.4.results
331-
- run: tox -e 'flask_cache_contrib-{py27}-flask{010,011}-flaskcache{012}-memcached-redis{210}-blinker' --result-json /tmp/flask.5.results
332-
- run: TOX_SKIP_DIST=False tox -e 'flask_cache_contrib_autopatch-{py27}-flask{010,011}-flaskcache{012}-memcached-redis{210}-blinker' --result-json /tmp/flask.6.results
334+
- run: tox -e 'flask_contrib-{py27}-flask{09}-blinker' --result-json /tmp/flask.3.results
335+
- run: TOX_SKIP_DIST=False tox -e 'flask_contrib_autopatch-{py27}-flask{09}-blinker' --result-json /tmp/flask.4.results
336+
- run: tox -e 'flask_cache_contrib-{py27,py34,py35,py36}-flask{010,011,012}-flaskcache{013}-memcached-redis{210}-blinker' --result-json /tmp/flask.5.results
337+
- run: TOX_SKIP_DIST=False tox -e 'flask_cache_contrib_autopatch-{py27,py34,py35,py36}-flask{010,011,012}-flaskcache{013}-memcached-redis{210}-blinker' --result-json /tmp/flask.6.results
338+
- run: tox -e 'flask_cache_contrib-{py27}-flask{010,011}-flaskcache{012}-memcached-redis{210}-blinker' --result-json /tmp/flask.7.results
339+
- run: TOX_SKIP_DIST=False tox -e 'flask_cache_contrib_autopatch-{py27}-flask{010,011}-flaskcache{012}-memcached-redis{210}-blinker' --result-json /tmp/flask.8.results
333340
- persist_to_workspace:
334341
root: /tmp
335342
paths:
@@ -339,6 +346,8 @@ jobs:
339346
- flask.4.results
340347
- flask.5.results
341348
- flask.6.results
349+
- flask.7.results
350+
- flask.8.results
342351
- *save_cache_step
343352

344353
gevent:
@@ -347,7 +356,7 @@ jobs:
347356
steps:
348357
- checkout
349358
- *restore_cache_step
350-
- run: tox -e 'gevent_contrib-{py27,py34,py35,py36}-gevent{11,12}' --result-json /tmp/gevent.1.results
359+
- run: tox -e 'gevent_contrib-{py27,py34,py35,py36}-gevent{11,12,13}' --result-json /tmp/gevent.1.results
351360
- run: tox -e 'gevent_contrib-{py27}-gevent{10}' --result-json /tmp/gevent.2.results
352361
- persist_to_workspace:
353362
root: /tmp
@@ -369,6 +378,19 @@ jobs:
369378
- httplib.results
370379
- *save_cache_step
371380

381+
grpc:
382+
docker:
383+
- *test_runner
384+
steps:
385+
- checkout
386+
- *restore_cache_step
387+
- run: tox -e 'grpc_contrib-{py27,py34,py35,py36}-grpc' --result-json /tmp/grpc.results
388+
- persist_to_workspace:
389+
root: /tmp
390+
paths:
391+
- grpc.results
392+
- *save_cache_step
393+
372394
mysqlconnector:
373395
docker:
374396
- *test_runner
@@ -470,13 +492,11 @@ jobs:
470492
steps:
471493
- checkout
472494
- *restore_cache_step
473-
- run: tox -e 'pymemcache_contrib-{py27,py34,py35,py36}-pymemcache{130,140}' --result-json /tmp/pymemcache.1.results
474-
- run: TOX_SKIP_DIST=False tox -e 'pymemcache_contrib_autopatch-{py27,py34,py35,py36}-pymemcache{130,140}' --result-json /tmp/pymemcache.2.results
495+
- run: tox -e 'pymemcache_contrib{,_autopatch}-{py27,py34,py35,py36}-pymemcache{130,140}' --result-json /tmp/pymemcache.results
475496
- persist_to_workspace:
476497
root: /tmp
477498
paths:
478-
- pymemcache.1.results
479-
- pymemcache.2.results
499+
- pymemcache.results
480500
- *save_cache_step
481501

482502
mongoengine:
@@ -513,13 +533,11 @@ jobs:
513533
steps:
514534
- checkout
515535
- *restore_cache_step
516-
- run: tox -e 'pyramid_contrib-{py27,py34,py35,py36}-pyramid{17,18,19}-webtest' --result-json /tmp/pyramid.1.results
517-
- run: TOX_SKIP_DIST=False tox -e 'pyramid_contrib_autopatch-{py27,py34,py35,py36}-pyramid{17,18,19}-webtest' --result-json /tmp/pyramid.2.results
536+
- run: tox -e 'pyramid_contrib{,_autopatch}-{py27,py34,py35,py36}-pyramid{17,18,19}-webtest' --result-json /tmp/pyramid.results
518537
- persist_to_workspace:
519538
root: /tmp
520539
paths:
521-
- pyramid.1.results
522-
- pyramid.2.results
540+
- pyramid.results
523541
- *save_cache_step
524542

525543
requests:
@@ -529,7 +547,7 @@ jobs:
529547
steps:
530548
- checkout
531549
- *restore_cache_step
532-
- run: tox -e 'requests_contrib-{py27,py34,py35,py36}-requests{208,209,210,211,212,213,219}' --result-json /tmp/requests.results
550+
- run: tox -e 'requests_contrib{,_autopatch}-{py27,py34,py35,py36}-requests{208,209,210,211,212,213,219}' --result-json /tmp/requests.results
533551
- persist_to_workspace:
534552
root: /tmp
535553
paths:
@@ -677,6 +695,21 @@ jobs:
677695
- vertica.results
678696
- *save_cache_step
679697

698+
kombu:
699+
docker:
700+
- *test_runner
701+
- image: rabbitmq:3.7-alpine
702+
steps:
703+
- checkout
704+
- *restore_cache_step
705+
- run: tox -e wait rabbitmq
706+
- run: tox -e 'kombu_contrib-{py27,py34,py35,py36}-kombu{40,41,42}' --result-json /tmp/kombu.results
707+
- persist_to_workspace:
708+
root: /tmp
709+
paths:
710+
- kombu.results
711+
- *save_cache_step
712+
680713
sqlite3:
681714
docker:
682715
- *test_runner
@@ -724,6 +757,19 @@ jobs:
724757
- run: sudo pip install mkwheelhouse sphinx awscli wrapt
725758
- run: VERSION_SUFFIX=$CIRCLE_BRANCH$CIRCLE_BUILD_NUM S3_DIR=trace-dev rake release:wheel
726759

760+
jinja2:
761+
docker:
762+
- *test_runner
763+
steps:
764+
- checkout
765+
- *restore_cache_step
766+
- run: tox -e 'jinja2_contrib-{py27,py34,py35,py36}-jinja{27,28,29,210}' --result-json /tmp/jinja2.results
767+
- persist_to_workspace:
768+
root: /tmp
769+
paths:
770+
- jinja2.results
771+
- *save_cache_step
772+
727773
build_docs:
728774
# deploy official documentation
729775
docker:
@@ -797,6 +843,7 @@ workflows:
797843
- futures
798844
- boto
799845
- ddtracerun
846+
- test_utils
800847
- asyncio
801848
- pylons
802849
- aiohttp
@@ -810,6 +857,7 @@ workflows:
810857
- flask
811858
- gevent
812859
- httplib
860+
- grpc
813861
- mongoengine
814862
- mysqlconnector
815863
- mysqlpython
@@ -827,9 +875,11 @@ workflows:
827875
- aiopg
828876
- redis
829877
- rediscluster
878+
- kombu
830879
- sqlite3
831880
- msgpack
832881
- vertica
882+
- jinja2
833883
- build_docs
834884
- wait_all_tests:
835885
requires:
@@ -840,6 +890,7 @@ workflows:
840890
- futures
841891
- boto
842892
- ddtracerun
893+
- test_utils
843894
- asyncio
844895
- pylons
845896
- aiohttp
@@ -852,6 +903,7 @@ workflows:
852903
- django
853904
- flask
854905
- gevent
906+
- grpc
855907
- httplib
856908
- mongoengine
857909
- mysqlconnector
@@ -870,9 +922,11 @@ workflows:
870922
- aiopg
871923
- redis
872924
- rediscluster
925+
- kombu
873926
- sqlite3
874927
- msgpack
875928
- vertica
929+
- jinja2
876930
- build_docs
877931
- deploy_dev:
878932
requires:

ddtrace/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
from .pin import Pin
33
from .span import Span
44
from .tracer import Tracer
5-
from .settings import Config
5+
from .settings import config
66

7-
__version__ = '0.15.0'
7+
__version__ = '0.16.0'
88

99
# a global tracer instance with integration settings
1010
tracer = Tracer()
11-
config = Config()
1211

1312
__all__ = [
1413
'patch',

ddtrace/compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import sys
21
import platform
2+
import sys
33

44
PYTHON_VERSION_INFO = sys.version_info
55
PY2 = sys.version_info[0] == 2

ddtrace/context.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import threading
33

44
from .constants import SAMPLING_PRIORITY_KEY
5-
5+
from .utils.formats import asbool, get_env
66

77
log = logging.getLogger(__name__)
88

@@ -22,6 +22,9 @@ class Context(object):
2222
2323
This data structure is thread-safe.
2424
"""
25+
_partial_flush_enabled = asbool(get_env('tracer', 'partial_flush_enabled', 'false'))
26+
_partial_flush_min_spans = int(get_env('tracer', 'partial_flush_min_spans', 500))
27+
2528
def __init__(self, trace_id=None, span_id=None, sampled=True, sampling_priority=None):
2629
"""
2730
Initialize a new thread-safe ``Context``.
@@ -190,6 +193,31 @@ def get(self):
190193
self._sampling_priority = None
191194
self._sampled = True
192195
return trace, sampled
196+
197+
elif self._partial_flush_enabled and self._finished_spans >= self._partial_flush_min_spans:
198+
# partial flush when enabled and we have more than the minimal required spans
199+
trace = self._trace
200+
sampled = self._sampled
201+
sampling_priority = self._sampling_priority
202+
# attach the sampling priority to the context root span
203+
if sampled and sampling_priority is not None and trace:
204+
trace[0].set_metric(SAMPLING_PRIORITY_KEY, sampling_priority)
205+
206+
# Any open spans will remain as `self._trace`
207+
# Any finished spans will get returned to be flushed
208+
opened_spans = []
209+
closed_spans = []
210+
for span in trace:
211+
if span._finished:
212+
closed_spans.append(span)
213+
else:
214+
opened_spans.append(span)
215+
216+
# Update trace spans and stats
217+
self._trace = opened_spans
218+
self._finished_spans = 0
219+
220+
return closed_spans, sampled
193221
else:
194222
return None, None
195223

ddtrace/contrib/bottle/trace.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
# project
99
from ...propagation.http import HTTPPropagator
1010

11+
SPAN_TYPE = 'web'
12+
1113
class TracePlugin(object):
1214
name = 'trace'
1315
api = 2
@@ -37,7 +39,7 @@ def wrapped(*args, **kwargs):
3739
if context.trace_id:
3840
self.tracer.context_provider.activate(context)
3941

40-
with self.tracer.trace('bottle.request', service=self.service, resource=resource) as s:
42+
with self.tracer.trace('bottle.request', service=self.service, resource=resource, span_type=SPAN_TYPE) as s:
4143
code = 0
4244
try:
4345
return callback(*args, **kwargs)

0 commit comments

Comments
 (0)