kenny 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +3 -3
- data/lib/kenny/formatters/log_stash_formatter.rb +2 -2
- data/lib/kenny/log_subscriber.rb +4 -4
- data/lib/kenny/railtie.rb +1 -0
- data/lib/kenny/unsubscriber.rb +13 -9
- data/lib/kenny.rb +16 -19
- metadata +32 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2740dfe3834c07d205a400e43ed53ffaa70b3eb6
|
4
|
+
data.tar.gz: cae861c957fb393d01fd56fa408d34f4d82ff725
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 180faaefd1c6d219bf0dd5e854dd8b2a9870103d746b83c1ecc622570777bb78762026290cf145d5837b76fdb92013122c177cdbaab1498ddbf373b93cc308e5
|
7
|
+
data.tar.gz: 588c0abb9b75569892e9d51dcb1691725780e6d72d7e3efb931a7a50cb9d612719bbf2441fd36c4e427cb80b7a71ae1e2c2f2e8b5fef3ad1a24bbbc649a8d7ae
|
data/Rakefile
CHANGED
@@ -4,8 +4,8 @@ require 'active_support'
|
|
4
4
|
|
5
5
|
module Kenny
|
6
6
|
module Formatters
|
7
|
+
# Formats messages as LogStash::Event
|
7
8
|
class LogStashFormatter < ::Logger::Formatter
|
8
|
-
|
9
9
|
include ActiveSupport::TaggedLogging::Formatter
|
10
10
|
|
11
11
|
def call(severity, time, progname, msg)
|
@@ -16,7 +16,7 @@ module Kenny
|
|
16
16
|
|
17
17
|
tags = current_tags
|
18
18
|
|
19
|
-
if tags.
|
19
|
+
if tags.any?
|
20
20
|
msg['type'] ||= tags.first
|
21
21
|
msg['tags'] = tags
|
22
22
|
end
|
data/lib/kenny/log_subscriber.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
##
|
2
|
-
# This class is meant to be inherited by anonymous classes,
|
1
|
+
##
|
2
|
+
# This class is meant to be inherited by anonymous classes,
|
3
3
|
# created through Kenny.define_log_subscriber_class.
|
4
4
|
#
|
5
|
-
# By inserting this class into the inheritance tree,
|
6
|
-
# we can verify in test-environment whether the LogSubscribers
|
5
|
+
# By inserting this class into the inheritance tree,
|
6
|
+
# we can verify in test-environment whether the LogSubscribers
|
7
7
|
# we created are indeed attached to the instrumentations we specified.
|
8
8
|
module Kenny
|
9
9
|
class LogSubscriber < ActiveSupport::LogSubscriber
|
data/lib/kenny/railtie.rb
CHANGED
data/lib/kenny/unsubscriber.rb
CHANGED
@@ -1,24 +1,26 @@
|
|
1
1
|
##
|
2
|
-
# Module to unsubscribe all Rails default LogSubscribers from their events.
|
3
2
|
module Kenny
|
3
|
+
# Module to unsubscribe all Rails default LogSubscribers from their events.
|
4
4
|
module Unsubscriber
|
5
5
|
DEFAULT_RAILS_LOG_SUBSCRIBER_CLASSES = [
|
6
|
-
ActionView::LogSubscriber,
|
7
|
-
ActionController::LogSubscriber,
|
8
|
-
ActiveRecord::LogSubscriber,
|
6
|
+
ActionView::LogSubscriber,
|
7
|
+
ActionController::LogSubscriber,
|
8
|
+
ActiveRecord::LogSubscriber,
|
9
9
|
ActionMailer::LogSubscriber
|
10
|
-
]
|
10
|
+
].freeze
|
11
11
|
|
12
12
|
##
|
13
13
|
# By default, a Rails app instantiates the LogSubscribers listed above and
|
14
14
|
# are actively listening to instrumentations listed in:
|
15
15
|
# http://edgeguides.rubyonrails.org/active_support_instrumentation.html
|
16
|
-
#
|
16
|
+
#
|
17
17
|
# Unsubscribing is not recommended, unless you want to modify the output
|
18
18
|
# to your standard rails logs (development|test|staging|production).log
|
19
|
-
#
|
19
|
+
#
|
20
20
|
# It would be safer to write your chosen instrumentation data to a separate file,
|
21
|
-
# setup by the [:logger] configuration (see Readme).
|
21
|
+
# setup by the [:logger] configuration (see Readme).
|
22
|
+
|
23
|
+
# In that case, the [:unsubscribe_rails_defaults]
|
22
24
|
# field in Kenny's config won't need to be set.
|
23
25
|
def self.unsubscribe_from_rails_defaults
|
24
26
|
default_rails_log_subscribers.each do |subscriber|
|
@@ -36,7 +38,9 @@ module Kenny
|
|
36
38
|
private_class_method :default_rails_log_subscribers
|
37
39
|
|
38
40
|
def self.listeners_for(event, subscriber_namespace)
|
39
|
-
ActiveSupport::Notifications.notifier.listeners_for(
|
41
|
+
ActiveSupport::Notifications.notifier.listeners_for(
|
42
|
+
"#{event}.#{subscriber_namespace}"
|
43
|
+
)
|
40
44
|
end
|
41
45
|
private_class_method :listeners_for
|
42
46
|
|
data/lib/kenny.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
##
|
2
|
+
|
2
3
|
# Kenny module does three things:
|
3
4
|
# - Holds reference to the Rails application (set through Railtie)
|
4
5
|
# - Unsubscribe all Rails' LogSubscribers from the default instrumentation channels
|
5
6
|
# - Create LogSubscriber-classes which will be attached to the user-specified instrumentations
|
6
|
-
|
7
7
|
module Kenny
|
8
|
-
|
9
8
|
def self.configs
|
10
9
|
Struct.new(
|
11
10
|
:unsubscribe_rails_defaults,
|
@@ -15,19 +14,19 @@ module Kenny
|
|
15
14
|
end
|
16
15
|
|
17
16
|
def self.application=(app)
|
18
|
-
|
17
|
+
@application = app
|
19
18
|
end
|
20
19
|
|
21
20
|
def self.application
|
22
|
-
|
21
|
+
@application
|
23
22
|
end
|
24
23
|
|
25
24
|
##
|
26
25
|
# Define LogSubscriber-classes and Attach to user-specified instrumentations
|
27
26
|
# if the configurations have been set.
|
28
27
|
def self.attach_to_instrumentations
|
29
|
-
if
|
30
|
-
|
28
|
+
if @application.config.kenny[:instrumentations]
|
29
|
+
@application.config.kenny[:instrumentations].each do |instr_config|
|
31
30
|
define_log_subscriber_class(instr_config)
|
32
31
|
end
|
33
32
|
end
|
@@ -38,17 +37,17 @@ module Kenny
|
|
38
37
|
# by delegating to Kenny::Unsubscriber.
|
39
38
|
# See http://edgeguides.rubyonrails.org/active_support_instrumentation.html
|
40
39
|
def self.unsubscribe_from_rails_defaults
|
41
|
-
if
|
40
|
+
if @application.config.kenny[:unsubscribe_rails_defaults]
|
42
41
|
Kenny::Unsubscriber.unsubscribe_from_rails_defaults
|
43
42
|
end
|
44
43
|
end
|
45
44
|
|
46
45
|
##
|
47
|
-
# Suppress Rails::Rack::Logger's output
|
46
|
+
# Suppress Rails::Rack::Logger's output like:
|
48
47
|
# Started GET "/my_path" for 10.0.2.2 at 2016-07-12 10:06:48 +0000
|
49
48
|
def self.suppress_rack_logger
|
50
|
-
if
|
51
|
-
require
|
49
|
+
if @application.config.kenny[:suppress_rack_logger]
|
50
|
+
require 'kenny/rails_ext/rack/logger'
|
52
51
|
end
|
53
52
|
end
|
54
53
|
|
@@ -60,25 +59,23 @@ module Kenny
|
|
60
59
|
# instrumentations-configs provided by the user.
|
61
60
|
def self.define_log_subscriber_class(instr_config)
|
62
61
|
klass = Class.new(Kenny::LogSubscriber) do |k|
|
63
|
-
define_method(
|
62
|
+
define_method(instr_config[:name].split('.')[0], instr_config[:block])
|
64
63
|
|
65
64
|
if instr_config[:logger]
|
66
65
|
# Following assignment needed as we don't want to have
|
67
66
|
# the lambda being re-evaluated and possibly return
|
68
67
|
# a new logger instance everytime the .logger method is invoked.
|
69
68
|
defined_logger = instr_config[:logger]
|
70
|
-
define_method(:logger, lambda{defined_logger})
|
69
|
+
define_method(:logger, lambda { defined_logger })
|
71
70
|
end
|
72
|
-
|
73
71
|
end
|
74
|
-
klass.attach_to instr_config[:name].split(
|
72
|
+
klass.attach_to instr_config[:name].split('.')[1].to_sym
|
75
73
|
end
|
76
74
|
private_class_method :define_log_subscriber_class
|
77
|
-
|
78
75
|
end
|
79
76
|
|
80
|
-
require
|
77
|
+
require 'kenny/railtie'
|
81
78
|
|
82
|
-
require
|
83
|
-
require
|
84
|
-
require
|
79
|
+
require 'kenny/formatters/log_stash_formatter'
|
80
|
+
require 'kenny/unsubscriber'
|
81
|
+
require 'kenny/log_subscriber'
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kenny
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Mathias Rüdiger
|
7
|
+
- Mathias Rüdiger
|
8
|
+
- Alex Fong
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
12
|
+
date: 2016-07-20 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
@@ -66,66 +67,62 @@ dependencies:
|
|
66
67
|
- - "~>"
|
67
68
|
- !ruby/object:Gem::Version
|
68
69
|
version: '0.10'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rubocop
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0.41'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0.41'
|
69
84
|
- !ruby/object:Gem::Dependency
|
70
85
|
name: actionpack
|
71
86
|
requirement: !ruby/object:Gem::Requirement
|
72
87
|
requirements:
|
73
|
-
- - "
|
88
|
+
- - "~>"
|
74
89
|
- !ruby/object:Gem::Version
|
75
90
|
version: '4.2'
|
76
|
-
- - "<"
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
version: '5.1'
|
79
91
|
type: :runtime
|
80
92
|
prerelease: false
|
81
93
|
version_requirements: !ruby/object:Gem::Requirement
|
82
94
|
requirements:
|
83
|
-
- - "
|
95
|
+
- - "~>"
|
84
96
|
- !ruby/object:Gem::Version
|
85
97
|
version: '4.2'
|
86
|
-
- - "<"
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '5.1'
|
89
98
|
- !ruby/object:Gem::Dependency
|
90
99
|
name: activerecord
|
91
100
|
requirement: !ruby/object:Gem::Requirement
|
92
101
|
requirements:
|
93
|
-
- - "
|
102
|
+
- - "~>"
|
94
103
|
- !ruby/object:Gem::Version
|
95
104
|
version: '4.2'
|
96
|
-
- - "<"
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
version: '5.1'
|
99
105
|
type: :runtime
|
100
106
|
prerelease: false
|
101
107
|
version_requirements: !ruby/object:Gem::Requirement
|
102
108
|
requirements:
|
103
|
-
- - "
|
109
|
+
- - "~>"
|
104
110
|
- !ruby/object:Gem::Version
|
105
111
|
version: '4.2'
|
106
|
-
- - "<"
|
107
|
-
- !ruby/object:Gem::Version
|
108
|
-
version: '5.1'
|
109
112
|
- !ruby/object:Gem::Dependency
|
110
113
|
name: actionmailer
|
111
114
|
requirement: !ruby/object:Gem::Requirement
|
112
115
|
requirements:
|
113
|
-
- - "
|
116
|
+
- - "~>"
|
114
117
|
- !ruby/object:Gem::Version
|
115
118
|
version: '4.2'
|
116
|
-
- - "<"
|
117
|
-
- !ruby/object:Gem::Version
|
118
|
-
version: '5.1'
|
119
119
|
type: :runtime
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- - "
|
123
|
+
- - "~>"
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '4.2'
|
126
|
-
- - "<"
|
127
|
-
- !ruby/object:Gem::Version
|
128
|
-
version: '5.1'
|
129
126
|
- !ruby/object:Gem::Dependency
|
130
127
|
name: activesupport
|
131
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,40 +141,35 @@ dependencies:
|
|
144
141
|
name: railties
|
145
142
|
requirement: !ruby/object:Gem::Requirement
|
146
143
|
requirements:
|
147
|
-
- - "
|
144
|
+
- - "~>"
|
148
145
|
- !ruby/object:Gem::Version
|
149
146
|
version: '4.2'
|
150
|
-
- - "<"
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '5.1'
|
153
147
|
type: :runtime
|
154
148
|
prerelease: false
|
155
149
|
version_requirements: !ruby/object:Gem::Requirement
|
156
150
|
requirements:
|
157
|
-
- - "
|
151
|
+
- - "~>"
|
158
152
|
- !ruby/object:Gem::Version
|
159
153
|
version: '4.2'
|
160
|
-
- - "<"
|
161
|
-
- !ruby/object:Gem::Version
|
162
|
-
version: '5.1'
|
163
154
|
- !ruby/object:Gem::Dependency
|
164
155
|
name: logstash-event
|
165
156
|
requirement: !ruby/object:Gem::Requirement
|
166
157
|
requirements:
|
167
|
-
- -
|
158
|
+
- - "~>"
|
168
159
|
- !ruby/object:Gem::Version
|
169
160
|
version: 1.2.02
|
170
161
|
type: :runtime
|
171
162
|
prerelease: false
|
172
163
|
version_requirements: !ruby/object:Gem::Requirement
|
173
164
|
requirements:
|
174
|
-
- -
|
165
|
+
- - "~>"
|
175
166
|
- !ruby/object:Gem::Version
|
176
167
|
version: 1.2.02
|
177
|
-
description:
|
178
|
-
|
168
|
+
description: One-stop destination for defining you actionswhen specific Rails instrumentations
|
169
|
+
occur
|
179
170
|
email:
|
180
|
-
- mathias.ruediger@fromatob.com
|
171
|
+
- mathias.ruediger@fromatob.com
|
172
|
+
- alex.fong@fromatob.com
|
181
173
|
executables: []
|
182
174
|
extensions: []
|
183
175
|
extra_rdoc_files: []
|