appsignal-moped 1.0.0.beta.1 → 1.0.1.beta.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/appsignal/middleware/moped_event_sanitizer.rb +36 -0
- data/lib/appsignal/middleware/moped_event_sanitizer.rb~ +36 -0
- data/lib/appsignal/moped/instrumentation.rb +40 -0
- data/lib/appsignal/moped/instrumentation.rb~ +39 -0
- data/lib/appsignal/moped/version.rb +5 -0
- data/lib/{appsignal_moped/version.rb → appsignal/moped/version.rb~} +0 -0
- data/lib/appsignal-moped.rb +16 -0
- data/lib/appsignal-moped.rb~ +16 -0
- metadata +48 -42
- data/lib/appsignal_moped.rb +0 -42
@@ -0,0 +1,36 @@
|
|
1
|
+
module Appsignal
|
2
|
+
module Middleware
|
3
|
+
class MopedEventSanitizer
|
4
|
+
WHITELISTED_KEYS = %w{fields flags}
|
5
|
+
|
6
|
+
def call(event)
|
7
|
+
if target?(event)
|
8
|
+
event.payload[:ops].each do |operation|
|
9
|
+
operation.each_value do |parameters|
|
10
|
+
selected(parameters).each_value do |value|
|
11
|
+
scrub!(value)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
yield
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
def target?(event)
|
22
|
+
event.name == Appsignal::Moped::Instrumentation::EVENT_NAME
|
23
|
+
end
|
24
|
+
|
25
|
+
def selected(parameters)
|
26
|
+
parameters.reject { |key, value| WHITELISTED_KEYS.include?(key) }
|
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
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Appsignal
|
2
|
+
module Middleware
|
3
|
+
class MopedEventSanitizer
|
4
|
+
WHITELISTED_KEYS = %w{fields flags}
|
5
|
+
|
6
|
+
def call(event)
|
7
|
+
if target?(event)
|
8
|
+
event.payload[:ops].each do |operation|
|
9
|
+
operation.each_value do |parameters|
|
10
|
+
selected(parameters).each_value do |value|
|
11
|
+
scrub!(value)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
yield
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
def target?(event)
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
25
|
+
def selected(parameters)
|
26
|
+
parameters.reject { |key, value| WHITELISTED_KEYS.include?(key) }
|
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
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Appsignal
|
2
|
+
module Moped
|
3
|
+
module Instrumentation
|
4
|
+
EVENT_NAME = 'query.moped'
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
def logging_with_appsignal_instrumentation(operations, &block)
|
9
|
+
ActiveSupport::Notifications.instrument(
|
10
|
+
EVENT_NAME, :ops => appsignal_log_operations(operations)
|
11
|
+
) do
|
12
|
+
logging_without_appsignal_instrumentation(operations, &block)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def appsignal_log_operations(ops)
|
17
|
+
ops.map do |op|
|
18
|
+
{
|
19
|
+
operation_name(op) => {}.tap do |hash|
|
20
|
+
op.instance_variables.reject do |o|
|
21
|
+
o == :@full_collection_name
|
22
|
+
end.each do |attr|
|
23
|
+
value = op.instance_variable_get(attr)
|
24
|
+
hash[attr.to_s.gsub('@', '')] = value unless value.nil?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def operation_name(operation)
|
32
|
+
operation.class.name.split('::').last.tap do |class_name|
|
33
|
+
class_name.gsub!(/([a-z])([A-Z])/,'\1_\2')
|
34
|
+
class_name.downcase!
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Appsignal
|
2
|
+
module Moped
|
3
|
+
module Instrumentation
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
def logging_with_appsignal_instrumentation(operations, &block)
|
8
|
+
ActiveSupport::Notifications.instrument(
|
9
|
+
'query.moped', :ops => appsignal_log_operations(operations)
|
10
|
+
) do
|
11
|
+
logging_without_appsignal_instrumentation(operations, &block)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def appsignal_log_operations(ops)
|
16
|
+
ops.map do |op|
|
17
|
+
{
|
18
|
+
operation_name(op) => {}.tap do |hash|
|
19
|
+
op.instance_variables.reject do |o|
|
20
|
+
o == :@full_collection_name
|
21
|
+
end.each do |attr|
|
22
|
+
value = op.instance_variable_get(attr)
|
23
|
+
hash[attr.to_s.gsub('@', '')] = value unless value.nil?
|
24
|
+
end
|
25
|
+
end
|
26
|
+
}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def operation_name(operation)
|
31
|
+
operation.class.name.split('::').last.tap do |class_name|
|
32
|
+
class_name.gsub!(/([a-z])([A-Z])/,'\1_\2')
|
33
|
+
class_name.downcase!
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'moped'
|
2
|
+
require 'rails'
|
3
|
+
require 'appsignal'
|
4
|
+
require 'appsignal/moped/instrumentation'
|
5
|
+
require 'appsignal/middleware/moped_event_sanitizer'
|
6
|
+
|
7
|
+
::Moped::Node.class_eval do
|
8
|
+
include Appsignal::Moped::Instrumentation
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
alias_method :logging_without_appsignal_instrumentation, :logging
|
13
|
+
alias_method :logging, :logging_with_appsignal_instrumentation
|
14
|
+
end
|
15
|
+
|
16
|
+
Appsignal.post_processing_middleware.add Appsignal::Middleware::MopedEventSanitizer
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'moped'
|
2
|
+
require 'rails'
|
3
|
+
require 'appsignal'
|
4
|
+
require 'appsignal/moped/instrumentation'
|
5
|
+
require 'appsignal/middleware/moped_event_sanitizer'
|
6
|
+
|
7
|
+
::Moped::Node.class_eval do
|
8
|
+
include Appsignal::Moped::Instrumentation
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
alias_method :logging_without_appsignal_instrumentation, :logging
|
13
|
+
alias_method :logging, :logging_with_appsignal_instrumentation
|
14
|
+
end
|
15
|
+
|
16
|
+
Appsignal.post_processing_middleware.add Appsignal::Moped::MopedEventSanitizer
|
metadata
CHANGED
@@ -1,105 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appsignal-moped
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.beta.1
|
5
4
|
prerelease: 6
|
5
|
+
version: 1.0.1.beta.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Steven Weller
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-04-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.5.0.beta1
|
20
|
+
none: false
|
21
|
+
prerelease: false
|
15
22
|
name: appsignal
|
16
23
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
24
|
requirements:
|
19
25
|
- - ~>
|
20
26
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
27
|
+
version: 0.5.0.beta1
|
28
|
+
none: false
|
22
29
|
type: :runtime
|
23
|
-
|
30
|
+
- !ruby/object:Gem::Dependency
|
24
31
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
32
|
requirements:
|
27
33
|
- - ~>
|
28
34
|
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
30
|
-
|
35
|
+
version: '1.0'
|
36
|
+
none: false
|
37
|
+
prerelease: false
|
31
38
|
name: moped
|
32
39
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
40
|
requirements:
|
35
41
|
- - ~>
|
36
42
|
- !ruby/object:Gem::Version
|
37
|
-
version: 1.0
|
38
|
-
type: :runtime
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
version: '1.0'
|
41
44
|
none: false
|
42
|
-
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 1.0.0
|
45
|
+
type: :runtime
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
|
-
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
47
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
48
|
requirements:
|
51
49
|
- - ! '>='
|
52
50
|
- !ruby/object:Gem::Version
|
53
51
|
version: '0'
|
54
|
-
type: :development
|
55
|
-
prerelease: false
|
56
|
-
version_requirements: !ruby/object:Gem::Requirement
|
57
52
|
none: false
|
53
|
+
prerelease: false
|
54
|
+
name: rake
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
58
56
|
requirements:
|
59
57
|
- - ! '>='
|
60
58
|
- !ruby/object:Gem::Version
|
61
59
|
version: '0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: rspec
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
60
|
none: false
|
61
|
+
type: :development
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
64
|
requirements:
|
67
65
|
- - ~>
|
68
66
|
- !ruby/object:Gem::Version
|
69
67
|
version: 2.12.0
|
70
|
-
type: :development
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
68
|
none: false
|
69
|
+
prerelease: false
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
74
72
|
requirements:
|
75
73
|
- - ~>
|
76
74
|
- !ruby/object:Gem::Version
|
77
75
|
version: 2.12.0
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: pry
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
76
|
none: false
|
77
|
+
type: :development
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
80
|
requirements:
|
83
81
|
- - ! '>='
|
84
82
|
- !ruby/object:Gem::Version
|
85
83
|
version: '0'
|
86
|
-
type: :development
|
87
|
-
prerelease: false
|
88
|
-
version_requirements: !ruby/object:Gem::Requirement
|
89
84
|
none: false
|
85
|
+
prerelease: false
|
86
|
+
name: pry
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
90
88
|
requirements:
|
91
89
|
- - ! '>='
|
92
90
|
- !ruby/object:Gem::Version
|
93
91
|
version: '0'
|
94
|
-
|
92
|
+
none: false
|
93
|
+
type: :development
|
94
|
+
description: Log your moped queries with ActiveSupport::Notifications.instrument calls
|
95
95
|
email:
|
96
96
|
- steven@80beans.com
|
97
97
|
executables: []
|
98
98
|
extensions: []
|
99
99
|
extra_rdoc_files: []
|
100
100
|
files:
|
101
|
-
- lib/
|
102
|
-
- lib/
|
101
|
+
- lib/appsignal/middleware/moped_event_sanitizer.rb
|
102
|
+
- lib/appsignal/middleware/moped_event_sanitizer.rb~
|
103
|
+
- lib/appsignal/moped/instrumentation.rb
|
104
|
+
- lib/appsignal/moped/instrumentation.rb~
|
105
|
+
- lib/appsignal/moped/version.rb
|
106
|
+
- lib/appsignal/moped/version.rb~
|
107
|
+
- lib/appsignal-moped.rb
|
108
|
+
- lib/appsignal-moped.rb~
|
103
109
|
- README.md
|
104
110
|
homepage: https://github.com/80beans/appsignal-moped
|
105
111
|
licenses: []
|
@@ -108,23 +114,23 @@ rdoc_options: []
|
|
108
114
|
require_paths:
|
109
115
|
- lib
|
110
116
|
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
-
none: false
|
112
117
|
requirements:
|
113
118
|
- - ! '>='
|
114
119
|
- !ruby/object:Gem::Version
|
115
120
|
version: '0'
|
116
121
|
segments:
|
117
122
|
- 0
|
118
|
-
hash:
|
119
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
hash: 3384813339710934242
|
120
124
|
none: false
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
126
|
requirements:
|
122
127
|
- - ! '>'
|
123
128
|
- !ruby/object:Gem::Version
|
124
129
|
version: 1.3.1
|
130
|
+
none: false
|
125
131
|
requirements: []
|
126
132
|
rubyforge_project:
|
127
|
-
rubygems_version: 1.8.
|
133
|
+
rubygems_version: 1.8.24
|
128
134
|
signing_key:
|
129
135
|
specification_version: 3
|
130
136
|
summary: Add instrument calls to mongodb queries made with moped(or mongoid). For
|
data/lib/appsignal_moped.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'moped'
|
2
|
-
require 'active_support'
|
3
|
-
|
4
|
-
module Appsignal
|
5
|
-
module Moped
|
6
|
-
module Instrumentation
|
7
|
-
|
8
|
-
private
|
9
|
-
|
10
|
-
def logging_with_appsignal_instrumentation(operations, &block)
|
11
|
-
ActiveSupport::Notifications.instrument(
|
12
|
-
'query.moped', :operations => appsignal_log_operations(operations)
|
13
|
-
) do
|
14
|
-
logging_without_appsignal_instrumentation(operations, &block)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def appsignal_log_operations(ops)
|
19
|
-
ops.map do |op|
|
20
|
-
{}.tap do |hash|
|
21
|
-
op.instance_variables.reject do |o|
|
22
|
-
o == :@full_collection_name
|
23
|
-
end.each do |attr|
|
24
|
-
value = op.instance_variable_get(attr)
|
25
|
-
hash[attr.to_s.gsub('@', '')] = value unless value.nil?
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
::Moped::Node.class_eval do
|
36
|
-
include Appsignal::Moped::Instrumentation
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
alias_method :logging_without_appsignal_instrumentation, :logging
|
41
|
-
alias_method :logging, :logging_with_appsignal_instrumentation
|
42
|
-
end
|