Skip to content

Commit 7b34bb8

Browse files
authored
Merge pull request #835 from DataDog/0.22-dev
Release 0.22.0
2 parents 64e15f5 + 7c933d9 commit 7b34bb8

Some content is hidden

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

82 files changed

+6000
-125
lines changed

ddtrace/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from .tracer import Tracer
55
from .settings import config
66

7-
__version__ = '0.21.1'
7+
__version__ = '0.22.0'
88

99
# a global tracer instance with integration settings
1010
tracer = Tracer()

ddtrace/compat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sys
33
import textwrap
44

5-
import six
5+
from ddtrace.vendor import six
66

77
__all__ = [
88
'httplib',

ddtrace/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
FILTERS_KEY = 'FILTERS'
22
SAMPLE_RATE_METRIC_KEY = '_sample_rate'
33
SAMPLING_PRIORITY_KEY = '_sampling_priority_v1'
4+
ORIGIN_KEY = '_dd.origin'
45
EVENT_SAMPLE_RATE_KEY = '_dd1.sr.eausr'
56

67
NUMERIC_TAGS = (EVENT_SAMPLE_RATE_KEY, )

ddtrace/context.py

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

4-
from .constants import SAMPLING_PRIORITY_KEY
4+
from .constants import SAMPLING_PRIORITY_KEY, ORIGIN_KEY
55
from .utils.formats import asbool, get_env
66

77
log = logging.getLogger(__name__)
@@ -25,7 +25,7 @@ class Context(object):
2525
_partial_flush_enabled = asbool(get_env('tracer', 'partial_flush_enabled', 'false'))
2626
_partial_flush_min_spans = int(get_env('tracer', 'partial_flush_min_spans', 500))
2727

28-
def __init__(self, trace_id=None, span_id=None, sampled=True, sampling_priority=None):
28+
def __init__(self, trace_id=None, span_id=None, sampled=True, sampling_priority=None, _dd_origin=None):
2929
"""
3030
Initialize a new thread-safe ``Context``.
3131
@@ -41,6 +41,7 @@ def __init__(self, trace_id=None, span_id=None, sampled=True, sampling_priority=
4141
self._parent_span_id = span_id
4242
self._sampled = sampled
4343
self._sampling_priority = sampling_priority
44+
self._dd_origin = _dd_origin
4445

4546
@property
4647
def trace_id(self):
@@ -184,6 +185,10 @@ def get(self):
184185
# attach the sampling priority to the context root span
185186
if sampled and sampling_priority is not None and trace:
186187
trace[0].set_metric(SAMPLING_PRIORITY_KEY, sampling_priority)
188+
origin = self._dd_origin
189+
# attach the origin to the root span tag
190+
if sampled and origin is not None and trace:
191+
trace[0].set_tag(ORIGIN_KEY, origin)
187192

188193
# clean the current state
189194
self._trace = []
@@ -202,6 +207,10 @@ def get(self):
202207
# attach the sampling priority to the context root span
203208
if sampled and sampling_priority is not None and trace:
204209
trace[0].set_metric(SAMPLING_PRIORITY_KEY, sampling_priority)
210+
origin = self._dd_origin
211+
# attach the origin to the root span tag
212+
if sampled and origin is not None and trace:
213+
trace[0].set_tag(ORIGIN_KEY, origin)
205214

206215
# Any open spans will remain as `self._trace`
207216
# Any finished spans will get returned to be flushed

ddtrace/contrib/aiobotocore/patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import asyncio
2-
import wrapt
2+
from ddtrace.vendor import wrapt
33
import aiobotocore.client
44

55
from aiobotocore.endpoint import ClientResponseContentProxy

ddtrace/contrib/aiohttp/patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import wrapt
1+
from ddtrace.vendor import wrapt
22

33
from ...pin import Pin
44
from ...utils.wrappers import unwrap

ddtrace/contrib/aiopg/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import asyncio
2-
import wrapt
2+
from ddtrace.vendor import wrapt
33

44
from aiopg.utils import _ContextManager
55

ddtrace/contrib/aiopg/patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import aiopg.connection
55
import psycopg2.extensions
6-
import wrapt
6+
from ddtrace.vendor import wrapt
77

88
from .connection import AIOTracedConnection
99
from ..psycopg.patch import _patch_extensions, \

ddtrace/contrib/asyncio/patch.py

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

3-
from wrapt import wrap_function_wrapper as _w
3+
from ddtrace.vendor.wrapt import wrap_function_wrapper as _w
44

55
from .helpers import _wrapped_create_task
66
from ...utils.wrappers import unwrap as _u

ddtrace/contrib/boto/patch.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import boto.connection
2-
import wrapt
2+
from ddtrace.vendor import wrapt
33
import inspect
44

55
from ...pin import Pin
@@ -105,10 +105,15 @@ def patched_auth_request(original_func, instance, args, kwargs):
105105

106106
# Catching the name of the operation that called make_request()
107107
operation_name = None
108+
109+
# Go up the stack until we get the first non-ddtrace module
110+
# DEV: For `lambda.list_functions()` this should be:
111+
# - ddtrace.contrib.boto.patch
112+
# - ddtrace.vendor.wrapt.wrappers
113+
# - boto.awslambda.layer1 (make_request)
114+
# - boto.awslambda.layer1 (list_functions)
108115
frame = inspect.currentframe()
109-
# go up the call stack twice to get into the boto frame
110-
boto_frame = frame.f_back.f_back
111-
operation_name = boto_frame.f_code.co_name
116+
operation_name = frame.f_back.f_back.f_back.f_code.co_name
112117

113118
pin = Pin.get_from(instance)
114119
if not pin or not pin.enabled():

0 commit comments

Comments
 (0)