For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/code_coverage/configuration.md.
A documentation index is available at /llms.txt.
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. You can suppress it on a per-repository basis with the comments.enabled field.
PR Gate checks are not affected by this setting.
code-coverage.datadog.yml
schema-version:v1comments:enabled: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: