The Cucumber integration traces executions of scenarios and steps when using the cucumber framework.
To activate your integration, add the following code to your application:
require'cucumber'require'datadog/ci'Datadog.configuredo|c|# Only activates test instrumentation on CIc.tracing.enabled=(ENV["DD_ENV"]=="ci")# Configures the tracer to ensure results deliveryc.ci.enabled=true# The name of the service or library under testc.service='my-ruby-app'# Enables the Cucumber instrumentationc.ci.instrument:cucumberend
Run your tests as you normally do, specifying the environment where test are being run (for example, local when running tests on a developer workstation, or ci when running them on a CI provider) in the DD_ENV environment variable. For example:
DD_ENV=ci bundle exec rake cucumber
The RSpec integration traces all executions of example groups and examples when using the rspec test framework.
To activate your integration, add this to the spec_helper.rb file:
require'rspec'require'datadog/ci'Datadog.configuredo|c|# Only activates test instrumentation on CIc.tracing.enabled=(ENV["DD_ENV"]=="ci")# Configures the tracer to ensure results deliveryc.ci.enabled=true# The name of the service or library under testc.service='my-ruby-app'# Enables the RSpec instrumentationc.ci.instrument:rspecend
Run your tests as you normally do, specifying the environment where test are being run (for example, local when running tests on a developer workstation, or ci when running them on a CI provider) in the DD_ENV environment variable. For example:
DD_ENV=ci bundle exec rake spec
Configuration settings
The following is a list of the most important configuration settings that can be used with the tracer, either in code by using a Datadog.configure block, or using environment variables:
service
Name of the service or library under test. Environment variable: DD_SERVICE Default: $PROGRAM_NAME Example: my-ruby-app
env
Name of the environment where tests are being run. Environment variable: DD_ENV Default: none Examples: local, ci
The following environment variable can be used to configure the location of the Datadog Agent:
DD_TRACE_AGENT_URL
Datadog Agent URL for trace collection in the form http://hostname:port. Default: http://localhost:8126
Datadog uses Git information for visualizing your test results and grouping them by repository, branch, and commit. Git metadata is automatically collected by the test instrumentation from CI provider environment variables and the local .git folder in the project path, if available.
If you are running tests in non-supported CI providers or with no .git folder, you can set the Git information manually using environment variables. These environment variables take precedence over any auto-detected information. Set the following environment variables to provide Git information:
DD_GIT_REPOSITORY_URL
URL of the repository where the code is stored. Both HTTP and SSH URLs are supported. Example: git@github.com:MyCompany/MyApp.git, https://github.com/MyCompany/MyApp.git
DD_GIT_BRANCH
Git branch being tested. Leave empty if providing tag information instead. Example: develop
DD_GIT_TAG
Git tag being tested (if applicable). Leave empty if providing branch information instead. Example: 1.0.1
DD_GIT_COMMIT_SHA
Full commit hash. Example: a18ebf361cc831f5535e58ec4fae04ffd98d8152
DD_GIT_COMMIT_MESSAGE
Commit message. Example: Set release number
DD_GIT_COMMIT_AUTHOR_NAME
Commit author name. Example: John Smith
DD_GIT_COMMIT_AUTHOR_EMAIL
Commit author email. Example: john@example.com
DD_GIT_COMMIT_AUTHOR_DATE
Commit author date in ISO 8601 format. Example: 2021-03-12T16:00:28Z
DD_GIT_COMMIT_COMMITTER_NAME
Commit committer name. Example: Jane Smith
DD_GIT_COMMIT_COMMITTER_EMAIL
Commit committer email. Example: jane@example.com
DD_GIT_COMMIT_COMMITTER_DATE
Commit committer date in ISO 8601 format. Example: 2021-03-12T16:00:28Z
Further reading
Additional helpful documentation, links, and articles: