![]() |
VOOZH | about |
Supported test frameworks:
testing packageTo report test results to Datadog, you need to configure the Datadog Go library:
We support auto-instrumentation for the following CI providers:
| CI Provider | Auto-Instrumentation method |
|---|---|
| GitHub Actions | Datadog Test Visibility Github Action |
| Jenkins | UI-based configuration with Datadog Jenkins plugin |
| GitLab | Datadog Test Visibility GitLab Script |
| CircleCI | Datadog Test Visibility CircleCI Orb |
If you are using auto-instrumentation for one of these providers, you can skip the rest of the setup steps below.
If you are using a cloud CI provider without access to the underlying worker nodes, such as GitHub Actions or CircleCI, configure the library to use the Agentless mode. For this, set the following environment variables:
DD_CIVISIBILITY_AGENTLESS_ENABLED=true (Required)falseDD_API_KEY (Required)(empty)Additionally, configure the Datadog site to which you want to send data.
DD_SITE (Required)datadoghq.comIf you are running tests on an on-premises CI provider, such as Jenkins or self-managed GitLab CI, install the Datadog Agent on each worker node by following the Agent installation instructions. This is the recommended option as it allows you to automatically link test results to logs and underlying host metrics.
If you are using a Kubernetes executor, Datadog recommends using the Datadog Operator. The operator includes Datadog Admission Controller which can automatically inject the tracer library into the build pods. Note: If you use the Datadog Operator, there is no need to download and inject the tracer library since the Admission Controller can do this for you, so you can skip the corresponding step below. However, you still need to make sure that your pods set the environment variables or command-line parameters necessary to enable Test Visibility.
If you are not using Kubernetes or can’t use the Datadog Admission Controller and the CI provider is using a container-based executor, set the DD_TRACE_AGENT_URL environment variable (which defaults to http://localhost:8126) in the build container running the tracer to an endpoint that is accessible from within that container. Note: Using localhost inside the build references the container itself and not the underlying worker node or any container where the Agent might be running in.
DD_TRACE_AGENT_URL includes the protocol and port (for example, http://localhost:8126) and takes precedence over DD_AGENT_HOST and DD_TRACE_AGENT_PORT, and is the recommended configuration parameter to configure the Datadog Agent’s URL for CI Visibility.
If you still have issues connecting to the Datadog Agent, use the Agentless Mode. Note: When using this method, tests are not correlated with logs and infrastructure metrics.
Orchestrion is a tool to process Go source code at compilation time and automatically insert instrumentation using dd-trace-go.
Install orchestrion from https://github.com/datadog/orchestrion using the command:
$ go install github.com/DataDog/orchestrion@latest
Orchestrion supports the two latest releases of Go, matching Go’s official release policy. It may function correctly with older Go releases, but Datadog cannot support older releases that do not work.
In addition to this, Orchestrion only supports projects using Go modules.
Set the following environment variables to configure the library:
DD_CIVISIBILITY_ENABLED=true (Required)DD_ENV (Required)local when running tests on a developer workstation or ci when running them on a CI provider).Prefix your go test command with orchestrion:
$ orchestrion go test -race ./...
If you have not run orchestrion pin, you may see a message similar to the following appear, as orchestrion pin is automatically executed:
╭──────────────────────────────────────────────────────────────────────────────╮
│ │
│ Warning: github.com/DataDog/orchestrion is not present in your go.mod │
│ file. │
│ In order to ensure build reliability and reproductibility, orchestrion │
│ will now add itself in your go.mod file by: │
│ │
│ 1. creating a new file named orchestrion.tool.go │
│ 2. running go get github.com/DataDog/orchestrion@v0.9.4 │
│ 3. running go mod tidy │
│ │
│ You should commit the resulting changes into your source control system. │
│ │
╰──────────────────────────────────────────────────────────────────────────────╯
Orchestrion at the core is a standard Go toolchain -toolexec proxy. Instead of using orchestrion go, you can
also manually provide the -toolexec argument to go commands that accept it:
$ go build -toolexec 'orchestrion toolexec' .
$ go test -toolexec 'orchestrion toolexec' -race .
Additional helpful documentation, links, and articles:
| |