time_bandits 0.10.9 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +17 -5
  3. data/Appraisals +2 -8
  4. data/README.md +29 -6
  5. data/Rakefile +1 -0
  6. data/docker-compose.yml +4 -4
  7. data/gemfiles/activesupport_5.2.4.3.gemfile +8 -0
  8. data/gemfiles/activesupport_5.2.4.3.gemfile.lock +81 -0
  9. data/gemfiles/activesupport_6.0.3.2.gemfile +8 -0
  10. data/gemfiles/activesupport_6.0.3.2.gemfile.lock +81 -0
  11. data/lib/time_bandits.rb +2 -6
  12. data/lib/time_bandits/monkey_patches/action_controller.rb +2 -67
  13. data/lib/time_bandits/monkey_patches/active_record.rb +21 -101
  14. data/lib/time_bandits/rack/logger.rb +46 -19
  15. data/lib/time_bandits/railtie.rb +2 -6
  16. data/lib/time_bandits/time_consumers/dalli.rb +0 -12
  17. data/lib/time_bandits/time_consumers/garbage_collection.rb +5 -29
  18. data/lib/time_bandits/version.rb +1 -1
  19. data/test/test_helper.rb +5 -10
  20. data/test/unit/database_test.rb +15 -0
  21. data/test/unit/gc_consumer_test.rb +2 -3
  22. data/test/unit/sequel_test.rb +5 -1
  23. data/time_bandits.gemspec +6 -3
  24. metadata +20 -33
  25. data/gemfiles/activesupport_4.1.16.gemfile +0 -8
  26. data/gemfiles/activesupport_4.1.16.gemfile.lock +0 -91
  27. data/gemfiles/activesupport_4.2.8.gemfile +0 -8
  28. data/gemfiles/activesupport_4.2.8.gemfile.lock +0 -89
  29. data/gemfiles/activesupport_4.2.9.gemfile +0 -8
  30. data/gemfiles/activesupport_4.2.9.gemfile.lock +0 -89
  31. data/gemfiles/activesupport_5.0.3.gemfile +0 -8
  32. data/gemfiles/activesupport_5.0.3.gemfile.lock +0 -88
  33. data/gemfiles/activesupport_5.0.4.gemfile +0 -8
  34. data/gemfiles/activesupport_5.0.4.gemfile.lock +0 -88
  35. data/gemfiles/activesupport_5.1.1.gemfile +0 -8
  36. data/gemfiles/activesupport_5.1.1.gemfile.lock +0 -88
  37. data/gemfiles/activesupport_5.1.2.gemfile +0 -8
  38. data/gemfiles/activesupport_5.1.2.gemfile.lock +0 -88
  39. data/lib/time_bandits/monkey_patches/active_support_cache_store.rb +0 -18
  40. data/lib/time_bandits/rack/logger40.rb +0 -94
  41. data/rails/init.rb +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9c20c5271abcd261d1eb1603550bd9e8a2e9f557454bc0369ad41e4a46d77f3
4
- data.tar.gz: 6b327e85bff4a1c9b2c30f6dbc206503d684a1e3fba471f4c9f2774e25b55592
3
+ metadata.gz: 0ac35c38f3393a0ff15bd629eaa862ab6f80b8c23dd199bd7ab0a21081ed7adc
4
+ data.tar.gz: 640caa883d9975cd47a662c0995b97fba05de0795e374ab4719f4c50cc3e773a
5
5
  SHA512:
6
- metadata.gz: d9c26ef3f4e1ba927e45a5bd3febfa515ac2b132e2ea4b1aae2277cfd22097133aaefc23fb9617fc1e5a98becd45f467079fd7ade31e68269e9872a987741b4e
7
- data.tar.gz: d09270ae8cc230a0b4dcad0604d75a437da6780539cf1777aa53bdf86b8ee8aaaa9f24fa288f854715b2bd3d3e1b5f3fea05a2c1a99184d188a2b6ea31112a21
6
+ metadata.gz: 14059e1e2903f23e6b61340688a1d6942a00c062d6088bb23c1f04b89e355860aa34b66d5e4a7926986e4f947e37a8bad72cf9ff0f149d9f86d8a68fa9fd05fd
7
+ data.tar.gz: cad90ceabc0220576aae6c8ffe83a3ec2c06f346e980e0c20d962267090dac1b03e36fcc8517e757104d9baf849b5cedc9bab5c7ffbabab2a064ffc7775eabc3
@@ -1,11 +1,23 @@
1
+ dist: bionic
1
2
  language: ruby
