From 281bbd7d4aa1d66dca6c607ae0508bb03d5656c5 Mon Sep 17 00:00:00 2001 From: Ryan Strat Date: Tue, 19 Aug 2025 14:54:55 -0400 Subject: [PATCH 01/13] Describe support for upstream and downstream trace propagation --- .../step_functions/distributed-maps.md | 3 +- .../merge-step-functions-lambda.md | 41 ++++++++++++------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/content/en/serverless/step_functions/distributed-maps.md b/content/en/serverless/step_functions/distributed-maps.md index 26bea22062a..ef1481394ed 100644 --- a/content/en/serverless/step_functions/distributed-maps.md +++ b/content/en/serverless/step_functions/distributed-maps.md @@ -18,7 +18,8 @@ In AWS Step Functions, you can set up a large-scale parallel workload by includi "ItemBatcher": { "MaxItemsPerBatch": N, "BatchInput": { - "_datadog": "{% ($execInput := $states.context.Execution.Input; $hasDatadogTraceId := $exists($execInput._datadog.`x-datadog-trace-id`); $hasDatadogRootExecutionId := $exists($execInput._datadog.RootExecutionId); $ddTraceContext := $hasDatadogTraceId ? {'x-datadog-trace-id': $execInput._datadog.`x-datadog-trace-id`, 'x-datadog-tags': $execInput._datadog.`x-datadog-tags`} : {'RootExecutionId': $hasDatadogRootExecutionId ? $execInput._datadog.RootExecutionId : $states.context.Execution.Id}; $merge([$ddTraceContext, {'serverless-version': 'v1', 'timestamp': $millis()}])) %}" + "_datadog": "{% ($ddctx := ($states.context.**._datadog)[0];$maybeSnsCtx := ($parse($parse(($states.context.**.body)[0]).**._datadog.Value))[0];$ddctx := $exists($maybeSnsCtx) ? $maybeSnsCtx : $ddctx;$ddTraceContext := $exists($ddctx.`x-datadog-trace-id`) ? {'x-datadog-trace-id': $ddctx.`x-datadog-trace-id`, 'x-datadog-tags': $ddctx.`x-datadog-tags`} : {'RootExecutionId': $exists($ddctx.RootExecutionId) ? $ddctx.RootExecutionId : $states.context.Execution.Id};$merge([$ddTraceContext, {'serverless-version': 'v1', 'timestamp': $millis()}])) + %}" } } {{< /highlight >}} diff --git a/content/en/serverless/step_functions/merge-step-functions-lambda.md b/content/en/serverless/step_functions/merge-step-functions-lambda.md index 1a597e1816d..7bdc523f5d2 100644 --- a/content/en/serverless/step_functions/merge-step-functions-lambda.md +++ b/content/en/serverless/step_functions/merge-step-functions-lambda.md @@ -6,7 +6,7 @@ further_reading: text: 'Install Serverless Monitoring for AWS Step Functions' --- -This page describes how to merge your AWS Step Functions traces with related AWS Lambda traces or nested Step Functions traces. These instructions assume that you have already instrumented these [AWS Step Functions][1] and [Lambda functions][2] to send traces to Datadog. +This page describes how to merge your AWS Step Functions traces with related AWS Lambda traces and Step Functions traces. These instructions assume that you have already instrumented these [AWS Step Functions][1] and [Lambda functions][2] to send traces to Datadog.
Datadog recommends using JSONata to define your Step Function definitions for the most complete end-to-end tracing experience. This approach ensures that any context upstream to the Step Function is preserved and passed down.
@@ -26,7 +26,7 @@ Your State Machine definition must use `JSONata` as the query language. To enabl #### Setup -On the Lambda Task, set the `Payload` in the `Arguments` field as follows: +On the Lambda Task, set the `Payload` in the `Arguments` field as follows: {{< highlight json "hl_lines=7-7" >}} "Lambda Invoke": { @@ -35,7 +35,7 @@ On the Lambda Task, set the `Payload` in the `Arguments` field as follows: "Output": "{% $states.result.Payload %}", "Arguments": { "FunctionName": "MyFunctionName", - "Payload": "{% ($execInput := $exists($states.context.Execution.Input.BatchInput) ? $states.context.Execution.Input.BatchInput : $states.context.Execution.Input; $hasDatadogTraceId := $exists($execInput._datadog.`x-datadog-trace-id`); $hasDatadogRootExecutionId := $exists($execInput._datadog.RootExecutionId); $ddTraceContext := $hasDatadogTraceId ? {'x-datadog-trace-id': $execInput._datadog.`x-datadog-trace-id`, 'x-datadog-tags': $execInput._datadog.`x-datadog-tags`} : {'RootExecutionId': $hasDatadogRootExecutionId ? $execInput._datadog.RootExecutionId : $states.context.Execution.Id}; $sfnContext := $merge([$states.context, {'Execution': $sift($states.context.Execution, function($v, $k) { $k != 'Input' })}]); $merge([$states.input, {'_datadog': $merge([$sfnContext, $ddTraceContext, {'serverless-version': 'v1'}])}])) %}" + "Payload": "{% ($ddctx := ($states.context.**._datadog)[0]; $maybeSnsCtx := ($parse($parse(($states.context.**.body)[0]).**._datadog.Value))[0]; $ddctx := $exists($maybeSnsCtx) ? $maybeSnsCtx : $ddctx; $ddTraceContext := $exists($ddctx.`x-datadog-trace-id`) ? {'x-datadog-trace-id': $ddctx.`x-datadog-trace-id`, 'x-datadog-tags': $ddctx.`x-datadog-tags`} : {'RootExecutionId': $exists($ddctx.RootExecutionId) ? $ddctx.RootExecutionId : $states.context.Execution.Id}; $sfnContext := $merge([$states.context, {'Execution': $sift($states.context.Execution, function($v, $k) { $k != 'Input' })}]); $merge([$sfnContext, $ddTraceContext, {'serverless-version': 'v1'}])) %}" } } {{< /highlight >}} @@ -188,7 +188,7 @@ For additional code examples in TypeScript and Go, see [CDK Examples for Instrum {{% /tab %}} {{% tab "Custom" %}} -On the Lambda Task, set the `Parameters` key as follows: +On the Lambda Task, set the `Parameters` key as follows: ```json "Parameters": { @@ -240,7 +240,7 @@ Alternatively, if you have business logic defined in the payload, you can also u ### Through managed services -Follow these instructions if your Step Function indirectly invokes a Lambda through EventBridge, SQS, or SNS. To trace through another managed AWS service, [contact Datadog Support][3] to open a feature request. +Requests between Step Functions and Lambdas can be traced through many AWS managed services, including SNS, SQS, and EventBridge. To trace through another managed AWS service, [contact Datadog Support][3] to open a feature request. #### Requirements @@ -254,7 +254,7 @@ Merging Step Functions with Lambda traces through managed services is only suppo #### EventBridge -If an EventBridge rule has a Lambda function as a target, edit your EventBridge PutEvents Task to set `_datadog` in the `Detail` field as follows: +If an EventBridge rule has a Lambda function as a target, edit your EventBridge PutEvents Task to set `_datadog` in the `Detail` field as follows: {{< highlight json "hl_lines=10-10" >}} "EventBridge PutEvents": { @@ -266,7 +266,7 @@ If an EventBridge rule has a Lambda function as a target, edit your EventBridge "Detail": { "Message": "Hello from Step Functions!", "TaskToken": "{% $states.context.Task.Token %}", - "_datadog": "{% ($execInput := $exists($states.context.Execution.Input.BatchInput) ? $states.context.Execution.Input.BatchInput : $states.context.Execution.Input; $hasDatadogTraceId := $exists($execInput._datadog.`x-datadog-trace-id`); $hasDatadogRootExecutionId := $exists($execInput._datadog.RootExecutionId); $ddTraceContext := $hasDatadogTraceId ? {'x-datadog-trace-id': $execInput._datadog.`x-datadog-trace-id`, 'x-datadog-tags': $execInput._datadog.`x-datadog-tags`} : {'RootExecutionId': $hasDatadogRootExecutionId ? $execInput._datadog.RootExecutionId : $states.context.Execution.Id}; $sfnContext := $merge([$states.context, {'Execution': $sift($states.context.Execution, function($v, $k) { $k != 'Input' })}]); $merge([$sfnContext, $ddTraceContext, {'serverless-version': 'v1'}])) %}" + "_datadog": "{% ($ddctx := ($states.context.**._datadog)[0]; $maybeSnsCtx := ($parse($parse(($states.context.**.body)[0]).**._datadog.Value))[0]; $ddctx := $exists($maybeSnsCtx) ? $maybeSnsCtx : $ddctx; $ddTraceContext := $exists($ddctx.`x-datadog-trace-id`) ? {'x-datadog-trace-id': $ddctx.`x-datadog-trace-id`, 'x-datadog-tags': $ddctx.`x-datadog-tags`} : {'RootExecutionId': $exists($ddctx.RootExecutionId) ? $ddctx.RootExecutionId : $states.context.Execution.Id}; $sfnContext := $merge([$states.context, {'Execution': $sift($states.context.Execution, function($v, $k) { $k != 'Input' })}]); $merge([$sfnContext, $ddTraceContext, {'serverless-version': 'v1'}])) %}" }, "DetailType": "MyDetailType", "EventBusName": "MyEventBusName", @@ -279,7 +279,7 @@ If an EventBridge rule has a Lambda function as a target, edit your EventBridge #### SQS -If an SQS queue has a Lambda trigger, edit your SQS SendMessage Task to set `_datadog` in the `MessageAttributes` field as follows: +If an SQS queue has a Lambda trigger, edit your SQS SendMessage Task to set `_datadog` in the `MessageAttributes` field as follows: {{< highlight json "hl_lines=8-11" >}} "SQS SendMessage": { @@ -291,7 +291,7 @@ If an SQS queue has a Lambda trigger, edit your SQS SendMessage Task to set `_da "MessageAttributes": { "_datadog": { "DataType": "String", - "StringValue": "{% ($execInput := $exists($states.context.Execution.Input.BatchInput) ? $states.context.Execution.Input.BatchInput : $states.context.Execution.Input; $hasDatadogTraceId := $exists($execInput._datadog.`x-datadog-trace-id`); $hasDatadogRootExecutionId := $exists($execInput._datadog.RootExecutionId); $ddTraceContext := $hasDatadogTraceId ? {'x-datadog-trace-id': $execInput._datadog.`x-datadog-trace-id`, 'x-datadog-tags': $execInput._datadog.`x-datadog-tags`} : {'RootExecutionId': $hasDatadogRootExecutionId ? $execInput._datadog.RootExecutionId : $states.context.Execution.Id}; $sfnContext := $merge([$states.context, {'Execution': $sift($states.context.Execution, function($v, $k) { $k != 'Input' })}]); $merge([$sfnContext, $ddTraceContext, {'serverless-version': 'v1'}])) %}" + "StringValue": "{% ($ddctx := ($states.context.**._datadog)[0]; $maybeSnsCtx := ($parse($parse(($states.context.**.body)[0]).**._datadog.Value))[0]; $ddctx := $exists($maybeSnsCtx) ? $maybeSnsCtx : $ddctx; $ddTraceContext := $exists($ddctx.`x-datadog-trace-id`) ? {'x-datadog-trace-id': $ddctx.`x-datadog-trace-id`, 'x-datadog-tags': $ddctx.`x-datadog-tags`} : {'RootExecutionId': $exists($ddctx.RootExecutionId) ? $ddctx.RootExecutionId : $states.context.Execution.Id}; $sfnContext := $merge([$states.context, {'Execution': $sift($states.context.Execution, function($v, $k) { $k != 'Input' })}]); $merge([$sfnContext, $ddTraceContext, {'serverless-version': 'v1'}])) %}" } } } @@ -300,7 +300,7 @@ If an SQS queue has a Lambda trigger, edit your SQS SendMessage Task to set `_da #### SNS -If there is a Lambda subscription on the topic, edit the SNS Publish Task to set `_datadog` in the `MessageAttributes` field as follows: +If there is a Lambda subscription on the topic, edit the SNS Publish Task to set `_datadog` in the `MessageAttributes` field as follows: {{< highlight json "hl_lines=8-11" >}} "SNS Publish": { @@ -312,7 +312,7 @@ If there is a Lambda subscription on the topic, edit the SNS Publish Task to set "MessageAttributes": { "_datadog": { "DataType": "String", - "StringValue": "{% ($execInput := $exists($states.context.Execution.Input.BatchInput) ? $states.context.Execution.Input.BatchInput : $states.context.Execution.Input; $hasDatadogTraceId := $exists($execInput._datadog.`x-datadog-trace-id`); $hasDatadogRootExecutionId := $exists($execInput._datadog.RootExecutionId); $ddTraceContext := $hasDatadogTraceId ? {'x-datadog-trace-id': $execInput._datadog.`x-datadog-trace-id`, 'x-datadog-tags': $execInput._datadog.`x-datadog-tags`} : {'RootExecutionId': $hasDatadogRootExecutionId ? $execInput._datadog.RootExecutionId : $states.context.Execution.Id}; $sfnContext := $merge([$states.context, {'Execution': $sift($states.context.Execution, function($v, $k) { $k != 'Input' })}]); $merge([$sfnContext, $ddTraceContext, {'serverless-version': 'v1'}])) %}" + "StringValue": "{% ($ddctx := ($states.context.**._datadog)[0]; $maybeSnsCtx := ($parse($parse(($states.context.**.body)[0]).**._datadog.Value))[0]; $ddctx := $exists($maybeSnsCtx) ? $maybeSnsCtx : $ddctx; $ddTraceContext := $exists($ddctx.`x-datadog-trace-id`) ? {'x-datadog-trace-id': $ddctx.`x-datadog-trace-id`, 'x-datadog-tags': $ddctx.`x-datadog-tags`} : {'RootExecutionId': $exists($ddctx.RootExecutionId) ? $ddctx.RootExecutionId : $states.context.Execution.Id}; $sfnContext := $merge([$states.context, {'Execution': $sift($states.context.Execution, function($v, $k) { $k != 'Input' })}]); $merge([$sfnContext, $ddTraceContext, {'serverless-version': 'v1'}])) %}" } } } @@ -323,7 +323,7 @@ If there is a Lambda subscription on the topic, edit the SNS Publish Task to set ### With JSONata -Edit the Step Functions Task to set `_datadog` in the `Input` field as follows: +Edit the Step Functions Task to set `_datadog` in the `Input` field as follows: {{< highlight json "hl_lines=7-7" >}} "Step Functions StartExecution": { @@ -332,7 +332,7 @@ Edit the Step Functions Task to set `_datadog` in the `Input` field as follows: "Arguments": { "StateMachineArn": "arn:aws:states:::stateMachine:", "Input": { - "_datadog": "{% ($execInput := $exists($states.context.Execution.Input.BatchInput) ? $states.context.Execution.Input.BatchInput : $states.context.Execution.Input; $hasDatadogTraceId := $exists($execInput._datadog.`x-datadog-trace-id`); $hasDatadogRootExecutionId := $exists($execInput._datadog.RootExecutionId); $ddTraceContext := $hasDatadogTraceId ? {'x-datadog-trace-id': $execInput._datadog.`x-datadog-trace-id`, 'x-datadog-tags': $execInput._datadog.`x-datadog-tags`} : {'RootExecutionId': $hasDatadogRootExecutionId ? $execInput._datadog.RootExecutionId : $states.context.Execution.Id}; $sfnContext := $merge([$states.context, {'Execution': $sift($states.context.Execution, function($v, $k) { $k != 'Input' })}]); $merge([$sfnContext, $ddTraceContext, {'serverless-version': 'v1'}])) %}" + "_datadog": "{% ($ddctx := ($states.context.**._datadog)[0]; $maybeSnsCtx := ($parse($parse(($states.context.**.body)[0]).**._datadog.Value))[0]; $ddctx := $exists($maybeSnsCtx) ? $maybeSnsCtx : $ddctx; $ddTraceContext := $exists($ddctx.`x-datadog-trace-id`) ? {'x-datadog-trace-id': $ddctx.`x-datadog-trace-id`, 'x-datadog-tags': $ddctx.`x-datadog-tags`} : {'RootExecutionId': $exists($ddctx.RootExecutionId) ? $ddctx.RootExecutionId : $states.context.Execution.Id}; $sfnContext := $merge([$states.context, {'Execution': $sift($states.context.Execution, function($v, $k) { $k != 'Input' })}]); $merge([$sfnContext, $ddTraceContext, {'serverless-version': 'v1'}])) %}" } } } @@ -363,7 +363,7 @@ Configure your task according to the following example: ## Merge Lambda traces with downstream Step Functions traces -Follow these instructions if a Lambda function directly invokes a Step Function using `StartExecution` or `StartSyncExecution`. +Traces can be connected downstream from Lambda functions when called directly using `StartExecution` or `StartSyncExecution` or when called indirectly through managed services like SNS, SQS, or EventBridge. ### Requirements | Runtime | Requirement | @@ -379,6 +379,17 @@ If the layer or tracer version requirements are fulfilled, no further setup is r
To ensure proper trace merging, provide input to the Step Functions Start Execution command, even if the input is an empty JSON object.
+## Merge Step Functions traces with other services + +For services not covered in this guide, you can merge traces by manually propagating [Datadog trace context][3]. + +**Upstream services to Step Functions**: Include trace context in the Step Function input payload as JSON under the `_datadog` key, which can be located anywhere in the payload. + +**Step Functions to Downstream services**: Add Step Function execution context to your task definitions using the patterns shown above. Additional configuration of the downstream service may be required. + +For assistance with custom integrations, [contact Datadog Support][4]. + [1]: /serverless/step_functions/installation [2]: /serverless/aws_lambda/installation -[3]: /help \ No newline at end of file +[3]: tracing/trace_collection/trace_context_propagation/?tab=java#datadog-format +[4]: /help From a33a6d10a1bd03b1c43dc2f54c75fc1f1fd9ed01 Mon Sep 17 00:00:00 2001 From: Ryan Strat Date: Tue, 19 Aug 2025 15:18:18 -0400 Subject: [PATCH 02/13] Fix link --- .../en/serverless/step_functions/merge-step-functions-lambda.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/serverless/step_functions/merge-step-functions-lambda.md b/content/en/serverless/step_functions/merge-step-functions-lambda.md index 7bdc523f5d2..f984c8ba3d4 100644 --- a/content/en/serverless/step_functions/merge-step-functions-lambda.md +++ b/content/en/serverless/step_functions/merge-step-functions-lambda.md @@ -391,5 +391,5 @@ For assistance with custom integrations, [contact Datadog Support][4]. [1]: /serverless/step_functions/installation [2]: /serverless/aws_lambda/installation -[3]: tracing/trace_collection/trace_context_propagation/?tab=java#datadog-format +[3]: /tracing/trace_collection/trace_context_propagation/?tab=java#datadog-format [4]: /help From 9472ff1b0221665c48191977d736582caf7bd4f2 Mon Sep 17 00:00:00 2001 From: Ryan Strat Date: Tue, 19 Aug 2025 15:43:10 -0400 Subject: [PATCH 03/13] Formatting --- .../serverless/step_functions/merge-step-functions-lambda.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/en/serverless/step_functions/merge-step-functions-lambda.md b/content/en/serverless/step_functions/merge-step-functions-lambda.md index f984c8ba3d4..d981b17ebfc 100644 --- a/content/en/serverless/step_functions/merge-step-functions-lambda.md +++ b/content/en/serverless/step_functions/merge-step-functions-lambda.md @@ -35,7 +35,7 @@ On the Lambda Task, set the `Payload` in the `Arguments` field as follows: "Output": "{% $states.result.Payload %}", "Arguments": { "FunctionName": "MyFunctionName", - "Payload": "{% ($ddctx := ($states.context.**._datadog)[0]; $maybeSnsCtx := ($parse($parse(($states.context.**.body)[0]).**._datadog.Value))[0]; $ddctx := $exists($maybeSnsCtx) ? $maybeSnsCtx : $ddctx; $ddTraceContext := $exists($ddctx.`x-datadog-trace-id`) ? {'x-datadog-trace-id': $ddctx.`x-datadog-trace-id`, 'x-datadog-tags': $ddctx.`x-datadog-tags`} : {'RootExecutionId': $exists($ddctx.RootExecutionId) ? $ddctx.RootExecutionId : $states.context.Execution.Id}; $sfnContext := $merge([$states.context, {'Execution': $sift($states.context.Execution, function($v, $k) { $k != 'Input' })}]); $merge([$sfnContext, $ddTraceContext, {'serverless-version': 'v1'}])) %}" + "Payload": "{% ($ddctx := ($states.context.**._datadog)[0]; $maybeSnsCtx := ($parse($parse(($states.context.**.body)[0]).**._datadog.Value))[0]; $ddctx := $exists($maybeSnsCtx) ? $maybeSnsCtx : $ddctx; $ddTraceContext := $exists($ddctx.`x-datadog-trace-id`) ? {'x-datadog-trace-id': $ddctx.`x-datadog-trace-id`, 'x-datadog-tags': $ddctx.`x-datadog-tags`} : {'RootExecutionId': $exists($ddctx.RootExecutionId) ? $ddctx.RootExecutionId : $states.context.Execution.Id}; $sfnContext := $merge([$states.context, {'Execution': $sift($states.context.Execution, function($v, $k) { $k != 'Input' })}]); $merge([$sfnContext, $ddTraceContext, {'serverless-version': 'v1'}])) %}" } } {{< /highlight >}} @@ -342,7 +342,7 @@ Edit the Step Functions Task to set `_datadog` in the `Input` field as follows: Configure your task according to the following example: -{{< highlight json "hl_lines=9-13" >}} +{{< highlight json "hl_lines=8-13" >}} "Step Functions StartExecution": { "Type": "Task", "Resource": "arn:aws:states:::states:startExecution", From 748800324fab4b62dc35d6a285ac06af08234e3e Mon Sep 17 00:00:00 2001 From: Ryan Strat Date: Tue, 19 Aug 2025 15:57:23 -0400 Subject: [PATCH 04/13] Adjust highlighting --- .../en/serverless/step_functions/merge-step-functions-lambda.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/serverless/step_functions/merge-step-functions-lambda.md b/content/en/serverless/step_functions/merge-step-functions-lambda.md index d981b17ebfc..1d80545b4ea 100644 --- a/content/en/serverless/step_functions/merge-step-functions-lambda.md +++ b/content/en/serverless/step_functions/merge-step-functions-lambda.md @@ -342,7 +342,7 @@ Edit the Step Functions Task to set `_datadog` in the `Input` field as follows: Configure your task according to the following example: -{{< highlight json "hl_lines=8-13" >}} +{{< highlight json "hl_lines=8-12" >}} "Step Functions StartExecution": { "Type": "Task", "Resource": "arn:aws:states:::states:startExecution", From 3bf9504ca051034e0f40cd0cf15b2dbfce81566c Mon Sep 17 00:00:00 2001 From: Ryan Strat Date: Wed, 20 Aug 2025 13:42:34 -0400 Subject: [PATCH 05/13] add example trace propagation --- .../step_functions/merge-step-functions-lambda.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/content/en/serverless/step_functions/merge-step-functions-lambda.md b/content/en/serverless/step_functions/merge-step-functions-lambda.md index 1d80545b4ea..9e13200a83f 100644 --- a/content/en/serverless/step_functions/merge-step-functions-lambda.md +++ b/content/en/serverless/step_functions/merge-step-functions-lambda.md @@ -385,6 +385,18 @@ For services not covered in this guide, you can merge traces by manually propaga **Upstream services to Step Functions**: Include trace context in the Step Function input payload as JSON under the `_datadog` key, which can be located anywhere in the payload. +**Example datadog context object**: + +At a minimum, the context object must contain the `x-datadog-trace-id` and `x-datadog-parent-id` keys. The `x-datadog-tags` key is optional and can be used to pass additional tags. + +{{< highlight json >}} +"_datadog": { + "x-datadog-trace-id": "280166049706551372", + "x-datadog-parent-id": "611647714644695775", + "x-datadog-tags": "_dd.p.tid=66bcb5eb00000000,_dd.p.dm=-0" +} +{{< /highlight >}} + **Step Functions to Downstream services**: Add Step Function execution context to your task definitions using the patterns shown above. Additional configuration of the downstream service may be required. For assistance with custom integrations, [contact Datadog Support][4]. From ca899b9f68a9cf40ef23a032417edb9a2baeb703 Mon Sep 17 00:00:00 2001 From: Ryan Strat Date: Wed, 20 Aug 2025 14:05:19 -0400 Subject: [PATCH 06/13] Formatting --- .../serverless/step_functions/merge-step-functions-lambda.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/content/en/serverless/step_functions/merge-step-functions-lambda.md b/content/en/serverless/step_functions/merge-step-functions-lambda.md index 9e13200a83f..e3ba65e6e7e 100644 --- a/content/en/serverless/step_functions/merge-step-functions-lambda.md +++ b/content/en/serverless/step_functions/merge-step-functions-lambda.md @@ -385,9 +385,7 @@ For services not covered in this guide, you can merge traces by manually propaga **Upstream services to Step Functions**: Include trace context in the Step Function input payload as JSON under the `_datadog` key, which can be located anywhere in the payload. -**Example datadog context object**: - -At a minimum, the context object must contain the `x-datadog-trace-id` and `x-datadog-parent-id` keys. The `x-datadog-tags` key is optional and can be used to pass additional tags. +The context object must contain the `x-datadog-trace-id` and `x-datadog-parent-id` keys. The `x-datadog-tags` key is optional and is used to pass additional tags. {{< highlight json >}} "_datadog": { From 115b8327a049a5ed8bad7f2af0aa23df594c9c43 Mon Sep 17 00:00:00 2001 From: Ryan Strat Date: Wed, 20 Aug 2025 14:08:36 -0400 Subject: [PATCH 07/13] Improve clarity of downstream trace propagation --- .../step_functions/merge-step-functions-lambda.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/content/en/serverless/step_functions/merge-step-functions-lambda.md b/content/en/serverless/step_functions/merge-step-functions-lambda.md index e3ba65e6e7e..de13075f8ac 100644 --- a/content/en/serverless/step_functions/merge-step-functions-lambda.md +++ b/content/en/serverless/step_functions/merge-step-functions-lambda.md @@ -395,11 +395,12 @@ The context object must contain the `x-datadog-trace-id` and `x-datadog-parent-i } {{< /highlight >}} -**Step Functions to Downstream services**: Add Step Function execution context to your task definitions using the patterns shown above. Additional configuration of the downstream service may be required. +**Step Functions to Downstream services**: Add Step Function execution context to your task definitions using the patterns described above in the [propagating traces to Lambda via Managed Services][4] section. Additional configuration of the downstream service may be required. -For assistance with custom integrations, [contact Datadog Support][4]. +For assistance with custom integrations, [contact Datadog Support][5]. [1]: /serverless/step_functions/installation [2]: /serverless/aws_lambda/installation [3]: /tracing/trace_collection/trace_context_propagation/?tab=java#datadog-format -[4]: /help +[4]: /serverless/step_functions/merge-step-functions-lambda?tab=serverlessframework#through-managed-services +[5]: /help From 8f62ff364bdadacf0334704612254b0daf77d666 Mon Sep 17 00:00:00 2001 From: Ryan Strat Date: Wed, 20 Aug 2025 14:43:54 -0400 Subject: [PATCH 08/13] Apply suggestion from @janine-c Co-authored-by: Janine Chan <64388808+janine-c@users.noreply.github.com> --- content/en/serverless/step_functions/distributed-maps.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/content/en/serverless/step_functions/distributed-maps.md b/content/en/serverless/step_functions/distributed-maps.md index ef1481394ed..904fcb5fc01 100644 --- a/content/en/serverless/step_functions/distributed-maps.md +++ b/content/en/serverless/step_functions/distributed-maps.md @@ -18,8 +18,7 @@ In AWS Step Functions, you can set up a large-scale parallel workload by includi "ItemBatcher": { "MaxItemsPerBatch": N, "BatchInput": { - "_datadog": "{% ($ddctx := ($states.context.**._datadog)[0];$maybeSnsCtx := ($parse($parse(($states.context.**.body)[0]).**._datadog.Value))[0];$ddctx := $exists($maybeSnsCtx) ? $maybeSnsCtx : $ddctx;$ddTraceContext := $exists($ddctx.`x-datadog-trace-id`) ? {'x-datadog-trace-id': $ddctx.`x-datadog-trace-id`, 'x-datadog-tags': $ddctx.`x-datadog-tags`} : {'RootExecutionId': $exists($ddctx.RootExecutionId) ? $ddctx.RootExecutionId : $states.context.Execution.Id};$merge([$ddTraceContext, {'serverless-version': 'v1', 'timestamp': $millis()}])) - %}" + "_datadog": "{% ($ddctx := ($states.context.**._datadog)[0];$maybeSnsCtx := ($parse($parse(($states.context.**.body)[0]).**._datadog.Value))[0];$ddctx := $exists($maybeSnsCtx) ? $maybeSnsCtx : $ddctx;$ddTraceContext := $exists($ddctx.`x-datadog-trace-id`) ? {'x-datadog-trace-id': $ddctx.`x-datadog-trace-id`, 'x-datadog-tags': $ddctx.`x-datadog-tags`} : {'RootExecutionId': $exists($ddctx.RootExecutionId) ? $ddctx.RootExecutionId : $states.context.Execution.Id};$merge([$ddTraceContext, {'serverless-version': 'v1', 'timestamp': $millis()}])) %}" } } {{< /highlight >}} From 522964fb2295682b07eccab67e5bb1fa36f9a57f Mon Sep 17 00:00:00 2001 From: Ryan Strat Date: Wed, 20 Aug 2025 14:44:20 -0400 Subject: [PATCH 09/13] Apply suggestion from @janine-c Co-authored-by: Janine Chan <64388808+janine-c@users.noreply.github.com> --- .../en/serverless/step_functions/merge-step-functions-lambda.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/serverless/step_functions/merge-step-functions-lambda.md b/content/en/serverless/step_functions/merge-step-functions-lambda.md index de13075f8ac..cac02b3f39a 100644 --- a/content/en/serverless/step_functions/merge-step-functions-lambda.md +++ b/content/en/serverless/step_functions/merge-step-functions-lambda.md @@ -363,7 +363,7 @@ Configure your task according to the following example: ## Merge Lambda traces with downstream Step Functions traces -Traces can be connected downstream from Lambda functions when called directly using `StartExecution` or `StartSyncExecution` or when called indirectly through managed services like SNS, SQS, or EventBridge. +Traces can be connected downstream from Lambda functions when called directly using `StartExecution` or `StartSyncExecution`, or when called indirectly through managed services like SNS, SQS, or EventBridge. ### Requirements | Runtime | Requirement | From ac4f7d1342dcbba9773fbf2089095ddb3e9a5da2 Mon Sep 17 00:00:00 2001 From: Ryan Strat Date: Wed, 20 Aug 2025 14:45:11 -0400 Subject: [PATCH 10/13] Apply suggestion from @janine-c Co-authored-by: Janine Chan <64388808+janine-c@users.noreply.github.com> --- .../serverless/step_functions/merge-step-functions-lambda.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/content/en/serverless/step_functions/merge-step-functions-lambda.md b/content/en/serverless/step_functions/merge-step-functions-lambda.md index cac02b3f39a..1de1428f4e5 100644 --- a/content/en/serverless/step_functions/merge-step-functions-lambda.md +++ b/content/en/serverless/step_functions/merge-step-functions-lambda.md @@ -399,6 +399,10 @@ The context object must contain the `x-datadog-trace-id` and `x-datadog-parent-i For assistance with custom integrations, [contact Datadog Support][5]. +## Further Reading + +{{< partial name="whats-next/whats-next.html" >}} + [1]: /serverless/step_functions/installation [2]: /serverless/aws_lambda/installation [3]: /tracing/trace_collection/trace_context_propagation/?tab=java#datadog-format From d97445e5508f0f3b74befe1ba939501947173103 Mon Sep 17 00:00:00 2001 From: Ryan Strat Date: Thu, 21 Aug 2025 16:24:10 -0400 Subject: [PATCH 11/13] Apply suggestion from @janine-c Co-authored-by: Janine Chan <64388808+janine-c@users.noreply.github.com> --- .../en/serverless/step_functions/merge-step-functions-lambda.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/serverless/step_functions/merge-step-functions-lambda.md b/content/en/serverless/step_functions/merge-step-functions-lambda.md index 1de1428f4e5..856457744da 100644 --- a/content/en/serverless/step_functions/merge-step-functions-lambda.md +++ b/content/en/serverless/step_functions/merge-step-functions-lambda.md @@ -406,5 +406,5 @@ For assistance with custom integrations, [contact Datadog Support][5]. [1]: /serverless/step_functions/installation [2]: /serverless/aws_lambda/installation [3]: /tracing/trace_collection/trace_context_propagation/?tab=java#datadog-format -[4]: /serverless/step_functions/merge-step-functions-lambda?tab=serverlessframework#through-managed-services +[4]: #through-managed-services [5]: /help From 931957ee51876bf623486ea1c6ae4dd4984a49f3 Mon Sep 17 00:00:00 2001 From: Ryan Strat Date: Thu, 21 Aug 2025 16:32:02 -0400 Subject: [PATCH 12/13] Apply suggestions from reviews --- .../step_functions/merge-step-functions-lambda.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/content/en/serverless/step_functions/merge-step-functions-lambda.md b/content/en/serverless/step_functions/merge-step-functions-lambda.md index 856457744da..16e8bdb8f0a 100644 --- a/content/en/serverless/step_functions/merge-step-functions-lambda.md +++ b/content/en/serverless/step_functions/merge-step-functions-lambda.md @@ -383,9 +383,11 @@ If the layer or tracer version requirements are fulfilled, no further setup is r For services not covered in this guide, you can merge traces by manually propagating [Datadog trace context][3]. -**Upstream services to Step Functions**: Include trace context in the Step Function input payload as JSON under the `_datadog` key, which can be located anywhere in the payload. +### Upstream services to Step Functions -The context object must contain the `x-datadog-trace-id` and `x-datadog-parent-id` keys. The `x-datadog-tags` key is optional and is used to pass additional tags. +Include trace context in the Step Function input payload as JSON under the `_datadog` key, which can be located anywhere in the payload. +- The context object must contain the `x-datadog-trace-id` and `x-datadog-parent-id` keys. +- The `x-datadog-tags` key is optional and is used to pass additional tags. {{< highlight json >}} "_datadog": { @@ -395,7 +397,9 @@ The context object must contain the `x-datadog-trace-id` and `x-datadog-parent-i } {{< /highlight >}} -**Step Functions to Downstream services**: Add Step Function execution context to your task definitions using the patterns described above in the [propagating traces to Lambda via Managed Services][4] section. Additional configuration of the downstream service may be required. +### Step Functions to Downstream services + +Add Step Function execution context to your task definitions using the patterns described above in the [propagating traces to Lambda via Managed Services][4] section. Additional configuration of the downstream service may be required. For assistance with custom integrations, [contact Datadog Support][5]. From bbee6956a4b28c63623916c730753c8af10ef890 Mon Sep 17 00:00:00 2001 From: Ryan Strat Date: Thu, 21 Aug 2025 16:49:25 -0400 Subject: [PATCH 13/13] Fix capitalization --- .../en/serverless/step_functions/merge-step-functions-lambda.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/en/serverless/step_functions/merge-step-functions-lambda.md b/content/en/serverless/step_functions/merge-step-functions-lambda.md index 16e8bdb8f0a..73b53fc8f89 100644 --- a/content/en/serverless/step_functions/merge-step-functions-lambda.md +++ b/content/en/serverless/step_functions/merge-step-functions-lambda.md @@ -397,7 +397,7 @@ Include trace context in the Step Function input payload as JSON under the `_dat } {{< /highlight >}} -### Step Functions to Downstream services +### Step Functions to downstream services Add Step Function execution context to your task definitions using the patterns described above in the [propagating traces to Lambda via Managed Services][4] section. Additional configuration of the downstream service may be required.