Skip to content

Modify end time of lambda load span to be last cold start node's end_time #319

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions datadog_lambda/cold_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,16 @@ def __init__(
self,
tracer,
function_name,
cold_start_span_finish_time_ns,
current_span_start_time_ns,
trace_ctx,
min_duration_ms: int,
ignored_libs: List[str] = [],
ignored_libs: List[str] = None,
):
if ignored_libs is None:
ignored_libs = []
self._tracer = tracer
self.function_name = function_name
self.cold_start_span_finish_time_ns = cold_start_span_finish_time_ns
self.current_span_start_time_ns = current_span_start_time_ns
self.min_duration_ms = min_duration_ms
self.trace_ctx = trace_ctx
self.ignored_libs = ignored_libs
Expand All @@ -151,11 +153,14 @@ def trace(self, root_nodes: List[ImportNode] = root_nodes):
if not root_nodes:
return
cold_start_span_start_time_ns = root_nodes[0].start_time_ns
cold_start_span_end_time_ns = min(
root_nodes[-1].end_time_ns, self.current_span_start_time_ns
)
cold_start_span = self.create_cold_start_span(cold_start_span_start_time_ns)
while root_nodes:
root_node = root_nodes.pop()
self.trace_tree(root_node, cold_start_span)
self.finish_span(cold_start_span, self.cold_start_span_finish_time_ns)
self.finish_span(cold_start_span, cold_start_span_end_time_ns)

def trace_tree(self, import_node: ImportNode, parent_span):
if (
Expand Down
2 changes: 1 addition & 1 deletion datadog_lambda/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def is_authorizer_response(response) -> bool:
and response["principalId"]
and response["policyDocument"]
)
except KeyError:
except (KeyError, AttributeError):
pass
except Exception as e:
logger.debug("unknown error while checking is_authorizer_response %s", e)
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_layers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ mkdir $LAYER_DIR

for python_version in "${PYTHON_VERSIONS[@]}"
do
if [ "$python_version" == "3.8" ] || [ "$python_version" == "3.9" ]; then
if [ "$python_version" != "3.7" ]; then
echo "Building layer for Python ${python_version} arch=arm64"
docker_build_zip ${python_version} $LAYER_DIR/${LAYER_FILES_PREFIX}-arm64-${python_version}.zip arm64
fi
Expand Down