From b44c92761b4688e749cdef35bcc78b1e14970a41 Mon Sep 17 00:00:00 2001 From: Andrey Marchenko Date: Thu, 17 Aug 2023 15:41:32 +0200 Subject: [PATCH] readme instructions for minitest, add options explanations --- README.md | 74 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 6ef10aba..4cc02f5e 100644 --- a/README.md +++ b/README.md @@ -13,11 +13,14 @@ end ## Usage -#### Cucumber +### RSpec -Activate `Cucumber` integration with configuration +To activate `RSpec` integration, add this to the `spec_helper.rb` file: + +```ruby +require 'rspec' +require 'datadog/ci' -``` Datadog.configure do |c| # Only activates test instrumentation on CI c.tracing.enabled = (ENV["DD_ENV"] == "ci") @@ -28,20 +31,32 @@ Datadog.configure do |c| # The name of the service or library under test c.service = 'my-ruby-app' - # Enables the Cucumber instrumentation - c.ci.instrument :cucumber + # Enables the RSpec instrumentation + c.ci.instrument :rspec, **options end ``` -#### RSpec +`options` are the following keyword arguments: -To activate `RSpec` integration, add this to the `spec_helper.rb` file: +| 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'` | -``` -require 'rspec' + +### Minitest + +The Minitest integration will trace all executions of tests when using `minitest` test framework. + +To activate your integration, use the `Datadog.configure` method: + +```ruby +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") @@ -52,12 +67,49 @@ Datadog.configure do |c| # The name of the service or library under test c.service = 'my-ruby-app' - # Enables the RSpec instrumentation - c.ci.instrument :rspec + 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 + +```ruby +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'` | + ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.