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
6 changes: 0 additions & 6 deletions sentry-ruby/lib/sentry-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -655,12 +655,6 @@ def logger

# Returns the metrics API for capturing custom metrics.
#
# @example Enable metrics
# Sentry.init do |config|
# config.dsn = "YOUR_DSN"
# config.enable_metrics = true
# end
#
# @example Usage
# Sentry.metrics.count("button.click", 1, attributes: { button_id: "submit" })
# Sentry.metrics.distribution("response.time", 120.5, unit: "millisecond")
Expand Down
4 changes: 1 addition & 3 deletions sentry-ruby/lib/sentry/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ def initialize(configuration)

@log_event_buffer = LogEventBuffer.new(configuration, self)

if configuration.enable_metrics
@metric_event_buffer = MetricEventBuffer.new(configuration, self)
end
@metric_event_buffer = MetricEventBuffer.new(configuration, self)
end

# Applies the given scope's data to the event and sends it to Sentry.
Expand Down
5 changes: 0 additions & 5 deletions sentry-ruby/lib/sentry/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,6 @@ class Configuration
# @return [Integer]
attr_accessor :max_log_events

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

# Maximum number of metric events to buffer before sending
# @return [Integer]
attr_accessor :max_metric_events
Expand Down Expand Up @@ -586,7 +582,6 @@ def initialize
self.std_lib_logger_filter = nil
self.rack_env_whitelist = RACK_ENV_WHITELIST_DEFAULT
self.traces_sampler = nil
self.enable_metrics = true

self.profiler_class = Sentry::Profiler
self.profiles_sample_interval = DEFAULT_PROFILES_SAMPLE_INTERVAL
Expand Down
2 changes: 1 addition & 1 deletion sentry-ruby/lib/sentry/hub.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def capture_log_event(message, **options)
# @param attributes [Hash, nil] (optional) additional attributes for the metric
# @return [void]
def capture_metric(name:, type:, value:, unit: nil, attributes: nil)
return unless current_client&.configuration.enable_metrics
return unless current_client

metric = MetricEvent.new(
name: name,
Expand Down
11 changes: 0 additions & 11 deletions sentry-ruby/spec/sentry/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -868,17 +868,6 @@ class SentryConfigurationSample < Sentry::Configuration
end
end

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

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

describe "#max_metric_events" do
it "returns 1000 by default" do
expect(subject.max_metric_events).to eq(1000)
Expand Down
25 changes: 4 additions & 21 deletions sentry-ruby/spec/sentry/hub_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -684,28 +684,11 @@
end

describe "#capture_metric" do
context "when metrics are disabled" do
before do
configuration.enable_metrics = false
end

it "doesn't buffer the metric" do
expect(subject.current_client).not_to receive(:buffer_metric_event)
it "creates and buffers a MetricEvent" do
expect(subject.current_client).to receive(:buffer_metric_event).and_call_original
expect do
subject.capture_metric(name: "test", type: :counter, value: 1)
end
end

context "when metrics are enabled" do
before do
configuration.enable_metrics = true
end

it "creates and buffers a MetricEvent" do
expect(subject.current_client).to receive(:buffer_metric_event).and_call_original
expect do
subject.capture_metric(name: "test", type: :counter, value: 1)
end.to change { subject.current_client.metric_event_buffer.size }.by(1)
end
end.to change { subject.current_client.metric_event_buffer.size }.by(1)
end
end

Expand Down
Loading
Loading