diff --git a/content/en/continuous_integration/pipelines/custom_commands.md b/content/en/continuous_integration/pipelines/custom_commands.md index 19203e38d9870..6f6d472e11401 100644 --- a/content/en/continuous_integration/pipelines/custom_commands.md +++ b/content/en/continuous_integration/pipelines/custom_commands.md @@ -20,7 +20,7 @@ Custom commands provide a way to trace individual commands in your CI pipelines, Custom commands work with the following CI providers: -- GitHub.com (SaaS) with datadog-ci CLI >= 2.40. For sending custom commands in GitHub Actions, see [Trace a command](#trace-a-command-in-github-actions). +- GitHub.com (SaaS) with datadog-ci CLI >= 2.40. For sending custom commands in GitHub Actions, see [Known issue with Github Actions](#known-issue-with-github-actions). - GitLab (SaaS or self-hosted >= 14.1) with datadog-ci CLI >= 2.40. - Jenkins with the Datadog plugin >= v3.2.0 - CircleCI @@ -36,9 +36,9 @@ Install the [`datadog-ci`][1] (>=v0.17.0) CLI globally using `npm`: npm install -g @datadog/datadog-ci {{< /code-block >}} -## Trace a command +## Trace a command line -To trace a command, run: +To trace a command line, run: {{< code-block lang="shell" >}} datadog-ci trace [--name ] -- @@ -60,7 +60,7 @@ echo "Hello World"
CI Visibility is not available in the selected site ({{< region-param key="dd_site_name" >}}).
{{< /site-region >}} -## Configuration settings +### Configuration settings These options are available for the `datadog-ci trace` command: @@ -108,7 +108,82 @@ Additionally, configure the Datadog site to use the selected one ({{< region-par **Selected site**: {{< region-param key="dd_site" code="true" >}} {{< /site-region >}} -## Trace a command in GitHub Actions +## Trace a command block + +It is possible to trace multiple command lines at once by manually specifying the start and end timestamps (or the duration). + +{{< code-block lang="shell" >}} +datadog-ci trace span [--name ] [--start-time ] [--end-time ] # [--duration ] can be used instead of start / end time +{{< /code-block >}} + +Specify a valid [Datadog API key][2] in the `DATADOG_API_KEY` environment variable. For example: + +{{< site-region region="us,us3,eu,ap1" >}} +
+
+DATADOG_API_KEY=<key> DATADOG_SITE={{< region-param key="dd_site" >}} datadog-ci trace span \
+--name "Build Step" \
+--duration 10000
+
+
+{{< /site-region >}} +{{< site-region region="gov" >}} +
CI Visibility is not available in the selected site ({{< region-param key="dd_site_name" >}}).
+{{< /site-region >}} + +### Configuration settings + +These options are available for the `datadog-ci trace span` command: + +`--name` +: Display name of the custom span.
+**Example**: `Build Step` + +`--start-time` +: Timestamp in milliseconds since the UNIX epoch representing the start time of the span.
+**Note**: There are two ways to specify start and end time, by using `--start-time` and `--end-time` or using `--duration`. + +`--end-time` +: Timestamp in milliseconds since the UNIX epoch representing the end time of the span.
+**Note**: There are two ways to specify start and end time, by using `--start-time` and `--end-time` or using `--duration`. + +`--duration` +: Duration amount in milliseconds. Using this, the end time is the current time when executing this command.
+**Note**: There are two ways to specify start and end time, by using `--start-time` and `--end-time` or using `--duration`. + +`--tags` +: Key-value pairs in the form `key: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`).
+**Environment variable**: `DD_TAGS`
+**Default**: (none)
+**Example**: `team:backend`
+**Note**: Tags specified using `--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. + +`--measures` +: Key-value pairs in the form `key:value` to be attached to the custom span as numerical values (the `--measures` parameter can be specified multiple times).
+_(Requires datadog-ci >=v2.35.0)_
+**Default**: (none)
+**Example**: `size:1024`
+ +`--dry-run` +: Prevents datadog-ci from sending the custom span to Datadog. All other checks are performed.
+**Default**: `false` + +The following environment variables are supported: + +`DATADOG_API_KEY` (Required) +: [Datadog API key][2] used to authenticate the requests.
+**Default**: (none) + +{{< site-region region="us3,us5,eu,ap1" >}} +Additionally, configure the Datadog site to use the selected one ({{< region-param key="dd_site_name" >}}): + +`DATADOG_SITE` +: The Datadog site to upload results to.
+**Default**: `datadoghq.com`
+**Selected site**: {{< region-param key="dd_site" code="true" >}} +{{< /site-region >}} + +## Known issue with GitHub Actions If the job name does not match the entry defined in the workflow configuration file (the GitHub [job ID][3]), the `DD_GITHUB_JOB_NAME` environment variable needs to be exposed, pointing to the job name. For example: