Skip to content

Commit 1677473

Browse files
authored
(feat): Enable Exception Replay in Lambda (#592)
* import exception replay from tracer and enable if `DD_EXCEPTION_REPLAY_ENABLED=true` * lint
1 parent 1226b2d commit 1677473

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

datadog_lambda/wrapper.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@
5353
if llmobs_env_var:
5454
from ddtrace.llmobs import LLMObs
5555

56+
exception_replay_env_var = os.environ.get(
57+
"DD_EXCEPTION_REPLAY_ENABLED", "false"
58+
).lower() in ("true", "1")
59+
if exception_replay_env_var:
60+
from ddtrace.debugging._exception.replay import SpanExceptionHandler
61+
5662
logger = logging.getLogger(__name__)
5763

5864
DD_FLUSH_TO_LOG = "DD_FLUSH_TO_LOG"
@@ -224,6 +230,11 @@ def __init__(self, func):
224230
if llmobs_env_var:
225231
LLMObs.enable()
226232

233+
# Enable Exception Replay
234+
if exception_replay_env_var:
235+
logger.debug("Enabling exception replay")
236+
SpanExceptionHandler.enable()
237+
227238
logger.debug("datadog_lambda_wrapper initialized")
228239
except Exception as e:
229240
logger.error(format_err_with_traceback(e))

0 commit comments

Comments
 (0)