GitHub Action
Configure Datadog Test Visibility
GitHub Action that installs and configures Datadog Test Visibility. Supported languages are .NET, Java, Javascript, and Python.
Test Visibility provides a test-first view into your CI health by displaying important metrics and results from your tests. It can help you investigate and mitigate performance problems and test failures that are most relevant to your work, focusing on the code you are responsible for, rather than the pipelines which run your tests.
-
Set Datadog API key inside Settings > Secrets as
DD_API_KEY
. -
Add a step to your GitHub Actions workflow YAML that uses this action. Set the language, service name and site parameters:
steps: - name: Configure Datadog Test Visibility uses: datadog/[email protected] with: languages: java service-name: my-service api-key: ${{ secrets.DD_API_KEY }} site: datadoghq.com # Change if your site is not US1 - name: Run unit tests run: | mvn clean test
Important
It is best if the new step comes right before the step that runs your tests.
Otherwise, installed tracing libraries might be removed by the steps that precede tests execution
(for example, actions/checkout
will wipe out whatever was installed in the action workspace).
The action has the following parameters:
languages: List of languages to be instrumented. It can be either "all" or any of "java", "js", "python", "dotnet" (multiple languages can be specified as a space-separated list).
service-name: The name of the service or library being tested.
api-key: Datadog API key. Can be found at https://app.datadoghq.com/organization-settings/api-keys
site: Datadog site (optional), defaults to datadoghq.com. See https://docs.datadoghq.com/getting_started/site for more information about sites. It can be "datadoghq.com", "us3.datadoghq.com", "us5.datadoghq.com", "datadoghq.eu" or "ap1.datadoghq.com".
Any additional configuration values can be added directly to the step that runs your tests:
- name: Run unit tests
run: |
mvn clean test
env:
DD_ENV: staging-tests
DD_TAGS: layer:api,team:intake,key:value
For security reasons Github does not allow actions to alter the NODE_OPTIONS
environment variable.
To work around this, the action provides a separate DD_TRACE_PACKAGE
variable that needs to be appended to node options manually:
- name: Run tests
shell: bash
run: npm run test-ci
env:
NODE_OPTIONS: -r ${{ env.DD_TRACE_PACKAGE }}