class RorVsWild::Plugin::Mongo

Attributes

commands[R]

Public Class Methods

new() click to toggle source
# File lib/rorvswild/plugin/mongo.rb, line 13
def initialize
  @commands = {}
end
setup() click to toggle source
# File lib/rorvswild/plugin/mongo.rb, line 4
def self.setup
  return if @installed
  return if !defined?(::Mongo::Monitoring::Global)
  ::Mongo::Monitoring::Global.subscribe(::Mongo::Monitoring::COMMAND, Mongo.new)
  @installed = true
end

Public Instance Methods

after_query(event) click to toggle source
# File lib/rorvswild/plugin/mongo.rb, line 30
def after_query(event)
  RorVsWild::Section.stop do |section|
    section.kind = "mongo".freeze
    section.command = commands.delete(event.request_id).to_s
  end
end
failed(event) click to toggle source
# File lib/rorvswild/plugin/mongo.rb, line 22
def failed(event)
  after_query(event)
end
started(event) click to toggle source
# File lib/rorvswild/plugin/mongo.rb, line 17
def started(event)
  RorVsWild::Section.start
  commands[event.request_id] = event.command
end
succeeded(event) click to toggle source
# File lib/rorvswild/plugin/mongo.rb, line 26
def succeeded(event)
  after_query(event)
end