このページは日本語には対応しておりません。随時翻訳に取り組んでいます。翻訳に関してご質問やご意見ございましたら、お気軽にご連絡ください。

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

Overview

Use the custom tags and measures commands to add user-defined text and numerical tags to your pipeline traces in CI Pipeline Visibility. You can use the datadog-ci NPM package to add custom tags to a pipeline trace or a job span, in addition to adding measures to a pipeline trace or a job span. From these custom tags and measures, you can create facets (string value tags) or measures (numerical value tags).

You can use facets and measures to filter, create visualizations, or create monitors for your pipelines in the CI Visibility Explorer.

Compatibility

Custom tags and measures work with the following CI providers:

  • Buildkite
  • CircleCI
  • GitLab (SaaS or self-hosted >= 14.1)
  • GitHub.com (SaaS): For adding tags and measures to GitHub jobs, see the section below.
  • Jenkins: 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 the tag command:

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

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

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

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

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

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

To create a facet from a tag, click the gear icon next to a tag name on the Pipeline Executions page, and click Create Facet.

Add measures to pipeline traces

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

DATADOG_SITE= datadog-ci measure [--level <pipeline|job>] [--measures <measures>]

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

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

DATADOG_SITE= datadog-ci measure --level pipeline --measures "error_rate:0.56"

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

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

To create a measure, click the gear icon next to a measures name on the Pipeline Executions page and click Create Measure.

Add tags and measures to GitHub jobs

To add tags and measures to GitHub jobs, datadog-ci CLI version 2.29.0 or higher is required. If the job name does not match the entry defined in the workflow configuration file (the GitHub job ID), the DD_GITHUB_JOB_NAME environment variable needs to be exposed, pointing to the job name. For example:

  1. If the job name is changed using the name property:

    jobs:
      build:
        name: My build job name
        env:
          DD_GITHUB_JOB_NAME: My build job name
        steps:
        - run: datadog-ci tag ...
    
  2. If the matrix strategy is used, several job names are generated by GitHub by adding the matrix values at the end of the job name, within parenthesis. The DD_GITHUB_JOB_NAME environment variable should then be conditional on the matrix values:

    jobs:
      build:
        strategy:
          matrix:
            version: [1, 2]
            os: [linux, macos]
        env:
          DD_GITHUB_JOB_NAME: build (${{ matrix.version }}, ${{ matrix.os }})
        steps:
        - run: datadog-ci tag ...
    

Further reading