class QueryTrack::EventProcessor

Attributes

event[R]
subscriber[R]

Public Class Methods

new(event, subscriber) click to toggle source
# File lib/query_track/event_processor.rb, line 5
def initialize(event, subscriber)
  @event = event
  @subscriber = subscriber
end

Public Instance Methods

call() click to toggle source
# File lib/query_track/event_processor.rb, line 10
def call
  unsubscribe
  return unless QueryTrack::Settings.config.duration && QueryTrack::Settings.config.enabled

  return if under_filter?(caller)

  if duration_seconds > QueryTrack::Settings.config.duration
    QueryTrack::Notifications::Slack.new(event.payload[:sql], duration_seconds).call
    QueryTrack::Notifications::Log.new(event.payload[:sql], duration_seconds).call
    QueryTrack::Notifications::Custom.new(event.payload[:sql], duration_seconds).call
  end
end

Private Instance Methods

duration_seconds() click to toggle source
# File lib/query_track/event_processor.rb, line 31
def duration_seconds
  event.duration / 1000
end
under_filter?(trace) click to toggle source
# File lib/query_track/event_processor.rb, line 35
def under_filter?(trace)
  QueryTrack::Filters.new(caller).call
end
unsubscribe() click to toggle source
# File lib/query_track/event_processor.rb, line 25
def unsubscribe
  return if QueryTrack::Settings.config.enabled

  ActiveSupport::Notifications.unsubscribe(subscriber)
end