2
3
  rvm:
3
- - 2.2.5
4
- - 2.3.4
5
- - 2.4.1
6
- script: "rake appraisal:test"
7
- sudo: false
4
+ - 2.5.7
5
+ - 2.6.5
6
+ - 2.7.0
7
+ before_install:
8
+ - gem install bundler
9
+ script: "bundle exec rake appraisal:test"
8
10
  services:
9
11
  - redis-server
10
12
  - memcached
11
13
  - rabbitmq
14
+ - mysql
15
+ addons:
16
+ apt:
17
+ sources:
18
+ - sourceline: "deb https://packages.erlang-solutions.com/ubuntu bionic contrib"
19
+ key_url: "https://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc"
20
+ - sourceline: "deb https://dl.bintray.com/rabbitmq/debian bionic main"
21
+ key_url: "https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc"
22
+ packages:
23
+ - rabbitmq-server
data/Appraisals CHANGED
@@ -1,13 +1,7 @@
1
1
  [
2
- "4.1.16",
3
- "4.2.8",
4
- "4.2.9",
5
- "5.0.3",
6
- "5.0.4",
7
- "5.1.1",
8
- "5.1.2",
2
+ "5.2.4.3",
3
+ "6.0.3.2"
9
4
  ].each do |rails_version|
10
- next if RUBY_VERSION >= "2.4.0" && rails_version < "4.2.8"
11
5
  appraise "activesupport-#{rails_version}" do
12
6
  gem "activesupport", rails_version
13
7
  gem "activerecord", rails_version
data/README.md CHANGED
@@ -53,16 +53,16 @@ With these two new time consumers, the log line changes to
53
53
  b: number of bytes allocated by the ruby x_malloc call (#bytes)
54
54
  l: live data set size after last GC (#slots)
55
55
 
56
- Sidenote for Germans: you can use the word "Gesabbel" (eng: drivel) as a mnemonic here ;-)
56
+ Side note for speakers of German: you can use the word "Gesabbel" (eng: drivel) as a mnemonic here ;-)
57
57
 
58
- It's realtively straightforward to write additional time consumers; the more difficult part of this is
58
+ It's relatively straightforward to write additional time consumers; the more difficult part of this is
59
59
  monkey patching the code which you want to instrument. Have a look at consumers under
60
- lib/time_bandits/time_consumers and the corresponding patches under lib/time_bandits/monkey_patches.
60
+ `lib/time_bandits/time_consumers` and the corresponding patches under `lib/time_bandits/monkey_patches`.
61
61
 
62
62
 
63
63
  ## Prerequisites
64
64
 
65
- Rails >= 3.x is required. The gem will raise an error if you try to use it with an incompatible
65
+ ActiveSupport/Rails >= 5.2 is required. The gem will raise an error if you try to use it with an incompatible
66
66
  version.
67
67
 
68
68
  You'll need a ruby with the railsexpress GC patches applied, if you want to include GC and heap size
@@ -80,10 +80,33 @@ changed so much of the code that is is practically a full rewrite, hence we chan
80
80
 
81
81
  ## Running Tests
82
82
 
83
- In order for the test to run you need a running memcached, redis-server and mysql
83
+ Run `docker-compose up` to start Redis, MySQL, RabbitMQ and Memached containers, then run `rake`.
84
+
84
85
 
85
86
  ## Release Notes
86
87
 
88
+ ## Version 0.12.0
89
+ - drops support for Rails versions before 5.2.0 and Ruby versions before 2.2.0
90
+ - makes it possible to use individual time bandits without Rails (e.g. in a Sinatra app)
91
+
92
+ ## Version 0.11.0
93
+ - supports rails 6.0.0
94
+
95
+ ## Version 0.10.12
96
+ - supports rails 5.0.7
97
+
98
+ ## Version 0.10.11
99
+ - support rails 5.2.0
100
+
101
+ ## Version 0.10.10
102
+ - fixed regression introduced in 0.10.9
103
+
104
+ ### Version 0.10.9
105
+ - added specialized activerecord logging for Rails >= 5.1.5
106
+
107
+ ### Version 0.10.8
108
+ - rails has changed render_bind in 5.0.3
109
+
87
110
  ### Version 0.10.7
