Skip to content

Commit 6e1eb1a

Browse files
committed
Add llmobs_enabled.
1 parent 2c2162f commit 6e1eb1a

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

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
@@ -48,8 +48,7 @@
4848
if config.profiling_enabled:
4949
from ddtrace.profiling import profiler
5050

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

5554
exception_replay_env_var = os.environ.get(
@@ -203,7 +202,7 @@ def __init__(self, func):
203202
patch_all()
204203

205204
# Enable LLM Observability
206-
if llmobs_env_var:
205+
if config.llmobs_enabled:
207206
LLMObs.enable()
208207

209208
# Enable Exception Replay
@@ -378,7 +377,7 @@ def _after(self, event, context):
378377
# logs api
379378
flush_extension()
380379

381-
if llmobs_env_var:
380+
if config.llmobs_enabled:
382381
LLMObs.flush()
383382

384383
if self.encode_authorizer_context and is_authorizer_response(self.response):

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)