Skip to content

Commit 192b9c1

Browse files
committed
Add trace_extractor.
1 parent 2f640ef commit 192b9c1

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

datadog_lambda/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class Config:
4444
)
4545
trace_enabled = _get_env("DD_TRACE_ENABLED", "true", as_bool)
4646
merge_xray_traces = _get_env("DD_MERGE_XRAY_TRACES", "false", as_bool)
47+
trace_extractor = _get_env("DD_TRACE_EXTRACTOR")
4748

4849
@property
4950
def fips_mode_enabled(self):

datadog_lambda/wrapper.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@
6363

6464
logger = logging.getLogger(__name__)
6565

66-
DD_LOGS_INJECTION = "DD_LOGS_INJECTION"
6766
DD_LOCAL_TEST = "DD_LOCAL_TEST"
68-
DD_TRACE_EXTRACTOR = "DD_TRACE_EXTRACTOR"
6967
DD_TRACE_MANAGED_SERVICES = "DD_TRACE_MANAGED_SERVICES"
7068
DD_ENCODE_AUTHORIZER_CONTEXT = "DD_ENCODE_AUTHORIZER_CONTEXT"
7169
DD_DECODE_AUTHORIZER_CONTEXT = "DD_DECODE_AUTHORIZER_CONTEXT"
@@ -158,7 +156,6 @@ def __init__(self, func):
158156
"""Executes when the wrapped function gets wrapped"""
159157
try:
160158
self.func = func
161-
self.extractor_env = os.environ.get(DD_TRACE_EXTRACTOR, None)
162159
self.trace_extractor = None
163160
self.span = None
164161
self.inferred_span = None
@@ -200,8 +197,8 @@ def __init__(self, func):
200197
self.response = None
201198
if profiling_env_var:
202199
self.prof = profiler.Profiler(env=env_env_var, service=config.service)
203-
if self.extractor_env:
204-
extractor_parts = self.extractor_env.rsplit(".", 1)
200+
if config.trace_extractor:
201+
extractor_parts = config.trace_extractor.rsplit(".", 1)
205202
if len(extractor_parts) == 2:
206203
(mod_name, extractor_name) = extractor_parts
207204
modified_extractor_name = modify_module_name(mod_name)

tests/test_config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ def set_env(key, value):
127127
("DD_MERGE_XRAY_TRACES", "merge_xray_traces", "1", True), # CHANGED
128128
("DD_MERGE_XRAY_TRACES", "merge_xray_traces", "0", False),
129129
("DD_MERGE_XRAY_TRACES", "merge_xray_traces", "purple", False),
130+
("DD_TRACE_EXTRACTOR", "trace_extractor", None, None),
131+
("DD_TRACE_EXTRACTOR", "trace_extractor", "", ""),
132+
("DD_TRACE_EXTRACTOR", "trace_extractor", "my_extractor", "my_extractor"),
130133
)
131134

132135

0 commit comments

Comments
 (0)