88
111
  - fixed bug in activerecord monkeypatch for Rails 5.1
89
112
 
@@ -160,7 +183,7 @@ In order for the test to run you need a running memcached, redis-server and mysq
160
183
 
161
184
  ## License
162
185
 
163
- Copyright (c) 2009-2014 Stefan Kaes <skaes@railsexpress.de>
186
+ Copyright (c) 2009-2020 Stefan Kaes <skaes@railsexpress.de>
164
187
 
165
188
  Permission is hereby granted, free of charge, to any person obtaining
166
189
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -13,6 +13,7 @@ Rake::TestTask.new do |t|
13
13
  t.libs << "test"
14
14
  t.test_files = FileList['test/**/*_test.rb']
15
15
  t.verbose = true
16
+ t.ruby_opts = %w(-W0)
16
17
  end
17
18
 
18
19
  namespace :appraisal do
@@ -3,7 +3,7 @@ version: '2'
3
3
  services:
4
4
  mysql:
5
5
  container_name: mysql
6
- image: mysql:5.5
6
+ image: mysql:5.7
7
7
  ports:
8
8
  - "3601:3306"
9
9
  environment:
@@ -11,18 +11,18 @@ services:
11
11
 
12
12
  memcached:
13
13
  container_name: memcached
14
- image: memcached:1.4.27
14
+ image: memcached:1.6.6
15
15
  ports:
16
16
  - "11211:11211"
17
17
 
18
18
  redis:
19
19
  container_name: redis
20
- image: redis:3.2.0
20
+ image: redis:5.0.9
21
21
  ports:
22
22
  - "6379:6379"
23
23
 
24
24
  rabbitmq:
25
25
  container_name: rabbitmq
26
- image: rabbitmq:3.6.2
26
+ image: rabbitmq:3.8.5
27
27
  ports:
28
28
  - "5672:5672"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "activesupport", "5.2.4.3"
