Class: Mongo::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/glimpse/views/mongo.rb

Overview

Instrument Mongo time

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.command_countObject

Returns the value of attribute command_count.



14
15
16
# File 'lib/glimpse/views/mongo.rb', line 14

def command_count
  @command_count
end

.command_timeObject

Returns the value of attribute command_time.



14
15
16
# File 'lib/glimpse/views/mongo.rb', line 14

def command_time
  @command_time
end

Instance Method Details

#receive_message_with_timing(*args) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/glimpse/views/mongo.rb', line 39

def receive_message_with_timing(*args)
  start = Time.now
  receive_message_without_timing(*args)
ensure
  duration = (Time.now - start)
  Mongo::Connection.command_time.update { |value| value + duration }
  Mongo::Connection.command_count.update { |value| value + 1 }
end

#send_message_with_gle_with_timing(*args) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/glimpse/views/mongo.rb', line 29

def send_message_with_gle_with_timing(*args)
  start = Time.now
  send_message_with_gle_without_timing(*args)
ensure
  duration = (Time.now - start)
  Mongo::Connection.command_time.update { |value| value + duration }
  Mongo::Connection.command_count.update { |value| value + 1 }
end

#send_message_with_timing(*args) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/glimpse/views/mongo.rb', line 19

def send_message_with_timing(*args)
  start = Time.now
  send_message_without_timing(*args)
ensure
  duration = (Time.now - start)
  Mongo::Connection.command_time.update { |value| value + duration }
  Mongo::Connection.command_count.update { |value| value + 1 }
end