close

Build Dashboards with Code Coverage Data

This product is not supported for your selected Datadog site. ().

Overview

Code Coverage events are available as a data source in Datadog dashboards. This page describes the event model, the facets you can query, and the query patterns for the most common widgets.

Coverage event model

Each report uploaded with datadog-ci coverage upload produces several events in Datadog:

  • One repository event that represents the report as a whole. This event carries no @service, @codeowner, or @report.flag tag.
  • One per-service event for each service the report covers, tagged with @service.
  • One per-code-owner event for each code owner the report covers, tagged with @codeowner.
  • One per-flag event for each flag applied to the report, tagged with @report.flag.

Any dashboard query that doesn’t isolate one of these event types ends up combining all of them and counting the same report multiple times. The query examples below demonstrate selecting exactly one event type at a time.

Available query facets

FacetDescription
@git.repository.idURL-style repository identifier in lowercase, without the scheme; for example, github.com/datadog/documentation. Scope every widget query to a single repository.
@git.default_branchtrue on events from the repository’s default branch. Add this only when a widget should report on the default branch. Use it instead of @git.branch when the default branch name differs across repositories.
@git.branchBranch name; for example, main. Use to target a specific named branch.
@git.commit.shaCommit the report was uploaded for. Useful as a group by for per-commit timeseries.
@serviceService name. Present only on per-service events.
@codeownerCode owner team. Present only on per-code-owner events.
@report.flagFlag name. Present only on per-flag events.

Build coverage widgets

Each example is the query filter for one widget. Replace <REPOSITORY_ID> with the lowercase, URL-style identifier of your repository (for example, github.com/datadog/documentation).

The breakdown examples (by service, code owner, and flag) do not restrict by branch. They aggregate coverage across every branch that has uploaded reports, including feature branches and pull requests. Add @git.default_branch:true or @git.branch:<BRANCH_NAME> to limit a widget to a specific branch.

Track overall coverage on the default branch

Use this filter in a Query Value widget for the current coverage number, or a Timeseries widget for a trend line over time.

@git.repository.id:<REPOSITORY_ID> @git.default_branch:true -@split:true -@report.flag:*

-@split:true excludes per-service and per-code-owner events, and -@report.flag:* excludes per-flag events, leaving only the repository event.

Break down coverage by service

Compare coverage across the services in a monorepo. Use this filter in a Top List or a Timeseries widget, grouped by @service.

@git.repository.id:<REPOSITORY_ID> @service:*

Break down coverage by code owner

Compare coverage across teams. Use this filter in a Top List or a Timeseries widget, grouped by @codeowner.

@git.repository.id:<REPOSITORY_ID> @codeowner:*

Break down coverage by flag

Compare coverage across flags, for example by test type or runtime version. Use this filter in a Top List or a Timeseries widget, grouped by @report.flag.

@git.repository.id:<REPOSITORY_ID> @report.flag:*

Example: coverage on main for a specific repository

@git.repository.id:github.com/datadog/documentation @git.branch:main -@split:true -@report.flag:*

This example uses @git.branch:main to target a named branch. To follow the default branch on any repository, use @git.default_branch:true instead.

Further reading