Skip to content

Commit 2eb60a9

Browse files
author
Emanuele Palazzetti
committed
Merge '0.12-dev' into 'master'
2 parents 8bc206c + b4ca38b commit 2eb60a9

File tree

109 files changed

+2175
-565
lines changed

Some content is hidden

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

109 files changed

+2175
-565
lines changed

.circleci/config.yml

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,26 @@ jobs:
6363
paths:
6464
- .tox
6565

66+
futures:
67+
docker:
68+
- image: datadog/docker-library:dd_trace_py_1_0_0
69+
steps:
70+
- checkout
71+
- restore_cache:
72+
keys:
73+
- tox-cache-futures-{{ checksum "tox.ini" }}
74+
- run: tox -e '{py27}-threading-futures{30,31,32}' --result-json /tmp/futures.1.results
75+
- run: tox -e '{py34,py35,py36}-threading' --result-json /tmp/futures.2.results
76+
- persist_to_workspace:
77+
root: /tmp
78+
paths:
79+
- futures.1.results
80+
- futures.2.results
81+
- save_cache:
82+
key: tox-cache-futures-{{ checksum "tox.ini" }}
83+
paths:
84+
- .tox
85+
6686
boto:
6787
docker:
6888
- image: datadog/docker-library:dd_trace_py_1_0_0
@@ -164,15 +184,13 @@ jobs:
164184
- restore_cache:
165185
keys:
166186
- tox-cache-tornado-{{ checksum "tox.ini" }}
167-
- run: tox -e '{py27}-tornado{40,41,42,43,44}' --result-json /tmp/tornado.1.results
168-
- run: tox -e '{py27}-tornado{40,41,42,43,44}-futures' --result-json /tmp/tornado.2.results
169-
- run: tox -e '{py34,py35,py36}-tornado{40,41,42,43,44}' --result-json /tmp/tornado.3.results
187+
- run: tox -e '{py27,py34,py35,py36}-tornado{40,41,42,43,44}' --result-json /tmp/tornado.1.results
188+
- run: tox -e '{py27}-tornado{40,41,42,43,44}-futures{30,31,32}' --result-json /tmp/tornado.2.results
170189
- persist_to_workspace:
171190
root: /tmp
172191
paths:
173192
- tornado.1.results
174193
- tornado.2.results
175-
- tornado.3.results
176194
- save_cache:
177195
key: tox-cache-tornado-{{ checksum "tox.ini" }}
178196
paths:
@@ -459,6 +477,31 @@ jobs:
459477
paths:
460478
- .tox
461479

480+
pymysql:
481+
docker:
482+
- image: datadog/docker-library:dd_trace_py_1_0_0
483+
- image: mysql:5.7
484+
env:
485+
- MYSQL_ROOT_PASSWORD=admin
486+
- MYSQL_PASSWORD=test
487+
- MYSQL_USER=test
488+
- MYSQL_DATABASE=test
489+
steps:
490+
- checkout
491+
- restore_cache:
492+
keys:
493+
- tox-cache-pymysql-{{ checksum "tox.ini" }}
494+
- run: tox -e 'wait' mysql
495+
- run: tox -e '{py27,py34,py35,py36}-pymysql{07,08}' --result-json /tmp/pymysql.results
496+
- persist_to_workspace:
497+
root: /tmp
498+
paths:
499+
- pymysql.results
500+
- save_cache:
501+
key: tox-cache-pymysql-{{ checksum "tox.ini" }}
502+
paths:
503+
- .tox
504+
462505
pylibmc:
463506
docker:
464507
- image: datadog/docker-library:dd_trace_py_1_0_0
@@ -744,6 +787,7 @@ workflows:
744787
- flake8
745788
- tracer
746789
- integration
790+
- futures
747791
- boto
748792
- ddtracerun
749793
- asyncio
@@ -762,6 +806,7 @@ workflows:
762806
- mysqlconnector
763807
- mysqlpython
764808
- mysqldb
809+
- pymysql
765810
- pylibmc
766811
- pymongo
767812
- pyramid
@@ -778,6 +823,7 @@ workflows:
778823
- flake8
779824
- tracer
780825
- integration
826+
- futures
781827
- boto
782828
- ddtracerun
783829
- asyncio
@@ -796,6 +842,7 @@ workflows:
796842
- mysqlconnector
797843
- mysqlpython
798844
- mysqldb
845+
- pymysql
799846
- pylibmc
800847
- pymongo
801848
- pyramid

ddtrace/__init__.py

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

