@@ -110,19 +110,12 @@ export function getCheckpointToken(event: unknown): string | undefined {
110110const TERMINAL_STATUSES = new Set ( [ "SUCCEEDED" , "FAILED" , "CANCELLED" , "STOPPED" , "TIMED_OUT" ] ) ;
111111
112112const TRACE_CHECKPOINT_NAME_PREFIX = "_datadog_" ;
113- const LEGACY_TRACE_CHECKPOINT_NAME_PREFIX = "_dd_trace_context_" ;
114- const TRACE_CHECKPOINT_NAME_PREFIXES = [
115- TRACE_CHECKPOINT_NAME_PREFIX ,
116- LEGACY_TRACE_CHECKPOINT_NAME_PREFIX ,
117- ] ;
118113
119114function parseTraceCheckpointNumber ( name : unknown ) : number | null {
120115 if ( typeof name !== "string" ) return null ;
121116
122- const prefix = TRACE_CHECKPOINT_NAME_PREFIXES . find ( ( candidate ) => name . startsWith ( candidate ) ) ;
123- if ( ! prefix ) return null ;
124-
125- const suffix = name . slice ( prefix . length ) ;
117+ if ( ! name . startsWith ( TRACE_CHECKPOINT_NAME_PREFIX ) ) return null ;
118+ const suffix = name . slice ( TRACE_CHECKPOINT_NAME_PREFIX . length ) ;
126119 const n = Number . parseInt ( suffix , 10 ) ;
127120 if ( Number . isNaN ( n ) || String ( n ) !== suffix ) return null ;
128121 return n ;
@@ -141,7 +134,6 @@ function isTraceCheckpointName(name: unknown): boolean {
141134 * dd-trace-js plugin via `tracer.inject(span, 'http_headers', headers)` so the
142135 * payload is a standard HTTP-style header dict.
143136 *
144- * Also accepts legacy `_dd_trace_context_{N}` names for compatibility.
145137 */
146138function findLatestCheckpointHeaders ( event : DurableExecutionEvent ) : Record < string , string > | null {
147139 const operations = event . InitialExecutionState ?. Operations ;
@@ -319,12 +311,14 @@ export function getCompletedOperationCount(event: unknown): number {
319311 * - no operation has terminal status
320312 * - operation count is <= 1
321313 *
314+ * The created span is parented to the current aws.lambda span context.
315+ *
322316 * Returns an object with { span, finish() } or null if not a durable execution.
323317 * Caller must call finish() when the invocation ends.
324318 */
325319export function createDurableExecutionRootSpan (
326320 event : unknown ,
327- extractedRootContext ?: SpanContextWrapper | null ,
321+ parentSpanContext ?: unknown ,
328322) : { span : any ; finish : ( ) => void } | null {
329323 if ( ! isDurableExecutionEvent ( event ) ) {
330324 return null ;
@@ -379,10 +373,9 @@ export function createDurableExecutionRootSpan(
379373 if ( startTime !== undefined ) {
380374 spanOptions . startTime = startTime ;
381375 }
382- if ( extractedRootContext ?. spanContext ) {
383- // Stay in the same trace as the upstream caller even when there is no
384- // active scope yet. aws.lambda will be parented to this span downstream.
385- spanOptions . childOf = extractedRootContext . spanContext ;
376+ if ( parentSpanContext ) {
377+ // Root span is modeled as a child of aws.lambda.
378+ spanOptions . childOf = parentSpanContext ;
386379 }
387380
388381 const span = tracer . startSpan ( "aws.durable-execution" , spanOptions ) ;
0 commit comments