Datadog CI Test Visibility is failing to report test results, leading to a complete blackout of your CI/CD pipeline’s performance.
Common Causes and Fixes:
-
Datadog Agent Not Running or Misconfigured:
- Diagnosis: Check the Datadog agent status on your CI runners. For Docker, this would be
docker psand looking for the Datadog agent container. For host-based agents,sudo datadog-agent status. If it’s not running or shows errors, investigate agent logs (/var/log/datadog/agent.logon Linux). - Fix: Ensure the Datadog agent is started and healthy. For Docker, this might involve restarting the container:
docker restart <datadog-agent-container-id>. For host agents,sudo datadog-agent start. Verify yourdatadog.yamlconfiguration, especiallyapi_keyandsite. - Why it works: The Datadog agent is the gateway for all telemetry data, including test results, to reach Datadog. If it’s down or misconfigured, nothing gets sent.
- Diagnosis: Check the Datadog agent status on your CI runners. For Docker, this would be
-
Incorrect Datadog API Key or Site:
- Diagnosis: In your CI environment, inspect the Datadog API key and site configuration. This is often set via environment variables like
DD_API_KEYandDD_SITE. Manually try to ping the Datadog API endpoint from your CI runner usingcurl -v https://api.datadoghq.com/api/v1/validate?api-key=<your-api-key>. A successful response is{"status":"Success"}. If using a government cloud, replacedatadoghq.comwith your specific site (e.g.,datadoghq.eu). - Fix: Correct the
DD_API_KEYenvironment variable in your CI configuration to your actual Datadog API key. EnsureDD_SITEis set correctly for your Datadog account region (e.g.,datadoghq.comfor US1,datadoghq.eufor EU1,us3.datadoghq.comfor US3, etc.). - Why it works: The API key authenticates your account, and the site directs the data to the correct Datadog datacenter. An incorrect key or site means your data is sent to the wrong place or rejected.
- Diagnosis: In your CI environment, inspect the Datadog API key and site configuration. This is often set via environment variables like
-
Datadog Test Runner Configuration Missing or Incorrect:
- Diagnosis: Examine your CI job configuration files (e.g.,
.gitlab-ci.yml,Jenkinsfile, GitHub Actions workflow.yml). Look for how the Datadog tracer ordd-traceCLI is initialized. Specifically, check for environment variables likeDD_TEST_FRAMEWORK,DD_TEST_LEVEL,DD_TEST_SERVICE, andDD_TEST_MODULE. - Fix: Ensure the necessary Datadog environment variables are exported in your CI script before your tests run. For example, in a Node.js project using Jest:
For Python with pytest:export DD_TEST_FRAMEWORK="jest" export DD_TEST_SERVICE="my-node-app" export DD_TEST_MODULE="my-tests" # Run your tests npm testexport DD_TEST_FRAMEWORK="pytest" export DD_TEST_SERVICE="my-python-app" export DD_TEST_MODULE="my-tests" # Run your tests pytest - Why it works: These variables instruct the Datadog tracer how to instrument your specific test runner and what metadata to associate with the test results. Without them, the tracer doesn’t know what to capture or where to send it.
- Diagnosis: Examine your CI job configuration files (e.g.,
-
Datadog Tracer Not Properly Injected/Initialized:
- Diagnosis: Verify that the Datadog tracer is being loaded and initialized before your test suite starts executing. This often involves modifying your test runner’s entry point or using a wrapper script. For example, if you’re using
dd-traceCLI with Node.js:DD_TEST_FRAMEWORK=jest node -r dd-trace/init node_modules/.bin/jest. Check your CI logs for any errors related todd-traceinitialization. - Fix: Ensure the
dd-tracelibrary is installed (npm install --save-dev dd-traceorpip install dd-trace) and that it’s being required or invoked correctly. For Node.js, this might berequire('dd-trace').init();at the top of your test setup file. For Python, it’s often done via environment variableDD_TRACE_ENABLED=true. - Why it works: The tracer needs to actively hook into your test runner’s execution flow to capture test events. If it’s not initialized or loaded correctly, it can’t intercept or report anything.
- Diagnosis: Verify that the Datadog tracer is being loaded and initialized before your test suite starts executing. This often involves modifying your test runner’s entry point or using a wrapper script. For example, if you’re using
-
Firewall or Network Restrictions Blocking Datadog Agent Communication:
- Diagnosis: From your CI runner, attempt to
curlthe Datadog intake endpoint for your region. For example, for US1:curl -v https://ingest.logs.datadoghq.com. Check for connection timeouts or explicit rejections. Review your CI environment’s network policies, VPC security groups, or firewall rules. - Fix: Open outbound connections from your CI runners to Datadog’s intake endpoints on ports 80 and 443. The specific hostnames depend on your Datadog site (e.g.,
ingest.logs.datadoghq.com,trace.agent.datadoghq.com). Consult Datadog’s documentation for a comprehensive list of IP ranges and hostnames. - Why it works: The Datadog agent needs to send data to Datadog’s servers. Network restrictions can prevent this essential communication, even if the agent itself is running correctly.
- Diagnosis: From your CI runner, attempt to
-
Test Results Not Being Captured by Datadog’s Integration:
- Diagnosis: Check the specific Datadog integration for your test framework. For example, if using Jest, Datadog’s integration might require specific Jest configuration or plugins. Inspect the CI job logs for any output from the
dd-traceCLI or Datadog tracer indicating it’s not finding or recognizing your test framework. Look for messages like "No test framework detected." - Fix: Ensure you’ve installed any necessary Datadog-specific test runner packages or plugins. For example, if Datadog requires a specific Jest reporter, install it (
npm install --save-dev @datadog/datadog-jest-reporter) and configure it in your Jest config (jest.config.js). - Why it works: Datadog’s CI Test Visibility relies on specific integrations to correctly parse and report test results from different frameworks. Without the correct integration, it can’t understand the output or structure of your tests.
- Diagnosis: Check the specific Datadog integration for your test framework. For example, if using Jest, Datadog’s integration might require specific Jest configuration or plugins. Inspect the CI job logs for any output from the
The next error you’ll likely encounter is datadog.api.exceptions.RateLimitError if you’ve fixed the reporting but are sending too much data.