Project

datadog-ci

0.0
The project is in a healthy, maintained state
datadog-ci is a Datadog's CI visibility library for Ruby. It traces tests as they are being executed and brings developers visibility into their CI pipelines.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
 Dependencies
 Project Readme

Datadog CI Visibility for Ruby

Gem Version codecov CircleCI

Datadog's Ruby Library for instrumenting your test and continuous integration pipeline. Learn more on our official website.

Important
The datadog-ci gem is currently a component of ddtrace and should not be used without it.

We expect this to change in the future.

Installation

Add to your Gemfile.

gem "ddtrace"

Usage

RSpec

To activate RSpec integration, add this to the spec_helper.rb file:

require 'rspec'
require 'datadog/ci'

Datadog.configure do |c|
  # Only activates test instrumentation on CI
  c.tracing.enabled = (ENV["DD_ENV"] == "ci")

  # Configures the tracer to ensure results delivery
  c.ci.enabled = true

  # The name of the service or library under test
  c.service = 'my-ruby-app'

  # Enables the RSpec instrumentation
  c.ci.instrument :rspec, **options
end

options are the following keyword arguments:

Key Description Default
enabled Defines whether RSpec tests should be traced. Useful for temporarily disabling tracing. true or false true
service_name Service name used for rspec instrumentation. 'rspec'
operation_name Operation name used for rspec instrumentation. Useful if you want rename automatic trace metrics e.g. trace.#{operation_name}.errors. 'rspec.example'

Minitest

The Minitest integration will trace all executions of tests when using minitest test framework.

To activate your integration, use the Datadog.configure method:

require 'minitest'
require 'datadog/ci'

# Configure default Minitest integration
Datadog.configure do |c|
  # Only activates test instrumentation on CI
  c.tracing.enabled = (ENV["DD_ENV"] == "ci")

  # Configures the tracer to ensure results delivery
  c.ci.enabled = true

  # The name of the service or library under test
  c.service = 'my-ruby-app'

  c.ci.instrument :minitest, **options
end

options are the following keyword arguments:

Key Description Default
enabled Defines whether Minitest tests should be traced. Useful for temporarily disabling tracing. true or false true
service_name Service name used for minitest instrumentation. 'minitest'
operation_name Operation name used for minitest instrumentation. Useful if you want rename automatic trace metrics e.g. trace.#{operation_name}.errors. 'minitest.test'

Cucumber

Activate Cucumber integration with configuration

require 'cucumber'
require 'datadog/ci'

Datadog.configure do |c|
  # Only activates test instrumentation on CI
  c.tracing.enabled = (ENV["DD_ENV"] == "ci")

  # Configures the tracer to ensure results delivery
  c.ci.enabled = true

  # The name of the service or library under test
  c.service = 'my-ruby-app'

  # Enables the Cucumber instrumentation
  c.ci.instrument :cucumber, **options
end

options are the following keyword arguments:

Key Description Default
enabled Defines whether Cucumber tests should be traced. Useful for temporarily disabling tracing. true or false true
service_name Service name used for cucumber instrumentation. 'cucumber'
operation_name Operation name used for cucumber instrumentation. Useful if you want rename automatic trace metrics e.g. trace.#{operation_name}.errors. 'cucumber.test'

Contributing

See development guide, static typing guide and contributing guidelines.

Code of Conduct

Everyone interacting in the Datadog::CI project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.