DataDog / datadog-ci

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

Print warning if traces merging from sfn to sfn is skipped #1447

Closed lym953 closed 1 week ago

lym953 commented 2 weeks ago

Why?

Let's say Step Function A executes Step Function B. If B:

  1. doesn't have a Parameters field, or
  2. its Parameters.Input field is not a JSON object
  3. its Parameters.Input field has a custom CONTEXT.$ field

traces merging will be skipped, but no warning message will be printed.

What

Print a warning message in these cases to let users know what won't work.

Testing

1. Missing Parameters field

I wasn't able to test this because Parameters field is required when editing the State Machine from AWS Management Console.

Screenshot 2024-09-12 at 12 51 26 PM

2. Parameters.Input field is not a JSON object

Steps
  1. Change the Step Function execution step to be like:
    "Step Functions StartExecution": {
      "Type": "Task",
      "Resource": "arn:aws:states:::states:startExecution",
      "Parameters": {
        "StateMachineArn": "...",
        "Input": "Input!"
      },
      "End": true
    }
  2. Run datadog-ci stepfunctions instrument command
Result

A warning message is printed as expected:

image

3. custom CONTEXT.$

image

4. Happy case

datadog-ci stepfunctions instrument finishes with no error

Review checklist

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

Datadog Report

Branch report: yiming.luo/fix-step-func-2 Commit report: 5ef1845 Test service: datadog-ci-tests

:white_check_mark: 0 Failed, 364 Passed, 0 Skipped, 1m 26.6s Total duration (2m 1.5s time saved)

lym953 commented 2 weeks ago

I found a bug: if traces merging is already set up and instrumentation command is run again, the warning will also be printed, which is wrong. I will fix this in a separate PR.