Class: Lamian::Engine
- Inherits:
-
Rails::Engine
- Object
- Rails::Engine
- Lamian::Engine
- Defined in:
- lib/lamian/engine.rb
Overview
This engine is automatically loaded by Rails
Instance Method Summary collapse
-
#build_default_lambda ⇒ Proc
Builds a callback, which does nothing.
-
#build_lamian_callback ⇒ Proc
Builds a callback that adds logs to the event.
-
#rebuild_before_send ⇒ Proc
Reassembles the callback that runs before sending the event to the Sentry: connects the user callback with the callback that adds lamian logs to the event.
Instance Method Details
#build_default_lambda ⇒ Proc
Builds a callback, which does nothing.
44 45 46 |
# File 'lib/lamian/engine.rb', line 44 def build_default_lambda -> (event, _hint) { event } end |
#build_lamian_callback ⇒ Proc
Builds a callback that adds logs to the event.
51 52 53 54 55 56 57 58 59 |
# File 'lib/lamian/engine.rb', line 51 def build_lamian_callback lambda do |event| event.tap do |event| extra = event&.extra or return log = Lamian.dump_limited extra[Lamian::SENTRY_EXTRA_KEY] = log if log end end end |
#rebuild_before_send ⇒ Proc
Reassembles the callback that runs before sending the event to the Sentry: connects the user callback with the callback that adds lamian logs to the event.
34 35 36 37 38 39 |
# File 'lib/lamian/engine.rb', line 34 def rebuild_before_send defined_callback = Sentry.configuration.before_send || build_default_lambda lamian_callback = build_lamian_callback proc { |*args, **kwargs| lamian_callback.call(defined_callback.call(*args, **kwargs)) } end |