Skip to content

Commit 8bb1825

Browse files
lym953claude
authored andcommitted
fix(aws-durable-execution-sdk-js): [SVLS-8588] set span type to serverless (#9162)
* fix(aws-durable-execution-sdk-js): treat FAILED checkpoints as replays A durable operation served from a FAILED checkpoint on replay (the SDK re-raises the stored error without running the body) was not recognized as a replay: both `aws.durable.replayed` and the `aws.durable.operation_attempt` normalization keyed only on `Status === 'SUCCEEDED'`. As a result a caught-then-replayed failed operation reported `replayed=false` and a 1-indexed `operation_attempt` (e.g. 2 for a step whose 2nd attempt failed) — one higher than, and inconsistent with, the live final attempt (1). This is the same off-by-one #8595 fixed for SUCCEEDED, still open for FAILED. Treat a terminal checkpoint (SUCCEEDED or FAILED) as a replay for both tags, so the replay agrees with the live run (replayed=true, operation_attempt=1). Verified in production on a durable Lambda. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(aws-durable-execution-sdk-js): set span type to serverless The durable plugins declare `static type = 'serverless'`, but `TracingPlugin.startSpan` only defaults `component` from the class — `type` and `kind` have no `this.constructor.*` fallback. The plugins forwarded `kind: this.constructor.kind` but omitted `type`, so every durable span was emitted with an empty `span.type`. Forward `type: this.constructor.type` in both bindStart calls so the spans carry `type: serverless`, matching the dd-trace-py integration. This lets serverless UIs (e.g. the Lambda trace panel's Durable Function Execution section) recognize the spans as Lambda/function spans. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
1 parent f0bc9f1 commit 8bb1825

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

packages/datadog-plugin-aws-durable-execution-sdk-js/src/context.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class BaseContextPlugin extends TracingPlugin {
5050

5151
this.startSpan(spanName, {
5252
resource,
53+
type: this.constructor.type,
5354
kind: this.constructor.kind,
5455
meta,
5556
metrics,

packages/datadog-plugin-aws-durable-execution-sdk-js/src/handler.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class AwsDurableExecutionSdkJsHandlerPlugin extends TracingPlugin {
5252

5353
this.startSpan(this.operationName(), {
5454
resource: handler?.name,
55+
type: this.constructor.type,
5556
kind: this.constructor.kind,
5657
meta,
5758
}, ctx)

packages/datadog-plugin-aws-durable-execution-sdk-js/test/index.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,17 @@ createIntegrationTestSuite('aws-durable-execution-sdk-js', '@aws/durable-executi
219219
return tracePromise
220220
})
221221

222+
it('sets span type to serverless on execute and operation spans', async () => {
223+
const tracePromise = agent.assertSomeTraces(traces => {
224+
// handler.js (execute span) and context.js (operation spans) both declare
225+
// `static type = 'serverless'`; assert it reaches the emitted span.type.
226+
assertSpanByName(traces, { name: 'aws.durable.execute', type: 'serverless' })
227+
assertSpanByName(traces, { name: 'aws.durable.step', type: 'serverless' })
228+
})
229+
await invokeHandler(async (event, ctx) => ctx.step(async () => {}))
230+
return tracePromise
231+
})
232+
222233
for (const { span, errorMessage, run } of [
223234
{
224235
span: 'aws.durable.step',

0 commit comments

Comments
 (0)