6-
__version__ = '0.11.1'
7+
__version__ = '0.12.0'
78

8-
# a global tracer instance
9+
# a global tracer instance with integration settings
910
tracer = Tracer()
11+
config = Config()
1012

1113
__all__ = [
1214
'patch',
@@ -15,4 +17,5 @@
1517
'Span',
1618
'tracer',
1719
'Tracer',
20+
'config',
1821
]

ddtrace/bootstrap/sitecustomize.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
"""
55

66
import os
7+
import imp
8+
import sys
79
import logging
810

9-
from ddtrace.util import asbool
11+
from ddtrace.utils.formats import asbool
1012

1113

1214
debug = os.environ.get("DATADOG_TRACE_DEBUG")
@@ -46,6 +48,8 @@ def update_patched_modules():
4648
patch = True
4749

4850
# Respect DATADOG_* environment variables in global tracer configuration
51+
# TODO: these variables are deprecated; use utils method and update our documentation
52+
# correct prefix should be DD_*
4953
enabled = os.environ.get("DATADOG_TRACE_ENABLED")
5054
hostname = os.environ.get("DATADOG_TRACE_AGENT_HOSTNAME")
5155
port = os.environ.get("DATADOG_TRACE_AGENT_PORT")
@@ -76,5 +80,24 @@ def update_patched_modules():
7680

7781
if 'DATADOG_ENV' in os.environ:
7882
tracer.set_tags({"env": os.environ["DATADOG_ENV"]})
83+
84+
# Ensure sitecustomize.py is properly called if available in application directories:
85+
# * exclude `bootstrap_dir` from the search
86+
# * find a user `sitecustomize.py` module
87+
# * import that module via `imp`
88+
bootstrap_dir = os.path.dirname(__file__)
89+
path = list(sys.path)
90+
path.remove(bootstrap_dir)
91+
92+
try:
93+
(f, path, description) = imp.find_module('sitecustomize', path)
94+
except ImportError:
95+
pass
96+
else:
97+
# `sitecustomize.py` found, load it
98+
log.debug('sitecustomize from user found in: %s', path)
99+
imp.load_module('sitecustomize', f, path, description)
100+
101+
79102
except Exception as e:
80103
log.warn("error configuring Datadog tracing", exc_info=True)

ddtrace/compat.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
from io import StringIO
2727

2828
try:
29-
import urlparse
29+
import urlparse as parse
3030
except ImportError:
31-
from urllib import parse as urlparse
31+
from urllib import parse
3232

3333
try:
3434
from asyncio import iscoroutinefunction
@@ -88,5 +88,5 @@ def to_unicode(s):
8888
'stringify',
8989
'StringIO',
9090
'urlencode',
91-
'urlparse',
91+
'parse',
9292
]

ddtrace/contrib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .util import func_name, module_name, require_modules # noqa
1+
from ..utils.importlib import func_name, module_name, require_modules # noqa

ddtrace/contrib/aiobotocore/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# This query generates a trace
1919
lambda_client.list_functions()
2020
"""
21-
from ..util import require_modules
21+
from ...utils.importlib import require_modules
2222

2323

2424
required_modules = ['aiobotocore.client']

ddtrace/contrib/aiobotocore/patch.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
import wrapt
33
import aiobotocore.client
44

5-
from ddtrace import Pin
6-
from ddtrace.util import deep_getattr, unwrap
7-
85
from aiobotocore.endpoint import ClientResponseContentProxy
96

7+
from ...pin import Pin
108
from ...ext import http, aws
119
from ...compat import PYTHON_VERSION_INFO
10+
from ...utils.formats import deep_getattr
11+
from ...utils.wrappers import unwrap
1212

1313

1414
ARGS_NAME = ('action', 'params', 'path', 'verb')

ddtrace/contrib/aiohttp/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async def home_handler(request):
4444
ctx = request['datadog_context']
4545
# do something with the tracing Context
4646
"""
47-
from ..util import require_modules
47+
from ...utils.importlib import require_modules
4848

4949
required_modules = ['aiohttp']
5050

ddtrace/contrib/aiohttp/patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import wrapt
22

33
from ...pin import Pin
4-
from ddtrace.util import unwrap
4+
from ...utils.wrappers import unwrap
55

66

77
try:

ddtrace/contrib/aiopg/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# Use a pin to specify metadata related to this connection
1616
Pin.override(db, service='postgres-users')
1717
"""
18-
from ..util import require_modules
18+
from ...utils.importlib import require_modules
1919

2020

2121
required_modules = ['aiopg']

0 commit comments

Comments
 (0)