time_bandits 0.9.2 → 0.10.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.
- checksums.yaml +4 -4
- data/Appraisals +1 -0
- data/README.rdoc +26 -1
- data/docker-compose.yml +28 -0
- data/gemfiles/activesupport_4.1.15.gemfile.lock +1 -1
- data/gemfiles/activesupport_4.2.6.gemfile.lock +1 -1
- data/gemfiles/activesupport_5.0.0.gemfile +8 -0
- data/gemfiles/activesupport_5.0.0.gemfile.lock +93 -0
- data/lib/time_bandits/monkey_patches/action_controller.rb +6 -5
- data/lib/time_bandits/monkey_patches/active_record.rb +41 -17
- data/lib/time_bandits/monkey_patches/active_support_cache_store.rb +4 -1
- data/lib/time_bandits/railtie.rb +6 -6
- data/lib/time_bandits/time_consumers/dalli.rb +1 -1
- data/lib/time_bandits/version.rb +1 -1
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acc7cbb26b11fb1994866f77893b803ed7b22d01
|
4
|
+
data.tar.gz: e7d1dbf959382fc54dd1bf86c9ba75690db8ac70
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50fa739258c7236ee9d0f66a7e0347164d99402d76d48b88e6836deb2b6bd0790071ef849aeae11ee1a499836e29fe9062f46a69a9986a4022259624ac292650
|
7
|
+
data.tar.gz: 65210bbea9658c6f5daadddeec201ed3c16a8d903d79d6d4e30fc488ae161d66dff42fee60774ac3e59b634d565d4f563dbbd47593a46abd53711205b07de7b5
|
data/Appraisals
CHANGED
data/README.rdoc
CHANGED
@@ -84,8 +84,33 @@ In order for the test to run you need a running memcached, redis-server and mysq
|
|
84
84
|
|
85
85
|
== Release Notes
|
86
86
|
|
87
|
-
|
87
|
+
version 0.10.0
|
88
|
+
-- support rails 5
|
89
|
+
|
90
|
+
version 0.9.2
|
91
|
+
-- sequel gem changes broke sequel time consumer
|
92
|
+
|
93
|
+
version 0.9.1
|
94
|
+
-- make sure redis times consumer logs keys in ASCII
|
95
|
+
|
96
|
+
version 0.9.0
|
97
|
+
-- added beetle time consumer
|
98
|
+
|
99
|
+
version 0.8.1
|
100
|
+
- bugfix
|
101
|
+
|
102
|
+
version 0.8.0
|
103
|
+
- support retrieving current runtime including not yet consumed time
|
104
|
+
|
105
|
+
version 0.7.4
|
88
106
|
- use appraisal for testing against multiple rails versions
|
107
|
+
- bugfix for actions without render
|
108
|
+
|
109
|
+
version 0.7.3
|
110
|
+
- bugfix dalli consumer for rails 4.2
|
111
|
+
|
112
|
+
version 0.7.2
|
113
|
+
- support ruby 2.2.0
|
89
114
|
|
90
115
|
version 0.7.1
|
91
116
|
- support measuring sequel gem
|
data/docker-compose.yml
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
version: '2'
|
2
|
+
|
3
|
+
services:
|
4
|
+
mysql:
|
5
|
+
container_name: mysql
|
6
|
+
image: mysql:5.5
|
7
|
+
ports:
|
8
|
+
- "3601:3306"
|
9
|
+
environment:
|
10
|
+
MYSQL_ALLOW_EMPTY_PASSWORD: 1
|
11
|
+
|
12
|
+
memcached:
|
13
|
+
container_name: memcached
|
14
|
+
image: memcached:1.4.27
|
15
|
+
ports:
|
16
|
+
- "11211:11211"
|
17
|
+
|
18
|
+
redis:
|
19
|
+
container_name: redis
|
20
|
+
image: redis:3.2.0
|
21
|
+
ports:
|
22
|
+
- "6379:6379"
|
23
|
+
|
24
|
+
rabbitmq:
|
25
|
+
container_name: rabbitmq
|
26
|
+
image: rabbitmq:3.6.2
|
27
|
+
ports:
|
28
|
+
- "5672:5672"
|
@@ -0,0 +1,93 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ../
|
3
|
+
specs:
|
4
|
+
time_bandits (0.9.2)
|
5
|
+
activesupport (>= 2.3.2)
|
6
|
+
thread_variables
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: http://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activemodel (5.0.0)
|
12
|
+
activesupport (= 5.0.0)
|
13
|
+
activerecord (5.0.0)
|
14
|
+
activemodel (= 5.0.0)
|
15
|
+
activesupport (= 5.0.0)
|
16
|
+
arel (~> 7.0)
|
17
|
+
activesupport (5.0.0)
|
18
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
|
+
i18n (~> 0.7)
|
20
|
+
minitest (~> 5.1)
|
21
|
+
tzinfo (~> 1.1)
|
22
|
+
amq-client (1.0.2)
|
23
|
+
amq-protocol (>= 1.2.0)
|
24
|
+
eventmachine
|
25
|
+
amq-protocol (1.6.0)
|
26
|
+
amqp (1.0.2)
|
27
|
+
amq-client (~> 1.0.2)
|
28
|
+
amq-protocol (>= 1.3.0)
|
29
|
+
eventmachine
|
30
|
+
ansi (1.5.0)
|
31
|
+
appraisal (2.1.0)
|
32
|
+
bundler
|
33
|
+
rake
|
34
|
+
thor (>= 0.14.0)
|
35
|
+
arel (7.0.0)
|
36
|
+
beetle (0.4.8)
|
37
|
+
activesupport (>= 2.3.4)
|
38
|
+
amq-client (= 1.0.2)
|
39
|
+
amq-protocol (= 1.6.0)
|
40
|
+
amqp (= 1.0.2)
|
41
|
+
bunny (~> 0.7.10)
|
42
|
+
daemons (>= 1.1.9)
|
43
|
+
eventmachine_httpserver (>= 0.2.1)
|
44
|
+
hiredis (>= 0.4.5, < 0.6)
|
45
|
+
redis (>= 2.2.2, < 3.2)
|
46
|
+
uuid4r (>= 0.1.2)
|
47
|
+
bunny (0.7.10)
|
48
|
+
byebug (9.0.5)
|
49
|
+
concurrent-ruby (1.0.2)
|
50
|
+
daemons (1.2.3)
|
51
|
+
dalli (2.7.6)
|
52
|
+
eventmachine (1.2.0.1)
|
53
|
+
eventmachine_httpserver (0.2.1)
|
54
|
+
hiredis (0.5.2)
|
55
|
+
i18n (0.7.0)
|
56
|
+
memcached (1.8.0)
|
57
|
+
metaclass (0.0.4)
|
58
|
+
minitest (5.9.0)
|
59
|
+
mocha (1.1.0)
|
60
|
+
metaclass (~> 0.0.1)
|
61
|
+
mysql2 (0.4.4)
|
62
|
+
rake (10.5.0)
|
63
|
+
redis (3.1.0)
|
64
|
+
sequel (4.36.0)
|
65
|
+
thor (0.19.1)
|
66
|
+
thread_safe (0.3.5)
|
67
|
+
thread_variables (0.2.0)
|
68
|
+
tzinfo (1.2.2)
|
69
|
+
thread_safe (~> 0.1)
|
70
|
+
uuid4r (0.2.0)
|
71
|
+
|
72
|
+
PLATFORMS
|
73
|
+
ruby
|
74
|
+
|
75
|
+
DEPENDENCIES
|
76
|
+
activerecord (= 5.0.0)
|
77
|
+
activesupport (= 5.0.0)
|
78
|
+
ansi
|
79
|
+
appraisal
|
80
|
+
beetle (>= 0.4.6)
|
81
|
+
byebug
|
82
|
+
dalli
|
83
|
+
memcached (~> 1.8.0)
|
84
|
+
minitest (~> 5.5)
|
85
|
+
mocha
|
86
|
+
mysql2
|
87
|
+
rake (~> 10.5.0)
|
88
|
+
redis
|
89
|
+
sequel
|
90
|
+
time_bandits!
|
91
|
+
|
92
|
+
BUNDLED WITH
|
93
|
+
1.12.5
|
@@ -5,7 +5,7 @@ module ActionController #:nodoc:
|
|
5
5
|
module Instrumentation
|
6
6
|
|
7
7
|
# patch to ensure that the completed line is always written to the log.
|
8
|
-
# this is not necessary anymore with
|
8
|
+
# this is not necessary anymore with Rails 4 and higher.
|
9
9
|
def process_action(action, *args)
|
10
10
|
raw_payload = get_raw_payload
|
11
11
|
ActiveSupport::Notifications.instrument("start_processing.action_controller", raw_payload.dup)
|
@@ -24,9 +24,10 @@ module ActionController #:nodoc:
|
|
24
24
|
end
|
25
25
|
raise exception if exception
|
26
26
|
result
|
27
|
-
end unless Rails::VERSION::STRING
|
27
|
+
end unless Rails::VERSION::STRING >= "4.0"
|
28
28
|
|
29
29
|
# patch to ensure that render times are always recorded in the log.
|
30
|
+
# this is not necessary anymore with Rails 3 and up.
|
30
31
|
def render(*args)
|
31
32
|
render_output = nil
|
32
33
|
exception = nil
|
@@ -40,7 +41,7 @@ module ActionController #:nodoc:
|
|
40
41
|
end
|
41
42
|
raise exception if exception
|
42
43
|
render_output
|
43
|
-
end
|
44
|
+
end unless Rails::VERSION::STRING >= "3.0"
|
44
45
|
|
45
46
|
def cleanup_view_runtime #:nodoc:
|
46
47
|
consumed_before_rendering = TimeBandits.consumed
|
@@ -73,7 +74,7 @@ module ActionController #:nodoc:
|
|
73
74
|
:path => (request.fullpath rescue "unknown")
|
74
75
|
}
|
75
76
|
end
|
76
|
-
elsif Rails::VERSION::STRING
|
77
|
+
elsif Rails::VERSION::STRING < "3"
|
77
78
|
raise "time_bandits ActionController monkey patch is not compatible with your Rails version"
|
78
79
|
end
|
79
80
|
|
@@ -101,7 +102,7 @@ module ActionController #:nodoc:
|
|
101
102
|
[ event.duration, additions, payload[:view_runtime], "#{payload[:controller]}##{payload[:action]}" ]
|
102
103
|
)
|
103
104
|
|
104
|
-
# this an ugly hack to
|
105
|
+
# this is an ugly hack to ensure completed lines show up in the test logs
|
105
106
|
# TODO: move this code to some other place
|
106
107
|
return unless Rails.env.test? && Rails::VERSION::STRING >= "3.2"
|
107
108
|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# it needs to be adapted to each new rails version
|
5
5
|
|
6
6
|
raise "time_bandits ActiveRecord monkey patch is not compatible with your rails version" unless
|
7
|
-
Rails::VERSION::STRING =~ /^(3\.[012]|4\.[012])/
|
7
|
+
Rails::VERSION::STRING =~ /^(3\.[012]|4\.[012])|5.0/
|
8
8
|
|
9
9
|
require "active_record/log_subscriber"
|
10
10
|
|
@@ -48,6 +48,8 @@ module ActiveRecord
|
|
48
48
|
# temporarily switch to protected mode and change it back later to
|
49
49
|
# public.
|
50
50
|
|
51
|
+
# Note that render_bind was added for Rails 4.0, and the implementation
|
52
|
+
# has changed since then, so we are careful to only redefine it if necessary.
|
51
53
|
unless instance_methods.include?(:render_bind)
|
52
54
|
protected
|
53
55
|
def render_bind(column, value)
|
@@ -76,29 +78,51 @@ module ActiveRecord
|
|
76
78
|
|
77
79
|
return if IGNORE_PAYLOAD_NAMES.include?(payload[:name])
|
78
80
|
|
79
|
-
|
80
|
-
|
81
|
-
|
81
|
+
log_sql_statement(payload, event)
|
82
|
+
end
|
83
|
+
public :sql
|
84
|
+
public
|
82
85
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
86
|
+
private
|
87
|
+
if Rails::VERSION::STRING < "5.0"
|
88
|
+
def log_sql_statement(payload, event)
|
89
|
+
name = '%s (%.1fms)' % [payload[:name], event.duration]
|
90
|
+
sql = payload[:sql].squeeze(' ')
|
91
|
+
binds = nil
|
88
92
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
name =
|
93
|
+
unless (payload[:binds] || []).empty?
|
94
|
+
binds = " " + payload[:binds].map { |attr| render_bind(attr) }.inspect
|
95
|
+
end
|
96
|
+
|
97
|
+
name = colorize_payload_name(name, payload[:name])
|
98
|
+
sql = color(sql, sql_color(sql), true)
|
99
|
+
|
100
|
+
debug " #{name} #{sql}#{binds}"
|
94
101
|
end
|
102
|
+
else
|
103
|
+
def log_sql_statement(payload, event)
|
104
|
+
name = "#{payload[:name]} (#{event.duration.round(1)}ms)"
|
105
|
+
sql = payload[:sql]
|
106
|
+
binds = nil
|
107
|
+
|
108
|
+
unless (payload[:binds] || []).empty?
|
109
|
+
binds = " " + payload[:binds].map { |col,v| render_bind(col, v) }.inspect
|
110
|
+
end
|
95
111
|
|
96
|
-
|
112
|
+
if odd?
|
113
|
+
name = color(name, CYAN, true)
|
114
|
+
sql = color(sql, nil, true)
|
115
|
+
else
|
116
|
+
name = color(name, MAGENTA, true)
|
117
|
+
end
|
118
|
+
|
119
|
+
debug " #{name} #{sql}#{binds}"
|
120
|
+
end
|
97
121
|
end
|
98
|
-
public :sql
|
99
|
-
public
|
100
122
|
end
|
101
123
|
|
124
|
+
require "active_record/railties/controller_runtime"
|
125
|
+
|
102
126
|
module Railties
|
103
127
|
module ControllerRuntime
|
104
128
|
def cleanup_view_runtime
|
@@ -1,6 +1,9 @@
|
|
1
1
|
require "active_support/cache"
|
2
2
|
|
3
|
-
#
|
3
|
+
# Rails 4 builtin mem_cache_store broke hit reporting for fetch.
|
4
|
+
# This has been fixed in Rails 5.
|
5
|
+
# The dalli time consumer makes sure to require this file only for Rails 4.
|
6
|
+
|
4
7
|
class ActiveSupport::Cache::Store
|
5
8
|
private
|
6
9
|
# only called by fetch
|
data/lib/time_bandits/railtie.rb
CHANGED
@@ -11,7 +11,7 @@ module TimeBandits
|
|
11
11
|
class Railtie < Rails::Railtie
|
12
12
|
|
13
13
|
initializer "time_bandits" do |app|
|
14
|
-
app.config.middleware.swap(
|
14
|
+
app.config.middleware.swap(Rails::Rack::Logger, TimeBandits::Rack::Logger)
|
15
15
|
|
16
16
|
ActiveSupport.on_load(:action_controller) do
|
17
17
|
require 'time_bandits/monkey_patches/action_controller'
|
@@ -19,14 +19,14 @@ module TimeBandits
|
|
19
19
|
|
20
20
|
# make sure TimeBandits.reset is called in test environment as middlewares are not executed
|
21
21
|
if Rails.env.test?
|
22
|
-
|
23
|
-
|
24
|
-
def process_with_time_bandits(*args)
|
22
|
+
module TestWithTimeBanditsReset
|
23
|
+
def process(*args)
|
25
24
|
TimeBandits.reset
|
26
|
-
|
25
|
+
super
|
27
26
|
end
|
28
|
-
alias_method_chain :process, :time_bandits
|
29
27
|
end
|
28
|
+
require 'action_controller/test_case'
|
29
|
+
ActionController::TestCase::Behavior.prepend TestWithTimeBanditsReset
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
data/lib/time_bandits/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: time_bandits
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Kaes
|
@@ -233,10 +233,13 @@ files:
|
|
233
233
|
- README.rdoc
|
234
234
|
- Rakefile
|
235
235
|
- TODO
|
236
|
+
- docker-compose.yml
|
236
237
|
- gemfiles/activesupport_4.1.15.gemfile
|
237
238
|
- gemfiles/activesupport_4.1.15.gemfile.lock
|
238
239
|
- gemfiles/activesupport_4.2.6.gemfile
|
239
240
|
- gemfiles/activesupport_4.2.6.gemfile.lock
|
241
|
+
- gemfiles/activesupport_5.0.0.gemfile
|
242
|
+
- gemfiles/activesupport_5.0.0.gemfile.lock
|
240
243
|
- lib/time_bandits.rb
|
241
244
|
- lib/time_bandits/monkey_patches/action_controller.rb
|
242
245
|
- lib/time_bandits/monkey_patches/active_record.rb
|