Skip to content

Commit 06b4c22

Browse files
committed
Add env.
1 parent baedfd0 commit 06b4c22

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

datadog_lambda/config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ def as_bool(val):
4040
class Config:
4141

4242
service = _get_env("DD_SERVICE")
43+
env = _get_env("DD_ENV")
44+
4345
add_span_pointers = _get_env("DD_BOTOCORE_ADD_SPAN_POINTERS", "true", as_bool)
4446
cold_start_tracing = _get_env("DD_COLD_START_TRACING", "true", as_bool)
4547
enhanced_metrics_enabled = _get_env("DD_ENHANCED_METRICS", "true", as_bool)

datadog_lambda/wrapper.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ def get_env_as_int(env_key, default_value: int) -> int:
8383
os.environ.get(DD_CAPTURE_LAMBDA_PAYLOAD, "false").lower() == "true"
8484
)
8585

86-
env_env_var = os.environ.get(DD_ENV, None)
87-
8886
init_timestamp_ns = time_ns()
8987

9088
"""
@@ -177,7 +175,7 @@ def __init__(self, func):
177175
logger.debug(f"Malformatted for env {DD_COLD_START_TRACE_SKIP_LIB}")
178176
self.response = None
179177
if config.profiling_enabled:
180-
self.prof = profiler.Profiler(env=env_env_var, service=config.service)
178+
self.prof = profiler.Profiler(env=config.env, service=config.service)
181179
if config.trace_extractor:
182180
extractor_parts = config.trace_extractor.rsplit(".", 1)
183181
if len(extractor_parts) == 2:

tests/test_config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ def set_env(key, value):
164164
("DD_EXCEPTION_REPLAY_ENABLED", "exception_replay_enabled", "1", True), # CHANGED
165165
("DD_EXCEPTION_REPLAY_ENABLED", "exception_replay_enabled", "0", False),
166166
("DD_EXCEPTION_REPLAY_ENABLED", "exception_replay_enabled", "purple", False),
167+
("DD_ENV", "env", None, None),
168+
("DD_ENV", "env", "", ""),
169+
("DD_ENV", "env", "my_env", "my_env"),
167170
)
168171

169172

0 commit comments

Comments
 (0)