Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.

CI Visibility is not available for the selected site ().

Custom tags and metrics is a beta feature and the API is still open to changes.

The custom tags and metrics commands provide a way to add user-defined text and numerical tags to your CI Visibility pipeline traces. These tags can be used to create facets (string value tags) or measures (numerical value tags). Facets and measures can then be used to search, graph, or monitor the pipelines.

Compatibility

Custom tags and metrics work with the following CI providers:

  • Buildkite
  • CircleCI
  • GitLab (SaaS or self-hosted >= 14.1)
  • GitHub.com (SaaS) Note: For GitHub, tags and metrics can only be added to the pipeline span.
  • Jenkins Note: For Jenkins, follow these instructions to set up custom tags in your pipelines.
  • Azure DevOps Pipelines

Install the Datadog CI CLI

Install the datadog-ci (>=v1.15.0) CLI globally using npm:

npm install -g @datadog/datadog-ci

Alternatively, you can try and use the beta standalone binary if you don’t want to use npm.

To install the standalone binary on Linux run:

curl -L --fail "https://github.com/DataDog/datadog-ci/releases/latest/download/datadog-ci_linux-x64" --output "/usr/local/bin/datadog-ci" && chmod +x /usr/local/bin/datadog-ci

To install the standalone binary on MacOS run:

curl -L --fail "https://github.com/DataDog/datadog-ci/releases/latest/download/datadog-ci_darwin-x64" --output "/usr/local/bin/datadog-ci" && chmod +x /usr/local/bin/datadog-ci

To install the standalone binary on Windows run:

Invoke-WebRequest -Uri "https://github.com/DataDog/datadog-ci/releases/latest/download/datadog-ci_win-x64.exe" -OutFile "datadog-ci.exe"

Add tags to pipeline traces

Tags can be added to the pipeline span or to the job span. To do this, run:

datadog-ci tag [--level <pipeline|job>] [--tags <tags>]

You must specify a valid Datadog API key using the environment variable DATADOG_API_KEY.

You must specify the Datadog site using the environment variable DATADOG_SITE.

The following example adds the tag team to the pipeline span:

datadog-ci tag --level pipeline --tags team:backend

The following example adds the tag go.version to the span for the current job:

datadog-ci tag --level job --tags "go.version:`go version`"

To create facets from the tags, click the gear icon next to the tag name in the pipeline executions page, and then click the create facet option.

Add metrics to pipeline traces

To add numerical tags to the pipeline span or the job span, run:

datadog-ci metric [--level <pipeline|job>] [--metrics <metrics>]

You must specify a valid Datadog API key using the environment variable DATADOG_API_KEY.

You must specify the Datadog site using the environment variable DATADOG_SITE.

The following example adds the metric error_rate to the pipeline span:

datadog-ci metric --level pipeline --metrics "error_rate:0.56"

The following example adds a metric binary.size to the span for the currently running job:

datadog-ci metric --level job --metric "binary.size:`ls -l dst/binary | awk '{print \$5}' | tr -d '\n'`"

To create a measure, click the gear icon next to the metrics name in the pipeline executions page and then click the create measure option.

Further reading