![]() |
VOOZH | about |
Custom commands provide a way to trace individual commands in your CI pipelines, allowing you to measure the time your command takes without taking into account any setup or teardown actions that the job might have (for example, downloading Docker images or waiting for an available node in a Kubernetes-based infrastructure). These spans appear as part of the pipeline’s trace:
Custom commands work with the following CI providers:
Install the datadog-ci (>=v0.17.0) CLI globally using npm:
npm install -g @datadog/datadog-ciTo trace a command line, run:
datadog-ci trace [--name <name>] -- <command>Specify a valid Datadog API key in the DATADOG_API_KEY environment variable. For example:
DATADOG_API_KEY=<key> DATADOG_SITE= datadog-ci trace \
--name "Greet" \
-- \
echo "Hello World"
These options are available for the datadog-ci trace command:
--name<command>Wait for DB to be reachable--tagskey:value to be attached to the custom command (the --tags parameter can be specified multiple times). When specifying tags using DD_TAGS, separate them using commas (for example, team:backend,priority:high).DD_TAGSteam:backend--tags and with the DD_TAGS environment variable are merged. If the same key appears in both --tags and DD_TAGS, the value in the environment variable DD_TAGS takes precedence.--measureskey:value to be attached to the custom command as numerical values (the --measures parameter can be specified multiple times).size:1024--no-failfalse--dry-runfalseThe following environment variables are supported:
DATADOG_API_KEY (Required)Additionally, configure the Datadog site to use the selected one ():
DATADOG_SITEdatadoghq.comIt is possible to trace multiple command lines at once by manually specifying the start and end timestamps (or the duration).
datadog-ci trace span [--name <name>] [--start-time <timestamp-ms>] [--end-time <timestamp-ms>] # [--duration <duration-ms>] can be used instead of start / end timeSpecify a valid Datadog API key in the DATADOG_API_KEY environment variable. For example:
DATADOG_API_KEY=<key> DATADOG_SITE= datadog-ci trace span \
--name "Build Step" \
--duration 10000
These options are available for the datadog-ci trace span command:
--nameBuild Step--start-time--start-time and --end-time or using --duration.--end-time--start-time and --end-time or using --duration.--duration--start-time and --end-time or using --duration.--tagskey:value to be attached to the custom span (the --tags parameter can be specified multiple times). When specifying tags using DD_TAGS, separate them using commas (for example, team:backend,priority:high).DD_TAGSteam:backend--tags and with the DD_TAGS environment variable are merged. If the same key appears in both --tags and DD_TAGS, the value in the environment variable DD_TAGS takes precedence.--measureskey:value to be attached to the custom span as numerical values (the --measures parameter can be specified multiple times).size:1024--dry-runfalseThe following environment variables are supported:
DATADOG_API_KEY (Required)Additionally, configure the Datadog site to use the selected one ():
DATADOG_SITEdatadoghq.comThe size limit is approximately 4MB. The most common cause for this error is extremely large tags.
Use the --dry-run option to see the traced command’s contents before sending it to Datadog.
Older versions of the datadog-ci CLI may require additional setup:
Additional helpful documentation, links, and articles:
| |