Skip to content

Commit 63b3d4f

Browse files
committed
Add llmobs_enabled.
1 parent 5c81289 commit 63b3d4f

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

datadog_lambda/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class Config:
5959
trace_extractor = _get_env("DD_TRACE_EXTRACTOR")
6060
capture_payload_max_depth = _get_env("DD_CAPTURE_PAYLOAD_MAX_DEPTH", 10, int)
6161
profiling_enabled = _get_env("DD_PROFILING_ENABLED", "false", as_bool)
62+
llmobs_enabled = _get_env("DD_LLMOBS_ENABLED", "false", as_bool)
6263

6364
@property
6465
def fips_mode_enabled(self):

datadog_lambda/wrapper.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@
4949
if config.profiling_enabled:
5050
from ddtrace.profiling import profiler
5151

52-
llmobs_env_var = os.environ.get("DD_LLMOBS_ENABLED", "false").lower() in ("true", "1")
53-
if llmobs_env_var:
52+
if config.llmobs_enabled:
5453
from ddtrace.llmobs import LLMObs
5554

5655
exception_replay_env_var = os.environ.get(
@@ -209,7 +208,7 @@ def __init__(self, func):
209208
patch_all()
210209

211210
# Enable LLM Observability
212-
if llmobs_env_var:
211+
if config.llmobs_enabled:
213212
LLMObs.enable()
214213

215214
# Enable Exception Replay
@@ -386,7 +385,7 @@ def _after(self, event, context):
386385
# logs api
387386
flush_extension()
388387

389-
if llmobs_env_var:
388+
if config.llmobs_enabled:
390389
LLMObs.flush()
391390

392391
# Flush exception replay

tests/test_config.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,15 @@ def set_env(key, value):
146146
("DD_PROFILING_ENABLED", "profiling_enabled", "1", True), # CHANGED
147147
("DD_PROFILING_ENABLED", "profiling_enabled", "0", False),
148148
("DD_PROFILING_ENABLED", "profiling_enabled", "purple", False),
149+
("DD_LLMOBS_ENABLED", "llmobs_enabled", None, False),
150+
("DD_LLMOBS_ENABLED", "llmobs_enabled", "", False),
151+
("DD_LLMOBS_ENABLED", "llmobs_enabled", "true", True),
152+
("DD_LLMOBS_ENABLED", "llmobs_enabled", "TRUE", True),
153+
("DD_LLMOBS_ENABLED", "llmobs_enabled", "false", False),
154+
("DD_LLMOBS_ENABLED", "llmobs_enabled", "FALSE", False),
155+
("DD_LLMOBS_ENABLED", "llmobs_enabled", "1", True), # CHANGED
156+
("DD_LLMOBS_ENABLED", "llmobs_enabled", "0", False),
157+
("DD_LLMOBS_ENABLED", "llmobs_enabled", "purple", False),
149158
)
150159

151160

0 commit comments

Comments
 (0)