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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Unreleased

- Skip creating `LogEventBuffer` if logging is not enabled ([#2652](https://github.com/getsentry/sentry-ruby/pull/2652))

## 5.25.0

### Features
Expand Down
6 changes: 4 additions & 2 deletions sentry-ruby/lib/sentry/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ def initialize(configuration)

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

@log_event_buffer = LogEventBuffer.new(configuration, self).start
if configuration.enable_logs
@log_event_buffer = LogEventBuffer.new(configuration, self).start
end
end

# Applies the given scope's data to the event and sends it to Sentry.
Expand Down Expand Up @@ -114,7 +116,7 @@ def capture_envelope(envelope)
def flush
transport.flush if configuration.sending_to_dsn_allowed?
spotlight_transport.flush if spotlight_transport
@log_event_buffer.flush
@log_event_buffer&.flush
end

# Initializes an Event object with the given exception. Returns `nil` if the exception's class is excluded from reporting.
Expand Down
1 change: 1 addition & 0 deletions sentry-ruby/spec/sentry/log_event_buffer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
config.sdk_logger = logger
config.background_worker_threads = 0
config.max_log_events = max_log_events
config.enable_logs = true
end

Sentry.background_worker = Sentry::BackgroundWorker.new(Sentry.configuration)
Expand Down
4 changes: 2 additions & 2 deletions sentry-ruby/spec/sentry/session_flusher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@
it "spawns new thread" do
expect do
subject.add_session(session)
end.to change { Thread.list.count }.by(2)
end.to change { Thread.list.count }.by(1)

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

it "spawns only one thread" do
expect do
subject.add_session(session)
end.to change { Thread.list.count }.by(2)
end.to change { Thread.list.count }.by(1)

thread = subject.instance_variable_get(:@thread)
expect(thread).to receive(:alive?).and_return(true)
Expand Down
1 change: 1 addition & 0 deletions sentry-ruby/spec/sentry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@
describe ".capture_log" do
before do
perform_basic_setup do |config|
config.enable_logs = true
config.traces_sample_rate = 1.0
config.max_log_events = 1
end
Expand Down
Loading