dd-instrument-test-optimization

Installation
SKILL.md

Datadog Test Optimization

Test Optimization collects per-test traces, failure reasons, and git metadata from CI test runs so Datadog can detect flaky tests and run Test Impact Analysis. No application resource has to be created in Datadog beforehand: the test service appears automatically when a test run sends spans with a valid API key and site.

How it works

  • What turns Test Optimization on: the CI test job must either run the Datadog Test Optimization CI step (datadog/test-visibility-github-action@v3, the GitLab script, or the CircleCI orb), run the language tracer in CI Visibility mode (DD_CIVISIBILITY_ENABLED=true and DD_CIVISIBILITY_AGENTLESS_ENABLED=true with the test runner hook), or upload JUnit XML reports (datadog-ci junit upload). Having dd-trace or ddtrace installed for APM or Code Coverage does not turn Test Optimization on.
  • GitHub Actions cannot mutate NODE_OPTIONS across steps: for JavaScript and TypeScript on GitHub Actions, datadog/test-visibility-github-action@v3 exports DD_TRACE_PACKAGE (and DD_TRACE_ESM_IMPORT for Vitest), which the test step itself must wire into NODE_OPTIONS. Without that env line on the test step, no test spans are collected.
  • Containers cross an execution boundary: when a CI step runs tests through docker run or docker compose, host-level environment variables do not enter the container automatically. The Datadog variables, the runtime injection variable, and the CI provider's git/pipeline variables must be passed into the container, and prebuilt test images must use manual instrumentation inside the container.
  • Credentials: Test Optimization uses DD_API_KEY in agentless mode. Reference it from the CI provider's secret store (${{ secrets.DD_API_KEY }}, $DD_API_KEY, or $(DD_API_KEY)); never write a literal key into a workflow or config file.

Set up

Copy these steps into your reply and tick them off as you go.

Installs
39
GitHub Stars
186
First Seen
14 days ago