DataDog / datadog-ci

Use Datadog from your CI.
https://datadoghq.com
Apache License 2.0
129 stars 55 forks source link

Handle sfn->Lambda context injection when Payload is used without $ (case 2) #1462

Closed lym953 closed 2 months ago

lym953 commented 2 months ago

What and why?

This PR handles Step Function context injection into Lambda when Payload (not Payload.$) is used in the Lambda execution step.

This is case # 2 in this design doc: Fixing Step Function Instrumentation

Sub-cases:

Case 2.1: Already instrumented

    "Lambda Invoke": {
      "Parameters": {
        "Payload": {
          "Execution.$": "$$.Execution",
          "State.$": "$$.State"
        },
      },
    },

Then just print a message.

Case 2.2: Already has Execution or State field

If the payload already has any of Execution.$, Execution, State.$ or State, e.g.

    "Lambda Invoke": {
      "Parameters": {
        "Payload": {
          "State": {
            "Name": 'Lambda Invoke'
          }
        },
      },
    },

and it's not case 2.1, then print a warning and skip context injection

Case 2.3: no Execution or State field

i.e. it's not Case 2.1 or 2.2, e.g.

    "Lambda Invoke": {
      "Parameters": {
        "Payload": {
          "CustomerId": 42
        },
      },
    },

then just add the two fields:

    "Lambda Invoke": {
      "Parameters": {
        "Payload": {
          "CustomerId": 42,
          "Execution.$": "$$.Execution",
          "State.$": "$$.State"
        },
      },
    },

Testing

Passed the added tests

Review checklist

datadog-datadog-prod-us1[bot] commented 2 months ago

Datadog Report

Branch report: yiming.luo/fix-step-func-11 Commit report: 5120374 Test service: datadog-ci-tests

:white_check_mark: 0 Failed, 392 Passed, 0 Skipped, 1m 29.12s Total duration (2m 0.74s time saved)