Skip to content

Commit 76fa712

Browse files
jchrostek-ddclaude
andcommitted
test: verify cold start spans share trace_id with function span
Add trace_id assertions to test_lazy_loaded_package_imports to ensure cold start spans (aws.lambda.load and import spans) are created with the same trace_id as the main aws.lambda span. This catches regressions where trace context is captured after span.finish() instead of before. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent d5916d6 commit 76fa712

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tests/test_cold_start.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,13 +310,20 @@ def handler(event, context):
310310
handler.cold_start_tracing = True
311311
handler({}, lambda_context)
312312

313-
function_span = import_span = None
313+
function_span = import_span = load_span = None
314314
for span in spans:
315315
if span.resource == "tabnanny":
316316
import_span = span
317317
elif span.name == "aws.lambda":
318318
function_span = span
319+
elif span.name == "aws.lambda.load":
320+
load_span = span
319321

320322
assert function_span is not None
321323
assert import_span is not None
322324
assert import_span.parent_id == function_span.span_id
325+
# Verify cold start spans share the same trace_id as the function span.
326+
# This ensures trace context is captured BEFORE span.finish() is called.
327+
assert import_span.trace_id == function_span.trace_id
328+
assert load_span is not None
329+
assert load_span.trace_id == function_span.trace_id

0 commit comments

Comments
 (0)