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



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

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

Instance Method Details

#process_action(*args) ⇒ Object



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

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



41
42
43
# File 'lib/telegram/bot/updates_controller/instrumentation.rb', line 41

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