Class: RequestTrail::Subscriber

Inherits:
Object
  • Object
show all
Defined in:
lib/request_trail/subscriber.rb

Constant Summary collapse

SQL_EVENT =
"sql.active_record"
CACHE_READ_EVENT =
"cache_read.active_support"
CACHE_WRITE_EVENT =
"cache_write.active_support"
ACTION_EVENT =
"process_action.action_controller"
HTTP_EVENT =
"request.faraday"

Class Method Summary collapse

Class Method Details

.attachObject



11
12
13
14
# File 'lib/request_trail/subscriber.rb', line 11

def self.attach
  @attach ||= [sql_subscription, cache_read_subscription, cache_write_subscription,
               action_subscription, http_subscription]
end

.detachObject



16
17
18
19
20
21
# File 'lib/request_trail/subscriber.rb', line 16

def self.detach
  return unless @attach

  @attach&.each { |sub| ActiveSupport::Notifications.unsubscribe(sub) }
  @attach = nil
end