This product is not supported for your selected Datadog site. ().
Overview
You can configure Code Coverage behavior by creating a configuration file named code-coverage.datadog.yml or code-coverage.datadog.yaml in the root of your repository.
Using Catalog integration is the recommended approach for defining services, as code locations configured in Catalog can be used by multiple Datadog products. Use manual configuration only when Catalog integration is not available.
You can define services in your configuration file to split coverage data by service in monorepos. This is useful when multiple projects or teams share a single repository and you want to view coverage metrics for each service independently.
You can exclude specific files or directories from code coverage reporting using the ignore field. This is useful for excluding test files, generated code, vendor dependencies, and other files that should not be included in coverage metrics. Path patterns support glob, regex, and prefix matching (see Pattern syntax).
ignore:- "test/**/*"# Exclude all files in test directory- "*.pb.go"# Exclude all protobuf generated files- "vendor/"# Exclude vendor directory
Exceptions
Add ! before a pattern to create an exception to your ignore rules. This lets you include specific files or folders that would otherwise be excluded.
You can define PR Gates in the configuration file to enforce code coverage thresholds on pull requests. If gates are also configured in the Datadog UI, Datadog evaluates both the configuration file rules and the UI rules when a PR is opened or updated.
If both the configuration file and the Datadog UI define gates for the same scope, the pull request must meet every defined threshold.
threshold (required): The minimum coverage percentage (0-100).
services: (optional) A list of service name patterns to scope the gate to. Use * as a wildcard. Prefix a value with ! to exclude matching services. When set, coverage is evaluated separately for each matching service.
codeowners: (optional) A list of code owner patterns to scope the gate to. Use * as a wildcard. Prefix a value with ! to exclude matching code owners. When set, coverage is evaluated separately for each matching code owner.
flags: (optional) A list of flag name patterns to scope the gate to. Use * as a wildcard. Prefix a value with ! to exclude matching flags. When set, coverage is evaluated separately for each matching flag.
Use the ! prefix to exclude specific services, code owners, or flags from a gate. For example, to enforce coverage on all services except experimental ones, and on all flags except nightly tests:
By default, Datadog posts a code coverage summary comment on every pull request. The summary reports the total and patch coverage for the pull request and links to the Code Coverage page in Datadog.
The comments block accepts the following fields:
Field
Type
Default
Description
enabled
Boolean
true
Whether Datadog posts a code coverage comment on pull requests.
file_breakdown
Boolean
false
Whether the comment includes a per-file table of total and patch coverage.
PR Gate checks are not affected by these settings.
Disabling PR comments
You can suppress the comment on a per-repository basis with the comments.enabled field:
code-coverage.datadog.yml
schema-version:v1comments:enabled:false
Per-file breakdown
Set comments.file_breakdown to true to add a table to the comment listing the files changed in the pull request, along with their total coverage and patch coverage:
The breakdown has no effect when comments.enabled is false.
Carryforward
Join the Preview!
Carryforward is in Preview and is subject to change.
You can enable carryforward in the configuration file to reuse coverage data from ancestor commits when not every CI job runs for a commit. Carryforward operates on flags, so every report involved must be tagged with --flags.
To enable carryforward for every flag in the repository: