Class: AwesomeExplain::Subscribers::CommandSubscriber

Inherits:
Object
  • Object
show all
Includes:
Mongodb::CommandStart, Mongodb::CommandSuccess, Mongodb::Formatter, Mongodb::Helpers
Defined in:
lib/awesome_explain/subscribers/command_subscriber.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ CommandSubscriber

Returns a new instance of CommandSubscriber.



11
12
13
14
# File 'lib/awesome_explain/subscribers/command_subscriber.rb', line 11

def initialize(options = {})
  init(options)
  @logger = ::AwesomeExplain::Config.instance.logger
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



8
9
10
# File 'lib/awesome_explain/subscribers/command_subscriber.rb', line 8

def logger
  @logger
end

#optionsObject

Returns the value of attribute options.



9
10
11
# File 'lib/awesome_explain/subscribers/command_subscriber.rb', line 9

def options
  @options
end

#queriesObject

Returns the value of attribute queries.



9
10
11
# File 'lib/awesome_explain/subscribers/command_subscriber.rb', line 9

def queries
  @queries
end

#statsObject

Returns the value of attribute stats.



9
10
11
# File 'lib/awesome_explain/subscribers/command_subscriber.rb', line 9

def stats
  @stats
end

Instance Method Details

#clearObject



38
39
40
# File 'lib/awesome_explain/subscribers/command_subscriber.rb', line 38

def clear
  init
end

#failed(event) ⇒ Object



28
29
# File 'lib/awesome_explain/subscribers/command_subscriber.rb', line 28

def failed(event)
end

#get(metric) ⇒ Object



31
32
33
34
35
36
# File 'lib/awesome_explain/subscribers/command_subscriber.rb', line 31

def get(metric)
  case metric
  when :total_performed_queries
    total_performed_queries
  end
end

#started(event) ⇒ Object



16
17
18
19
20
# File 'lib/awesome_explain/subscribers/command_subscriber.rb', line 16

def started(event)
  unless COMMAND_NAMES_BLACKLIST.include?(event.command_name)
    handle_command_start(event)
  end
end

#succeeded(event) ⇒ Object



22
23
24
25
26
# File 'lib/awesome_explain/subscribers/command_subscriber.rb', line 22

def succeeded(event)
  unless COMMAND_NAMES_BLACKLIST.include?(event.command_name)
    handle_command_success(event)
  end
end