Skip to content
Prev Previous commit
Next Next commit
add logging, add default skip libs, change the following-span order
  • Loading branch information
joeyzhao2018 committed Feb 13, 2023
commit c9f2b3aedd80c4e65792f01d65d0b20eec31621c
6 changes: 4 additions & 2 deletions datadog_lambda/cold_start.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import time
import os
from typing import List, Hashable
import logging
logger = logging.getLogger(__name__)

_cold_start = True
_lambda_container_initialized = False
Expand Down Expand Up @@ -103,8 +105,8 @@ def wrapped_find_spec(*args, **kwargs):
try:
loader.exec_module = wrap_exec_module(loader.exec_module)
already_wrapped_loaders.add(loader)
except Exception:
pass
except Exception as e:
logger.debug("Failed to wrap the loader. %s", e)
return spec

return wrapped_find_spec
Expand Down
9 changes: 5 additions & 4 deletions datadog_lambda/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,10 @@ def __init__(self, func):
self.cold_start_trace_skip_lib = []
if "DD_COLD_START_TRACE_SKIP_LIB" in os.environ:
try:
self.cold_start_trace_skip_lib = os.environ[
"DD_COLD_START_TRACE_SKIP_LIB"
].split(",")
self.cold_start_trace_skip_lib = os.environ.get(
"DD_COLD_START_TRACE_SKIP_LIB",
"datadog_lambda.extension,datadog_lambda.metric,datadog_lambda.patch"
).split(",")
except Exception:
logger.debug("Malformatted for env DD_COLD_START_TRACE_SKIP_LIB")
self.response = None
Expand Down Expand Up @@ -302,7 +303,7 @@ def _after(self, event, context):

if should_trace_cold_start:
try:
following_span = self.span or self.inferred_span
following_span = self.inferred_span or self.span
ColdStartTracer(
tracer,
self.function_name,
Expand Down