Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,20 @@
The SDK now supports Sentry's new [Trace Connected Metrics](https://docs.sentry.io/product/explore/metrics/) product.

```ruby
Sentry.init do |config|
# ...
config.enable_metrics = true
end

Sentry.metrics.count("button.click", 1, attributes: { button_id: "submit" })
Sentry.metrics.distribution("response.time", 120.5, unit: "millisecond")
Sentry.metrics.gauge("cpu.usage", 75.2, unit: "percent")
```

Metrics is enabled by default and only activates once you use the above APIs. To disable completely:

```ruby
Sentry.init do |config|
# ...
config.enable_metrics = false
end
```

- Support for tracing `Sequel` queries ([#2814](https://github.com/getsentry/sentry-ruby/pull/2814))

```ruby
Expand Down
4 changes: 2 additions & 2 deletions sentry-ruby/lib/sentry/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ class Configuration
# @return [Integer]
attr_accessor :max_log_events

# Enable metrics collection
# Enable metrics collection, defaults to true
# @return [Boolean]
attr_accessor :enable_metrics

Expand Down Expand Up @@ -531,7 +531,7 @@ def initialize
self.rack_env_whitelist = RACK_ENV_WHITELIST_DEFAULT
self.traces_sampler = nil
self.enable_logs = false
self.enable_metrics = false
self.enable_metrics = true

self.profiler_class = Sentry::Profiler
self.profiles_sample_interval = DEFAULT_PROFILES_SAMPLE_INTERVAL
Expand Down
10 changes: 5 additions & 5 deletions sentry-ruby/spec/sentry/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -759,13 +759,13 @@ class SentryConfigurationSample < Sentry::Configuration
end

describe "#enable_metrics" do
it "returns false by default" do
expect(subject.enable_metrics).to eq(false)
it "returns true by default" do
expect(subject.enable_metrics).to eq(true)
end

it "can be set to true" do
subject.enable_metrics = true
expect(subject.enable_metrics).to eq(true)
it "can be set to false" do
subject.enable_metrics = false
expect(subject.enable_metrics).to eq(false)
end
end

Expand Down
4 changes: 0 additions & 4 deletions sentry-ruby/spec/sentry/metrics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
RSpec.describe "Sentry Metrics" do
before do
perform_basic_setup do |config|
config.enable_metrics = true
config.traces_sample_rate = 1.0
config.release = "test-release"
config.environment = "test"
Expand Down Expand Up @@ -294,7 +293,6 @@
context "with before_send_metric callback" do
it "receives MetricEvent" do
perform_basic_setup do |config|
config.enable_metrics = true
config.before_send_metric = lambda do |metric|
expect(metric).to be_a(Sentry::MetricEvent)
metric
Expand All @@ -307,7 +305,6 @@

it "allows modifying metrics before sending" do
perform_basic_setup do |config|
config.enable_metrics = true
config.before_send_metric = lambda do |metric|
metric.attributes["modified"] = true
metric
Expand All @@ -324,7 +321,6 @@

it "filters out metrics when callback returns nil" do
perform_basic_setup do |config|
config.enable_metrics = true
config.before_send_metric = lambda do |metric|
metric.name == "test.filtered" ? nil : metric
end
Expand Down
Loading