Skip to content

Commit fe575cc

Browse files
committed
Enable metrics by default
1 parent 9cd6a06 commit fe575cc

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

CHANGELOG.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@
77
The SDK now supports Sentry's new [Trace Connected Metrics](https://docs.sentry.io/product/explore/metrics/) product.
88

99
```ruby
10-
Sentry.init do |config|
11-
# ...
12-
config.enable_metrics = true
13-
end
14-
1510
Sentry.metrics.count("button.click", 1, attributes: { button_id: "submit" })
1611
Sentry.metrics.distribution("response.time", 120.5, unit: "millisecond")
1712
Sentry.metrics.gauge("cpu.usage", 75.2, unit: "percent")
1813
```
1914

15+
Metrics is enabled by default and only activates once you use the above APIs. To disable completely:
16+
17+
```ruby
18+
Sentry.init do |config|
19+
# ...
20+
config.enable_metrics = false
21+
end
22+
```
23+
2024
- Support for tracing `Sequel` queries ([#2814](https://github.com/getsentry/sentry-ruby/pull/2814))
2125

2226
```ruby

sentry-ruby/lib/sentry/configuration.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ class Configuration
338338
# @return [Integer]
339339
attr_accessor :max_log_events
340340

341-
# Enable metrics collection
341+
# Enable metrics collection, defaults to true
342342
# @return [Boolean]
343343
attr_accessor :enable_metrics
344344

@@ -531,7 +531,7 @@ def initialize
531531
self.rack_env_whitelist = RACK_ENV_WHITELIST_DEFAULT
532532
self.traces_sampler = nil
533533
self.enable_logs = false
534-
self.enable_metrics = false
534+
self.enable_metrics = true
535535

536536
self.profiler_class = Sentry::Profiler
537537
self.profiles_sample_interval = DEFAULT_PROFILES_SAMPLE_INTERVAL

sentry-ruby/spec/sentry/configuration_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -759,13 +759,13 @@ class SentryConfigurationSample < Sentry::Configuration
759759
end
760760

761761
describe "#enable_metrics" do
762-
it "returns false by default" do
763-
expect(subject.enable_metrics).to eq(false)
762+
it "returns true by default" do
763+
expect(subject.enable_metrics).to eq(true)
764764
end
765765

766-
it "can be set to true" do
767-
subject.enable_metrics = true
768-
expect(subject.enable_metrics).to eq(true)
766+
it "can be set to false" do
767+
subject.enable_metrics = false
768+
expect(subject.enable_metrics).to eq(false)
769769
end
770770
end
771771

sentry-ruby/spec/sentry/metrics_spec.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
RSpec.describe "Sentry Metrics" do
44
before do
55
perform_basic_setup do |config|
6-
config.enable_metrics = true
76
config.traces_sample_rate = 1.0
87
config.release = "test-release"
98
config.environment = "test"
@@ -294,7 +293,6 @@
294293
context "with before_send_metric callback" do
295294
it "receives MetricEvent" do
296295
perform_basic_setup do |config|
297-
config.enable_metrics = true
298296
config.before_send_metric = lambda do |metric|
299297
expect(metric).to be_a(Sentry::MetricEvent)
300298
metric
@@ -307,7 +305,6 @@
307305

308306
it "allows modifying metrics before sending" do
309307
perform_basic_setup do |config|
310-
config.enable_metrics = true
311308
config.before_send_metric = lambda do |metric|
312309
metric.attributes["modified"] = true
313310
metric
@@ -324,7 +321,6 @@
324321

325322
it "filters out metrics when callback returns nil" do
326323
perform_basic_setup do |config|
327-
config.enable_metrics = true
328324
config.before_send_metric = lambda do |metric|
329325
metric.name == "test.filtered" ? nil : metric
330326
end

0 commit comments

Comments
 (0)