Skip to content

Commit

Permalink
readme instructions for minitest, add options explanations
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Aug 17, 2023
1 parent e592b8c commit b44c927
Showing 1 changed file with 63 additions and 11 deletions.
74 changes: 63 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand All @@ -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.
Expand Down

0 comments on commit b44c927

Please sign in to comment.