Skip to content

Commit 860ab10

Browse files
committed
Add local_test.
1 parent 302d472 commit 860ab10

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

datadog_lambda/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ class Config:
6868
llmobs_enabled = _get_env("DD_LLMOBS_ENABLED", "false", as_bool)
6969
exception_replay_enabled = _get_env("DD_EXCEPTION_REPLAY_ENABLED", "false", as_bool)
7070

71+
local_test = _get_env("DD_LOCAL_TEST", "false", as_bool)
72+
7173
@property
7274
def fips_mode_enabled(self):
7375
if not hasattr(self, "_config_fips_mode_enabled"):

datadog_lambda/wrapper.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,6 @@
6767
DD_ENV = "DD_ENV"
6868

6969

70-
def get_env_as_int(env_key, default_value: int) -> int:
71-
try:
72-
return int(os.environ.get(env_key, default_value))
73-
except Exception as e:
74-
logger.warn(
75-
f"Failed to parse {env_key} as int. Using default value: {default_value}. Error: {e}"
76-
)
77-
return default_value
78-
79-
8070
init_timestamp_ns = time_ns()
8171

8272
"""
@@ -150,9 +140,6 @@ def __init__(self, func):
150140
self.cold_start_tracing = depends_on_dd_tracing_enabled(
151141
os.environ.get(DD_COLD_START_TRACING, "true").lower() == "true"
152142
)
153-
self.local_testing_mode = os.environ.get(
154-
DD_LOCAL_TEST, "false"
155-
).lower() in ("true", "1")
156143
self.cold_start_trace_skip_lib = [
157144
"ddtrace.internal.compat",
158145
"ddtrace.filters",
@@ -357,7 +344,7 @@ def _after(self, event, context):
357344
from datadog_lambda.metric import flush_stats
358345

359346
flush_stats(context)
360-
if should_use_extension and self.local_testing_mode:
347+
if should_use_extension and self.local_test:
361348
# when testing locally, the extension does not know when an
362349
# invocation completes because it does not have access to the
363350
# logs api

tests/test_config.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,15 @@ def set_env(key, value):
183183
("DD_MIN_COLD_START_DURATION", "min_cold_start_trace_duration", "2.5", 3),
184184
("DD_MIN_COLD_START_DURATION", "min_cold_start_trace_duration", "-1", -1),
185185
("DD_MIN_COLD_START_DURATION", "min_cold_start_trace_duration", "purple", 3),
186+
("DD_LOCAL_TEST", "local_test", None, False),
187+
("DD_LOCAL_TEST", "local_test", "", False),
188+
("DD_LOCAL_TEST", "local_test", "true", True),
189+
("DD_LOCAL_TEST", "local_test", "TRUE", True),
190+
("DD_LOCAL_TEST", "local_test", "false", False),
191+
("DD_LOCAL_TEST", "local_test", "FALSE", False),
192+
("DD_LOCAL_TEST", "local_test", "1", True), # CHANGED
193+
("DD_LOCAL_TEST", "local_test", "0", False),
194+
("DD_LOCAL_TEST", "local_test", "purple", False),
186195
)
187196

188197

0 commit comments

Comments
 (0)