glimpse-mongo 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +5 -1
- data/glimpse-mongo.gemspec +1 -0
- data/lib/glimpse-mongo/version.rb +1 -1
- data/lib/glimpse/views/mongo.rb +16 -12
- metadata +18 -2
data/CHANGELOG.md
CHANGED
data/glimpse-mongo.gemspec
CHANGED
data/lib/glimpse/views/mongo.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'mongo'
|
2
|
+
require 'atomic'
|
2
3
|
|
3
4
|
# At the deepest of all commands in mongo go to Mongo::Connection
|
4
5
|
# and the following methods:
|
@@ -12,15 +13,16 @@ class Mongo::Connection
|
|
12
13
|
class << self
|
13
14
|
attr_accessor :command_time, :command_count
|
14
15
|
end
|
15
|
-
self.command_count = 0
|
16
|
-
self.command_time = 0
|
16
|
+
self.command_count = Atomic.new(0)
|
17
|
+
self.command_time = Atomic.new(0)
|
17
18
|
|
18
19
|
def send_message_with_timing(*args)
|
19
20
|
start = Time.now
|
20
21
|
send_message_without_timing(*args)
|
21
22
|
ensure
|
22
|
-
|
23
|
-
Mongo::Connection.
|
23
|
+
duration = (Time.now - start)
|
24
|
+
Mongo::Connection.command_time.update { |value| value + duration }
|
25
|
+
Mongo::Connection.command_count.update { |value| value + 1 }
|
24
26
|
end
|
25
27
|
alias_method_chain :send_message, :timing
|
26
28
|
|
@@ -28,8 +30,9 @@ class Mongo::Connection
|
|
28
30
|
start = Time.now
|
29
31
|
send_message_with_gle_without_timing(*args)
|
30
32
|
ensure
|
31
|
-
|
32
|
-
Mongo::Connection.
|
33
|
+
duration = (Time.now - start)
|
34
|
+
Mongo::Connection.command_time.update { |value| value + duration }
|
35
|
+
Mongo::Connection.command_count.update { |value| value + 1 }
|
33
36
|
end
|
34
37
|
alias_method_chain :send_message_with_gle, :timing
|
35
38
|
|
@@ -37,8 +40,9 @@ class Mongo::Connection
|
|
37
40
|
start = Time.now
|
38
41
|
receive_message_without_timing(*args)
|
39
42
|
ensure
|
40
|
-
|
41
|
-
Mongo::Connection.
|
43
|
+
duration = (Time.now - start)
|
44
|
+
Mongo::Connection.command_time.update { |value| value + duration }
|
45
|
+
Mongo::Connection.command_count.update { |value| value + 1 }
|
42
46
|
end
|
43
47
|
alias_method_chain :receive_message, :timing
|
44
48
|
end
|
@@ -47,7 +51,7 @@ module Glimpse
|
|
47
51
|
module Views
|
48
52
|
class Mongo < View
|
49
53
|
def duration
|
50
|
-
::Mongo::Connection.command_time
|
54
|
+
::Mongo::Connection.command_time.value
|
51
55
|
end
|
52
56
|
|
53
57
|
def formatted_duration
|
@@ -60,7 +64,7 @@ module Glimpse
|
|
60
64
|
end
|
61
65
|
|
62
66
|
def calls
|
63
|
-
::Mongo::Connection.command_count
|
67
|
+
::Mongo::Connection.command_count.value
|
64
68
|
end
|
65
69
|
|
66
70
|
def results
|
@@ -72,8 +76,8 @@ module Glimpse
|
|
72
76
|
def setup_subscribers
|
73
77
|
# Reset each counter when a new request starts
|
74
78
|
before_request do
|
75
|
-
::Mongo::Connection.command_time = 0
|
76
|
-
::Mongo::Connection.command_count = 0
|
79
|
+
::Mongo::Connection.command_time.value = 0
|
80
|
+
::Mongo::Connection.command_count.value = 0
|
77
81
|
end
|
78
82
|
end
|
79
83
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimpse-mongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: glimpse
|
@@ -43,6 +43,22 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '1.8'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: atomic
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.0.0
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.0.0
|
46
62
|
description: Provide a glimpse into the Mongo commands made within your Rails application.
|
47
63
|
email:
|
48
64
|
- me@garrettbjerkhoel.com
|