peek-mongo 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +4 -0
- data/lib/peek-mongo/version.rb +1 -1
- data/lib/peek/views/mongo.rb +71 -45
- data/peek-mongo.gemspec +2 -2
- metadata +20 -27
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 48895e9d990e1d81676d587e2db0fb0ffd8c6361
|
4
|
+
data.tar.gz: 7201cbea459ce896e9b0973820588f7ca1e688a8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 715ea029257f778a2babe33153ca986d36fd604cc0f6d0a733f1014ce5f9f236c04a651ad7e39fbf96f1fae6ecd8259b0af7d03f1c13e2324edc3e654f822a55
|
7
|
+
data.tar.gz: a9a0d0460cafd74a504bbfaba3d590ec3de3b7451019dc8df96a26c1594ec1a35698436605c80d4a0a5fe1ea516fccd783ba242ab0b1091f9e043e5fff19113d
|
data/CHANGELOG.md
CHANGED
data/lib/peek-mongo/version.rb
CHANGED
data/lib/peek/views/mongo.rb
CHANGED
@@ -1,57 +1,83 @@
|
|
1
1
|
require 'mongo'
|
2
|
-
require '
|
2
|
+
require 'concurrent'
|
3
3
|
|
4
|
-
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
module Peek
|
5
|
+
# Query times are logged by timing the Socket class of the Mongo Ruby Driver
|
6
|
+
module MongoSocketInstrumented
|
7
|
+
def read(*args, &block)
|
8
|
+
start = Time.now
|
9
|
+
super(*args, &block)
|
10
|
+
ensure
|
11
|
+
duration = (Time.now - start)
|
12
|
+
::Mongo::Socket.query_time.update { |value| value + duration }
|
13
|
+
end
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
+
def write(*args, &block)
|
16
|
+
start = Time.now
|
17
|
+
super(*args, &block)
|
18
|
+
ensure
|
19
|
+
duration = (Time.now - start)
|
20
|
+
::Mongo::Socket.query_time.update { |value| value + duration }
|
21
|
+
end
|
15
22
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
Mongo::Connection.command_time.update { |value| value + duration }
|
25
|
-
Mongo::Connection.command_count.update { |value| value + 1 }
|
23
|
+
|
24
|
+
# Query counts are logged to the Socket class by monitoring payload generation
|
25
|
+
module MongoProtocolInstrumented
|
26
|
+
def payload
|
27
|
+
super
|
28
|
+
ensure
|
29
|
+
::Mongo::Protocol::Message.query_count.update { |value| value + 1 }
|
30
|
+
end
|
26
31
|
end
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
Mongo::Connection.command_count.update { |value| value + 1 }
|
32
|
+
end
|
33
|
+
|
34
|
+
# The Socket class will keep track of timing
|
35
|
+
# The MongoSocketInstrumented class overrides the read and write methods, rerporting the total count as the attribute :query_count
|
36
|
+
class Mongo::Socket
|
37
|
+
prepend Peek::MongoSocketInstrumented
|
38
|
+
class << self
|
39
|
+
attr_accessor :query_time
|
36
40
|
end
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
Mongo::Connection.command_count.update { |value| value + 1 }
|
41
|
+
self.query_time = Concurrent::AtomicFixnum.new(0)
|
42
|
+
end
|
43
|
+
|
44
|
+
# The Message class will keep track of count
|
45
|
+
# Nothing is overridden here, only an attribute for counting is added
|
46
|
+
class Mongo::Protocol::Message
|
47
|
+
class << self
|
48
|
+
attr_accessor :query_count
|
46
49
|
end
|
47
|
-
|
50
|
+
self.query_count = Concurrent::AtomicFixnum.new(0)
|
51
|
+
end
|
52
|
+
|
53
|
+
## Following classes all override the various Mongo command classes in Protocol to add counting
|
54
|
+
# The actual counting for each class is stored in Mongo::Protocol::Message
|
55
|
+
|
56
|
+
class Mongo::Protocol::Query
|
57
|
+
prepend Peek::MongoProtocolInstrumented
|
58
|
+
end
|
59
|
+
|
60
|
+
class Mongo::Protocol::Insert
|
61
|
+
prepend Peek::MongoProtocolInstrumented
|
62
|
+
end
|
63
|
+
|
64
|
+
class Mongo::Protocol::Update
|
65
|
+
prepend Peek::MongoProtocolInstrumented
|
66
|
+
end
|
67
|
+
|
68
|
+
class Mongo::Protocol::GetMore
|
69
|
+
prepend Peek::MongoProtocolInstrumented
|
70
|
+
end
|
71
|
+
|
72
|
+
class Mongo::Protocol::Delete
|
73
|
+
prepend Peek::MongoProtocolInstrumented
|
48
74
|
end
|
49
75
|
|
50
76
|
module Peek
|
51
77
|
module Views
|
52
78
|
class Mongo < View
|
53
79
|
def duration
|
54
|
-
::Mongo::
|
80
|
+
::Mongo::Socket.query_time.value
|
55
81
|
end
|
56
82
|
|
57
83
|
def formatted_duration
|
@@ -64,7 +90,7 @@ module Peek
|
|
64
90
|
end
|
65
91
|
|
66
92
|
def calls
|
67
|
-
::Mongo::
|
93
|
+
::Mongo::Protocol::Message.query_count.value
|
68
94
|
end
|
69
95
|
|
70
96
|
def results
|
@@ -75,9 +101,9 @@ module Peek
|
|
75
101
|
|
76
102
|
def setup_subscribers
|
77
103
|
# Reset each counter when a new request starts
|
78
|
-
|
79
|
-
::Mongo::
|
80
|
-
::Mongo::
|
104
|
+
subscribe 'start_processing.action_controller' do
|
105
|
+
::Mongo::Socket.query_time.value = 0
|
106
|
+
::Mongo::Protocol::Message.query_count.value = 0
|
81
107
|
end
|
82
108
|
end
|
83
109
|
end
|
data/peek-mongo.gemspec
CHANGED
@@ -18,6 +18,6 @@ Gem::Specification.new do |gem|
|
|
18
18
|
gem.require_paths = ['lib']
|
19
19
|
|
20
20
|
gem.add_dependency 'peek'
|
21
|
-
gem.add_dependency 'mongo', '>= 1
|
22
|
-
gem.add_dependency '
|
21
|
+
gem.add_dependency 'mongo', '>= 2.4.1'
|
22
|
+
gem.add_dependency 'concurrent-ruby', '>= 1.0.4'
|
23
23
|
end
|
metadata
CHANGED
@@ -1,64 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peek-mongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Garrett Bjerkhoel
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2017-05-08 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: peek
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: mongo
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
|
-
version:
|
33
|
+
version: 2.4.1
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
|
-
version:
|
40
|
+
version: 2.4.1
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
42
|
+
name: concurrent-ruby
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: 1.0.
|
47
|
+
version: 1.0.4
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.0.
|
54
|
+
version: 1.0.4
|
62
55
|
description: Take a peek into the Mongo commands made within your Rails application.
|
63
56
|
email:
|
64
57
|
- me@garrettbjerkhoel.com
|
@@ -66,7 +59,7 @@ executables: []
|
|
66
59
|
extensions: []
|
67
60
|
extra_rdoc_files: []
|
68
61
|
files:
|
69
|
-
- .gitignore
|
62
|
+
- ".gitignore"
|
70
63
|
- CHANGELOG.md
|
71
64
|
- Gemfile
|
72
65
|
- LICENSE.txt
|
@@ -80,26 +73,26 @@ files:
|
|
80
73
|
- peek-mongo.gemspec
|
81
74
|
homepage: https://github.com/peek/peek-mongo
|
82
75
|
licenses: []
|
76
|
+
metadata: {}
|
83
77
|
post_install_message:
|
84
78
|
rdoc_options: []
|
85
79
|
require_paths:
|
86
80
|
- lib
|
87
81
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
-
none: false
|
89
82
|
requirements:
|
90
|
-
- -
|
83
|
+
- - ">="
|
91
84
|
- !ruby/object:Gem::Version
|
92
85
|
version: '0'
|
93
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
-
none: false
|
95
87
|
requirements:
|
96
|
-
- -
|
88
|
+
- - ">="
|
97
89
|
- !ruby/object:Gem::Version
|
98
90
|
version: '0'
|
99
91
|
requirements: []
|
100
92
|
rubyforge_project:
|
101
|
-
rubygems_version:
|
93
|
+
rubygems_version: 2.5.1
|
102
94
|
signing_key:
|
103
|
-
specification_version:
|
95
|
+
specification_version: 4
|
104
96
|
summary: Take a peek into the Mongo commands made within your Rails application.
|
105
97
|
test_files: []
|
98
|
+
has_rdoc:
|