6
+ gem "activerecord", "5.2.4.3"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,81 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ time_bandits (0.11.0)
5
+ activesupport (>= 5.2.4.3)
6
+ thread_variables
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ activemodel (5.2.4.3)
12
+ activesupport (= 5.2.4.3)
13
+ activerecord (5.2.4.3)
14
+ activemodel (= 5.2.4.3)
15
+ activesupport (= 5.2.4.3)
16
+ arel (>= 9.0)
17
+ activesupport (5.2.4.3)
18
+ concurrent-ruby (~> 1.0, >= 1.0.2)
19
+ i18n (>= 0.7, < 2)
20
+ minitest (~> 5.1)
21
+ tzinfo (~> 1.1)
22
+ amq-protocol (2.3.1)
23
+ amqp (1.8.0)
24
+ amq-protocol (>= 2.2.0)
25
+ eventmachine
26
+ ansi (1.5.0)
27
+ appraisal (2.3.0)
28
+ bundler
29
+ rake
30
+ thor (>= 0.14.0)
31
+ arel (9.0.0)
32
+ beetle (3.4.1)
33
+ activesupport (>= 2.3.4)
34
+ amq-protocol (= 2.3.1)
35
+ amqp (= 1.8.0)
36
+ bunny (~> 0.7.12)
37
+ hiredis (>= 0.4.5)
38
+ redis (>= 4.2.1)
39
+ bunny (0.7.12)
40
+ byebug (11.1.3)
41
+ concurrent-ruby (1.1.6)
42
+ dalli (2.7.10)
43
+ eventmachine (1.2.7)
44
+ hiredis (0.6.3)
45
+ i18n (1.8.3)
46
+ concurrent-ruby (~> 1.0)
47
+ memcached (1.8.0)
48
+ minitest (5.14.1)
49
+ mocha (1.11.2)
50
+ mysql2 (0.5.3)
51
+ rake (13.0.1)
52
+ redis (4.2.1)
53
+ sequel (5.33.0)
54
+ thor (1.0.1)
55
+ thread_safe (0.3.6)
56
+ thread_variables (0.2.0)
57
+ tzinfo (1.2.7)
58
+ thread_safe (~> 0.1)
59
+
60
+ PLATFORMS
61
+ ruby
62
+
63
+ DEPENDENCIES
64
+ activerecord (= 5.2.4.3)
65
+ activesupport (= 5.2.4.3)
66
+ ansi
67
+ appraisal
68
+ beetle (>= 3.4.1)
69
+ byebug
70
+ dalli
71
+ memcached (~> 1.8.0)
72
+ minitest (~> 5.5)
73
+ mocha
74
+ mysql2
75
+ rake
76
+ redis
77
+ sequel
78
+ time_bandits!
79
+
80
+ BUNDLED WITH
81
+ 2.1.4
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "http://rubygems.org"
4
+
5
+ gem "activesupport", "6.0.3.2"
6
+ gem "activerecord", "6.0.3.2"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,81 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ time_bandits (0.11.0)
5
+ activesupport (>= 5.2.4.3)
6
+ thread_variables
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ activemodel (6.0.3.2)
12
+ activesupport (= 6.0.3.2)
13
+ activerecord (6.0.3.2)
14
+ activemodel (= 6.0.3.2)
15
+ activesupport (= 6.0.3.2)
16
+ activesupport (6.0.3.2)
17
+ concurrent-ruby (~> 1.0, >= 1.0.2)
18
+ i18n (>= 0.7, < 2)
19
+ minitest (~> 5.1)
20
+ tzinfo (~> 1.1)
21
+ zeitwerk (~> 2.2, >= 2.2.2)
22
+ amq-protocol (2.3.1)
23
+ amqp (1.8.0)
24
+ amq-protocol (>= 2.2.0)
25
+ eventmachine
26
+ ansi (1.5.0)
27
+ appraisal (2.3.0)
28
+ bundler
29
+ rake
30
+ thor (>= 0.14.0)
31
+ beetle (3.4.1)
32
+ activesupport (>= 2.3.4)
33
+ amq-protocol (= 2.3.1)
34
+ amqp (= 1.8.0)
35
+ bunny (~> 0.7.12)
36
+ hiredis (>= 0.4.5)
37
+ redis (>= 4.2.1)
38
+ bunny (0.7.12)
39
+ byebug (11.1.3)
40
+ concurrent-ruby (1.1.6)
41
+ dalli (2.7.10)
42
+ eventmachine (1.2.7)
43
+ hiredis (0.6.3)
44
+ i18n (1.8.3)
45
+ concurrent-ruby (~> 1.0)
46
+ memcached (1.8.0)
47
+ minitest (5.14.1)
48
+ mocha (1.11.2)
49
+ mysql2 (0.5.3)
50
+ rake (13.0.1)
51
+ redis (4.2.1)
52
+ sequel (5.33.0)
53
+ thor (1.0.1)
54
+ thread_safe (0.3.6)
55
+ thread_variables (0.2.0)
56
+ tzinfo (1.2.7)
57
+ thread_safe (~> 0.1)
58
+ zeitwerk (2.3.0)
59
+
60
+ PLATFORMS
61
+ ruby
62
+
63
+ DEPENDENCIES
64
+ activerecord (= 6.0.3.2)
65
+ activesupport (= 6.0.3.2)
66
+ ansi
67
+ appraisal
68
+ beetle (>= 3.4.1)
69
+ byebug
70
+ dalli
71
+ memcached (~> 1.8.0)
72
+ minitest (~> 5.5)
73
+ mocha
74
+ mysql2
75
+ rake
76
+ redis
77
+ sequel
78
+ time_bandits!
79
+
80
+ BUNDLED WITH
81
+ 2.1.4
@@ -5,11 +5,7 @@ require 'thread_variables'
5
5
  module TimeBandits
6
6
 
7
7
  module TimeConsumers
8
- if defined?(Rails) && Rails::VERSION::STRING < "3.0"
9
- autoload :Database, 'time_bandits/time_consumers/database_rails2'
10
- else
11
- autoload :Database, 'time_bandits/time_consumers/database'
12
- end
8
+ autoload :Database, 'time_bandits/time_consumers/database'
13
9
  autoload :GarbageCollection, 'time_bandits/time_consumers/garbage_collection'
