Module: Telegram::Bot::UpdatesController::Instrumentation

Extended by:
ActiveSupport::Concern
Included in:
Telegram::Bot::UpdatesController
Defined in:
lib/telegram/bot/updates_controller/instrumentation.rb

Overview

Most methods are taken from ActionController::Instrumentation, some are slightly modified.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.instrument(action, *args, &block) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/telegram/bot/updates_controller/instrumentation.rb', line 14

def instrument(action, *args, &block)
  ActiveSupport::Notifications.instrument(
    "#{action}.updates_controller.bot.telegram",
    *args,
    &block
  )
end

Instance Method Details

#process_action(*args) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/telegram/bot/updates_controller/instrumentation.rb', line 23

def process_action(*args)
  raw_payload = {
    controller: self.class.name,
    action:     action_name,
    update:     update,
  }
  Instrumentation.instrument(:start_processing, raw_payload.dup)
  Instrumentation.instrument(:process_action, raw_payload) do |payload|
    begin
      super
    ensure
      append_info_to_payload(payload)
    end
  end
end

#respond_with(type) ⇒ Object



39
40
41
# File 'lib/telegram/bot/updates_controller/instrumentation.rb', line 39

def respond_with(type, *)
  Instrumentation.instrument(:respond_with, type: type) { super }
end