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
2 changes: 2 additions & 0 deletions sentry-ruby/lib/sentry-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ def close
if client = get_current_client
client.configuration.run_after_close_callbacks
client.flush
client.log_event_buffer.kill
client.metric_event_buffer.kill

if client.configuration.data_collection.collect_stack_frame_variables?
exception_locals_tp.disable
Expand Down
4 changes: 2 additions & 2 deletions sentry-ruby/lib/sentry/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ def capture_envelope(envelope)
def flush
transport.flush if configuration.sending_to_dsn_allowed?
spotlight_transport.flush if spotlight_transport
@log_event_buffer&.flush
@metric_event_buffer&.flush
@log_event_buffer.flush
@metric_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
15 changes: 15 additions & 0 deletions sentry-ruby/spec/sentry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,21 @@
described_class.close
end

it "kills telemetry workers" do
client = described_class.get_current_client
client.log_event_buffer.add_item(Sentry::LogEvent.new(level: :info, body: "log"))
client.metric_event_buffer.add_item(Sentry::MetricEvent.new(name: "metric", type: :counter, value: 1))
log_thread = client.log_event_buffer.thread
metric_thread = client.metric_event_buffer.thread

described_class.close

expect(log_thread.join(1)).to eq(log_thread)
expect(metric_thread.join(1)).to eq(metric_thread)
expect(log_thread).not_to be_alive
expect(metric_thread).not_to be_alive
end

it "flushes session flusher" do
expect(described_class.session_flusher).to receive(:flush)
described_class.close
Expand Down
Loading