DataDog / datadog-ci

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

Refactor sfn->sfn context injection code by merging two functions #1466

Closed lym953 closed 1 month ago

lym953 commented 1 month ago

What

Currently the injectContextForStepFunctions() function roughly looks like this:

const injectContextForStepFunctions = (...): boolean => {
  if (shouldUpdateStepForStepFunctionContextInjection()) {
    addTraceContextToStepFunctionParameters()
    return true
  }
  return false
}

It calls shouldUpdateStepForStepFunctionContextInjection().

This PR

  1. merges the two functions by moving the code of shouldUpdateStepForStepFunctionContextInjection() into injectContextForStepFunctions().
  2. makes the tests for shouldUpdateStepForStepFunctionContextInjection() test injectContextForStepFunctions() instead

Why?

We will soon have different instrumentation strategies depending on the existing state of Lambda definition, so shouldUpdateStepForStepFunctionContextInjection() which has a boolean return value will no longer work.

Design doc: Fixing Step Function Instrumentation

Testing

Passed the touched automated tests

Review checklist

datadog-datadog-prod-us1[bot] commented 1 month ago

Datadog Report

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

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