From f9b4a4aa6cec5c342e2f46836ac6856cc33075be Mon Sep 17 00:00:00 2001 From: Rey Abolofia Date: Wed, 14 May 2025 11:19:07 -0700 Subject: [PATCH] Call `patch_all` before importing handler code. --- datadog_lambda/wrapper.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/datadog_lambda/wrapper.py b/datadog_lambda/wrapper.py index e5460118..8ba611ae 100644 --- a/datadog_lambda/wrapper.py +++ b/datadog_lambda/wrapper.py @@ -45,6 +45,10 @@ extract_http_status_code_tag, ) +# Patch third-party libraries for tracing, must be done before importing any +# handler code. +patch_all() + profiling_env_var = os.environ.get("DD_PROFILING_ENABLED", "false").lower() == "true" if profiling_env_var: from ddtrace.profiling import profiler @@ -223,8 +227,6 @@ def __init__(self, func): os.environ[DD_REQUESTS_SERVICE_NAME] = os.environ.get( DD_SERVICE, "aws.lambda" ) - # Patch third-party libraries for tracing - patch_all() # Enable LLM Observability if llmobs_env_var: