appsignal-mongo 0.1.2 → 0.1.3.beta.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/appsignal/middleware/mongo_event_sanitizer.rb +37 -0
- data/lib/appsignal/middleware/mongo_event_sanitizer.rb~ +35 -0
- data/lib/appsignal/mongo/instrumentation.rb +17 -0
- data/lib/appsignal/mongo/instrumentation.rb~ +16 -0
- data/lib/appsignal/mongo/version.rb +5 -0
- data/lib/{appsignal_mongo/version.rb → appsignal/mongo/version.rb~} +0 -0
- data/lib/appsignal-mongo.rb +14 -0
- data/lib/appsignal-mongo.rb~ +12 -0
- metadata +69 -50
- data/lib/appsignal_mongo.rb +0 -26
@@ -0,0 +1,37 @@
|
|
1
|
+
module Appsignal
|
2
|
+
module Middleware
|
3
|
+
class MongoEventSanitizer
|
4
|
+
WHITELISTED_TOP_LEVEL_KEYS = [:fields, :order]
|
5
|
+
|
6
|
+
def call(event)
|
7
|
+
if target?(event)
|
8
|
+
event.payload.each_value do |parameters|
|
9
|
+
selected(parameters).each_value do |value|
|
10
|
+
scrub!(value)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
yield
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
|
19
|
+
def target?(event)
|
20
|
+
event.name == Appsignal::Mongo::Instrumentation::EVENT_NAME
|
21
|
+
end
|
22
|
+
|
23
|
+
def selected(parameters)
|
24
|
+
parameters.reject do |key, value|
|
25
|
+
WHITELISTED_TOP_LEVEL_KEYS.include?(key)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def scrub!(value)
|
30
|
+
if value.is_a?(Hash) || value.is_a?(Array)
|
31
|
+
Appsignal::ParamsSanitizer.scrub!(value)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Appsignal
|
2
|
+
module Middleware
|
3
|
+
class MongoEventSanitizer
|
4
|
+
WHITELISTED_KEYS = [:fields, :order]
|
5
|
+
|
6
|
+
def call(event)
|
7
|
+
if target?(event)
|
8
|
+
event.payload.each_value do |parameters|
|
9
|
+
selected(parameters).each_value do |value|
|
10
|
+
scrub!(value)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
yield
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
|
19
|
+
def target?(event)
|
20
|
+
event.name == Appsignal::Mongo::Instrumentation::EVENT_NAME
|
21
|
+
end
|
22
|
+
|
23
|
+
def selected(parameters)
|
24
|
+
parameters.reject { |key, value| WHITELISTED_KEYS.include?(key) }
|
25
|
+
end
|
26
|
+
|
27
|
+
def scrub!(value)
|
28
|
+
if value.is_a?(Hash) || value.is_a?(Array)
|
29
|
+
Appsignal::ParamsSanitizer.scrub!(value)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Appsignal
|
2
|
+
module Mongo
|
3
|
+
module Instrumentation
|
4
|
+
EVENT_NAME = 'query.mongodb'
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def instrument_with_appsignal_instrumentation(name, payload={}, &block)
|
9
|
+
ActiveSupport::Notifications.instrument(
|
10
|
+
EVENT_NAME, name => payload) do
|
11
|
+
instrument_without_appsignal_instrumentation(name, payload, &block)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Appsignal
|
2
|
+
module Mongo
|
3
|
+
module Instrumentation
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
def instrument_with_appsignal_instrumentation(name, payload={}, &block)
|
8
|
+
ActiveSupport::Notifications.instrument(
|
9
|
+
'query.mongodb', name => payload) do
|
10
|
+
instrument_without_appsignal_instrumentation(name, payload, &block)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'mongo'
|
2
|
+
require 'rails'
|
3
|
+
require 'appsignal'
|
4
|
+
require 'appsignal/mongo/instrumentation'
|
5
|
+
require 'appsignal/middleware/mongo_event_sanitizer'
|
6
|
+
|
7
|
+
::Mongo::Logging.module_eval do
|
8
|
+
include Appsignal::Mongo::Instrumentation
|
9
|
+
|
10
|
+
alias_method :instrument_without_appsignal_instrumentation, :instrument
|
11
|
+
alias_method :instrument, :instrument_with_appsignal_instrumentation
|
12
|
+
end
|
13
|
+
|
14
|
+
Appsignal.post_processing_middleware.add Appsignal::Middleware::MongoEventSanitizer
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'mongo'
|
2
|
+
require 'rails'
|
3
|
+
require 'appsignal'
|
4
|
+
require 'appsignal/mongo/instrumentation'
|
5
|
+
require 'appsignal/middleware/mongo_event_sanitizer'
|
6
|
+
|
7
|
+
::Mongo::Logging.module_eval do
|
8
|
+
include Appsignal::Mongo::Instrumentation
|
9
|
+
|
10
|
+
alias_method :instrument_without_appsignal_instrumentation, :instrument
|
11
|
+
alias_method :instrument, :instrument_with_appsignal_instrumentation
|
12
|
+
end
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appsignal-mongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
4
|
+
prerelease: 6
|
5
|
+
version: 0.1.3.beta.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Thijs Cadier
|
@@ -10,142 +10,161 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-04-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
|
17
|
-
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
17
|
requirements:
|
20
18
|
- - ! '>'
|
21
19
|
- !ruby/object:Gem::Version
|
22
20
|
version: '1.5'
|
23
|
-
type: :runtime
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: !ruby/object:Gem::Requirement
|
26
21
|
none: false
|
22
|
+
prerelease: false
|
23
|
+
name: mongo
|
24
|
+
requirement: !ruby/object:Gem::Requirement
|
27
25
|
requirements:
|
28
26
|
- - ! '>'
|
29
27
|
- !ruby/object:Gem::Version
|
30
28
|
version: '1.5'
|
29
|
+
none: false
|
30
|
+
type: :runtime
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
|
+
version_requirements: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ~>
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '3'
|
37
|
+
none: false
|
38
|
+
prerelease: false
|
32
39
|
name: activesupport
|
33
40
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
41
|
requirements:
|
36
42
|
- - ~>
|
37
43
|
- !ruby/object:Gem::Version
|
38
44
|
version: '3'
|
45
|
+
none: false
|
39
46
|
type: :runtime
|
40
|
-
|
47
|
+
- !ruby/object:Gem::Dependency
|
41
48
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
49
|
requirements:
|
44
50
|
- - ~>
|
45
51
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
47
|
-
|
48
|
-
|
52
|
+
version: 0.5.0.beta1
|
53
|
+
none: false
|
54
|
+
prerelease: false
|
55
|
+
name: appsignal
|
49
56
|
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ~>
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 0.5.0.beta1
|
50
61
|
none: false
|
62
|
+
type: :runtime
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - ! '>='
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
|
-
type: :development
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: !ruby/object:Gem::Requirement
|
58
69
|
none: false
|
70
|
+
prerelease: false
|
71
|
+
name: bson_ext
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
59
73
|
requirements:
|
60
74
|
- - ! '>='
|
61
75
|
- !ruby/object:Gem::Version
|
62
76
|
version: '0'
|
63
|
-
- !ruby/object:Gem::Dependency
|
64
|
-
name: rake
|
65
|
-
requirement: !ruby/object:Gem::Requirement
|
66
77
|
none: false
|
78
|
+
type: :development
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
81
|
requirements:
|
68
82
|
- - ! '>='
|
69
83
|
- !ruby/object:Gem::Version
|
70
84
|
version: '0'
|
71
|
-
type: :development
|
72
|
-
prerelease: false
|
73
|
-
version_requirements: !ruby/object:Gem::Requirement
|
74
85
|
none: false
|
86
|
+
prerelease: false
|
87
|
+
name: rake
|
88
|
+
requirement: !ruby/object:Gem::Requirement
|
75
89
|
requirements:
|
76
90
|
- - ! '>='
|
77
91
|
- !ruby/object:Gem::Version
|
78
92
|
version: '0'
|
79
|
-
- !ruby/object:Gem::Dependency
|
80
|
-
name: rspec
|
81
|
-
requirement: !ruby/object:Gem::Requirement
|
82
93
|
none: false
|
94
|
+
type: :development
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
version_requirements: !ruby/object:Gem::Requirement
|
83
97
|
requirements:
|
84
98
|
- - ~>
|
85
99
|
- !ruby/object:Gem::Version
|
86
100
|
version: 2.12.0
|
87
|
-
type: :development
|
88
|
-
prerelease: false
|
89
|
-
version_requirements: !ruby/object:Gem::Requirement
|
90
101
|
none: false
|
102
|
+
prerelease: false
|
103
|
+
name: rspec
|
104
|
+
requirement: !ruby/object:Gem::Requirement
|
91
105
|
requirements:
|
92
106
|
- - ~>
|
93
107
|
- !ruby/object:Gem::Version
|
94
108
|
version: 2.12.0
|
95
|
-
- !ruby/object:Gem::Dependency
|
96
|
-
name: pry
|
97
|
-
requirement: !ruby/object:Gem::Requirement
|
98
109
|
none: false
|
110
|
+
type: :development
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
113
|
requirements:
|
100
114
|
- - ! '>='
|
101
115
|
- !ruby/object:Gem::Version
|
102
116
|
version: '0'
|
103
|
-
type: :development
|
104
|
-
prerelease: false
|
105
|
-
version_requirements: !ruby/object:Gem::Requirement
|
106
117
|
none: false
|
118
|
+
prerelease: false
|
119
|
+
name: pry
|
120
|
+
requirement: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
122
|
- - ! '>='
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
111
|
-
|
112
|
-
|
125
|
+
none: false
|
126
|
+
type: :development
|
127
|
+
description: Wrap all mongo queries withActiveSupport::Notifications.instrument calls.
|
128
|
+
For use with Appsignal.
|
113
129
|
email:
|
114
130
|
- contact@appsignal.com
|
115
131
|
executables: []
|
116
132
|
extensions: []
|
117
133
|
extra_rdoc_files: []
|
118
134
|
files:
|
119
|
-
- lib/
|
120
|
-
- lib/
|
135
|
+
- lib/appsignal/middleware/mongo_event_sanitizer.rb
|
136
|
+
- lib/appsignal/middleware/mongo_event_sanitizer.rb~
|
137
|
+
- lib/appsignal/mongo/instrumentation.rb
|
138
|
+
- lib/appsignal/mongo/instrumentation.rb~
|
139
|
+
- lib/appsignal/mongo/version.rb
|
140
|
+
- lib/appsignal/mongo/version.rb~
|
141
|
+
- lib/appsignal-mongo.rb
|
142
|
+
- lib/appsignal-mongo.rb~
|
121
143
|
- README.md
|
122
|
-
homepage: https://github.com/
|
144
|
+
homepage: https://github.com/appsignal/appsignal-mongo
|
123
145
|
licenses: []
|
124
146
|
post_install_message:
|
125
147
|
rdoc_options: []
|
126
148
|
require_paths:
|
127
149
|
- lib
|
128
150
|
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
151
|
requirements:
|
131
152
|
- - ! '>='
|
132
153
|
- !ruby/object:Gem::Version
|
133
154
|
version: '0'
|
134
155
|
segments:
|
135
156
|
- 0
|
136
|
-
hash: -
|
137
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
|
+
hash: -4000561256811814464
|
138
158
|
none: false
|
159
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
160
|
requirements:
|
140
|
-
- - ! '
|
161
|
+
- - ! '>'
|
141
162
|
- !ruby/object:Gem::Version
|
142
|
-
version:
|
143
|
-
|
144
|
-
- 0
|
145
|
-
hash: -1981725142118150093
|
163
|
+
version: 1.3.1
|
164
|
+
none: false
|
146
165
|
requirements: []
|
147
166
|
rubyforge_project:
|
148
|
-
rubygems_version: 1.8.
|
167
|
+
rubygems_version: 1.8.24
|
149
168
|
signing_key:
|
150
169
|
specification_version: 3
|
151
170
|
summary: Add instrument calls to mongodb queries made with mongo. For use with Appsignal.
|
data/lib/appsignal_mongo.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'mongo'
|
2
|
-
require 'active_support'
|
3
|
-
|
4
|
-
module Appsignal
|
5
|
-
module Mongo
|
6
|
-
module Instrumentation
|
7
|
-
|
8
|
-
private
|
9
|
-
|
10
|
-
def instrument_with_appsignal_instrumentation(name, payload={}, &block)
|
11
|
-
ActiveSupport::Notifications.instrument(
|
12
|
-
'query.mongodb', :query => payload.merge(:method => name)) do
|
13
|
-
instrument_without_appsignal_instrumentation(name, payload, &block)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
::Mongo::Logging.module_eval do
|
22
|
-
include Appsignal::Mongo::Instrumentation
|
23
|
-
|
24
|
-
alias_method :instrument_without_appsignal_instrumentation, :instrument
|
25
|
-
alias_method :instrument, :instrument_with_appsignal_instrumentation
|
26
|
-
end
|