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=trueandDD_CIVISIBILITY_AGENTLESS_ENABLED=truewith the test runner hook), or upload JUnit XML reports (datadog-ci junit upload). Havingdd-traceorddtraceinstalled for APM or Code Coverage does not turn Test Optimization on. - GitHub Actions cannot mutate
NODE_OPTIONSacross steps: for JavaScript and TypeScript on GitHub Actions,datadog/test-visibility-github-action@v3exportsDD_TRACE_PACKAGE(andDD_TRACE_ESM_IMPORTfor Vitest), which the test step itself must wire intoNODE_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 runordocker 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_KEYin 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.