Skip to content

Commit 233e17a

Browse files
committed
Skip creating LogEventBuffer if logging is not enabled
1 parent 5fdf3be commit 233e17a

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

sentry-ruby/lib/sentry/client.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ def initialize(configuration)
4242

4343
@spotlight_transport = SpotlightTransport.new(configuration) if configuration.spotlight
4444

45-
@log_event_buffer = LogEventBuffer.new(configuration, self).start
45+
if configuration.enable_logs
46+
@log_event_buffer = LogEventBuffer.new(configuration, self).start
47+
end
4648
end
4749

4850
# Applies the given scope's data to the event and sends it to Sentry.
@@ -114,7 +116,7 @@ def capture_envelope(envelope)
114116
def flush
115117
transport.flush if configuration.sending_to_dsn_allowed?
116118
spotlight_transport.flush if spotlight_transport
117-
@log_event_buffer.flush
119+
@log_event_buffer&.flush
118120
end
119121

120122
# Initializes an Event object with the given exception. Returns `nil` if the exception's class is excluded from reporting.

sentry-ruby/spec/sentry/session_flusher_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@
103103
it "spawns new thread" do
104104
expect do
105105
subject.add_session(session)
106-
end.to change { Thread.list.count }.by(2)
106+
end.to change { Thread.list.count }.by(1)
107107

108108
expect(subject.instance_variable_get(:@thread)).to be_a(Thread)
109109
end
110110

111111
it "spawns only one thread" do
112112
expect do
113113
subject.add_session(session)
114-
end.to change { Thread.list.count }.by(2)
114+
end.to change { Thread.list.count }.by(1)
115115

116116
thread = subject.instance_variable_get(:@thread)
117117
expect(thread).to receive(:alive?).and_return(true)

sentry-ruby/spec/sentry_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@
354354
describe ".capture_log" do
355355
before do
356356
perform_basic_setup do |config|
357+
config.enable_logs = true
357358
config.traces_sample_rate = 1.0
358359
config.max_log_events = 1
359360
end

0 commit comments

Comments
 (0)