Skip to content

Commit d836b23

Browse files
committed
Add trace_extractor.
1 parent 2de5650 commit d836b23

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

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
@@ -61,9 +61,7 @@
6161

6262
logger = logging.getLogger(__name__)
6363

64-
DD_LOGS_INJECTION = "DD_LOGS_INJECTION"
6564
DD_LOCAL_TEST = "DD_LOCAL_TEST"
66-
DD_TRACE_EXTRACTOR = "DD_TRACE_EXTRACTOR"
6765
DD_TRACE_MANAGED_SERVICES = "DD_TRACE_MANAGED_SERVICES"
6866
DD_ENCODE_AUTHORIZER_CONTEXT = "DD_ENCODE_AUTHORIZER_CONTEXT"
6967
DD_DECODE_AUTHORIZER_CONTEXT = "DD_DECODE_AUTHORIZER_CONTEXT"
@@ -155,7 +153,6 @@ def __init__(self, func):
155153
"""Executes when the wrapped function gets wrapped"""
156154
try:
157155
self.func = func
158-
self.extractor_env = os.environ.get(DD_TRACE_EXTRACTOR, None)
159156
self.trace_extractor = None
160157
self.span = None
161158
self.inferred_span = None
@@ -194,8 +191,8 @@ def __init__(self, func):
194191
self.response = None
195192
if profiling_env_var:
196193
self.prof = profiler.Profiler(env=env_env_var, service=config.service)
197-
if self.extractor_env:
198-
extractor_parts = self.extractor_env.rsplit(".", 1)
194+
if config.trace_extractor:
195+
extractor_parts = config.trace_extractor.rsplit(".", 1)
199196
if len(extractor_parts) == 2:
200197
(mod_name, extractor_name) = extractor_parts
201198
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)