Method: Sentry.close

Defined in:
lib/sentry-ruby.rb

.closevoid

This method returns an undefined value.

Flushes pending events and cleans up SDK state. SDK will stop sending events and all top-level APIs will be no-ops after this.


261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/sentry-ruby.rb', line 261

def close
  if @session_flusher
    @session_flusher.flush
    @session_flusher.kill
    @session_flusher = nil
  end

  if @backpressure_monitor
    @backpressure_monitor.kill
    @backpressure_monitor = nil
  end

  if @metrics_aggregator
    @metrics_aggregator.flush(force: true)
    @metrics_aggregator.kill
    @metrics_aggregator = nil
  end

  if client = get_current_client
    client.flush

    if client.configuration.include_local_variables
      exception_locals_tp.disable
    end
  end

  @background_worker.shutdown

  MUTEX.synchronize do
    @main_hub = nil
    Thread.current.thread_variable_set(THREAD_LOCAL, nil)
  end
end