Module: Tobox::Plugins::Sentry

Defined in:
lib/tobox/plugins/sentry.rb

Defined Under Namespace

Modules: ConfigurationMethods Classes: Configuration, EventHandler

Class Method Summary collapse

Class Method Details

.configure(config) ⇒ Object



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/tobox/plugins/sentry.rb', line 138

def configure(config)
  event_handler = EventHandler.new(config)
  config.on_before_event(&event_handler.method(:on_start))
  config.on_after_event(&event_handler.method(:on_finish))
  config.on_error_event(&event_handler.method(:on_error))

  config.on_error_worker do |error|
    ::Sentry.capture_exception(error, hint: { background: false })
  end

  ::Sentry::Configuration.attr_reader(:tobox)
  ::Sentry::Configuration.add_post_initialization_callback do
    @tobox = Plugins::Sentry::Configuration.new
  end

  register_integration name: "tobox", version: Tobox::VERSION

  config.on_start do
    ::Sentry.init do |sentry_cfg|
      Array(config.lifecycle_events[:sentry_init]).each do |cb|
        cb[sentry_cfg]
      end
    end
  end
end

.load_dependenciesObject



131
132
133
134
135
136
# File 'lib/tobox/plugins/sentry.rb', line 131

def load_dependencies(*)
  require "uri"
  require "sentry-ruby"
  require "sentry/integrable"
  extend ::Sentry::Integrable
end