14
10
  autoload :JMX, 'time_bandits/time_consumers/jmx'
15
11
  autoload :MemCache, 'time_bandits/time_consumers/mem_cache'
@@ -20,7 +16,7 @@ module TimeBandits
20
16
  autoload :Beetle, 'time_bandits/time_consumers/beetle'
21
17
  end
22
18
 
23
- require 'time_bandits/railtie' if defined?(Rails) && Rails::VERSION::STRING >= "3.0"
19
+ require 'time_bandits/railtie' if defined?(Rails)
24
20
  require 'time_bandits/time_consumers/base_consumer'
25
21
 
26
22
  mattr_accessor :time_bandits
@@ -4,45 +4,6 @@ module ActionController #:nodoc:
4
4
 
5
5
  module Instrumentation
6
6
 
7
- # patch to ensure that the completed line is always written to the log.
8
- # this is not necessary anymore with Rails 4 and higher.
9
- def process_action(action, *args)
10
- raw_payload = get_raw_payload
11
- ActiveSupport::Notifications.instrument("start_processing.action_controller", raw_payload.dup)
12
-
13
- exception = nil
14
- result = ActiveSupport::Notifications.instrument("process_action.action_controller", raw_payload) do |payload|
15
- begin
16
- super
17
- rescue Exception => exception
18
- response.status = 500
19
- nil
20
- ensure
21
- payload[:status] = response.status
22
- append_info_to_payload(payload)
23
- end
24
- end
25
- raise exception if exception
26
- result
27
- end unless Rails::VERSION::STRING >= "4.0"
28
-
29
- # patch to ensure that render times are always recorded in the log.
30
- # this is not necessary anymore with Rails 3 and up.
31
- def render(*args)
32
- render_output = nil
33
- exception = nil
34
- self.view_runtime = cleanup_view_runtime do
35
- Benchmark.ms do
36
- begin
37
- render_output = super
38
- rescue Exception => exception
39
- end
40
- end
41
- end
42
- raise exception if exception
43
- render_output
44
- end unless Rails::VERSION::STRING >= "3.0"
45
-
46
7
  def cleanup_view_runtime #:nodoc:
47
8
  consumed_before_rendering = TimeBandits.consumed
48
9
  runtime = yield
@@ -52,32 +13,6 @@ module ActionController #:nodoc:
52
13
 
53
14
  private
54
15
 
55
- if Rails::VERSION::STRING =~ /\A3\.[01]/
56
- def get_raw_payload
57
- {
58
- :controller => self.class.name,
59
- :action => self.action_name,
60
- :params => request.filtered_parameters,
61
- :formats => request.formats.map(&:to_sym),
62
- :method => request.method,
63
- :path => (request.fullpath rescue "unknown")
64
- }
65
- end
66
- elsif Rails::VERSION::STRING =~ /\A3\.2/
67
- def get_raw_payload
68
- {
69
- :controller => self.class.name,
70
- :action => self.action_name,
71
- :params => request.filtered_parameters,
72
- :format => request.format.try(:ref),
73
- :method => request.method,
74
- :path => (request.fullpath rescue "unknown")
75
- }
76
- end
77
- elsif Rails::VERSION::STRING < "3"
78
- raise "time_bandits ActionController monkey patch is not compatible with your Rails version"
79
- end
80
-
81
16
  module ClassMethods
82
17
  # patch to log rendering time with more precision
83
18
  def log_process_action(payload) #:nodoc:
@@ -104,7 +39,7 @@ module ActionController #:nodoc:
104
39
 
105
40
  # this is an ugly hack to ensure completed lines show up in the test logs
106
41
  # TODO: move this code to some other place
107
- return unless Rails.env.test? && Rails::VERSION::STRING >= "3.2"
42
+ return unless Rails.env.test?
108
43
 
109
44
  status = payload[:status]
110
45
  if status.nil? && payload[:exception].present?
@@ -118,7 +53,7 @@ module ActionController #:nodoc:
118
53
  end
119
54
  end
120
55
 
121
- # this gets included in ActionController::Base
56
+ # this gets included in ActionController::Base in the time_bandits railtie
122
57
  module TimeBanditry #:nodoc:
123
58
  extend ActiveSupport::Concern
124
59