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 Software Catalog integration is the recommended approach for defining services, as code locations configured in Software Catalog can be used by multiple Datadog products. Use manual configuration only when Software 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: