이 페이지는 아직 한국어로 제공되지 않으며 번역 작업 중입니다. 번역에 관한 질문이나 의견이 있으시면 언제든지 저희에게 연락해 주십시오.

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 <tag1>] [--tags <tag2>] ...

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 team and service tags to the pipeline span.

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

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 <measure1>] [--measures <measure2>]...

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 error_rate and size measures to the pipeline span:

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

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