time_bandits 0.10.10 → 0.12.1

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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +17 -5
  3. data/Appraisals +2 -9
  4. data/README.md +33 -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 +18 -98
  14. data/lib/time_bandits/rack/logger.rb +46 -19
  15. data/lib/time_bandits/railtie.rb +6 -8
  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 +6 -2
  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 -35
  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/gemfiles/activesupport_5.1.5.gemfile +0 -8
  40. data/gemfiles/activesupport_5.1.5.gemfile.lock +0 -85
  41. data/lib/time_bandits/monkey_patches/active_support_cache_store.rb +0 -18
  42. data/lib/time_bandits/rack/logger40.rb +0 -94
  43. data/rails/init.rb +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c58d28c93e2abce5a7e5748cafd1720e71e9efd1a9dbad61dfd84f8c388d18ac
4
- data.tar.gz: 4cdd00f82f637c496b5810f46ae1899c898f86850502626c33ab5d676bf8bacd
3
+ metadata.gz: 5e7b550a5d77896484401846b736c019fba606ae7ab266a14cff054c5f392f61
4
+ data.tar.gz: d8d58687ebe4687e75ec71b8caf0cba39229a72a50edc614cdd0f0df2200bdbe
5
5
  SHA512:
6
- metadata.gz: 0b9afbbe602af0a36640c60491f7de0e8bf173619572c65206a2502c2056a05f1b81d9b14c36ebfeacc69e9a7633cc3c53d8c308475dda258d54ffec4f294e57
7
- data.tar.gz: fc6dbf5399f916035854330e3a00a517fe50e809cbac3b30d35519c8a74e97eb6b3a8bf0a5c5e9d70f76825d30c69a873f584cacf7952696a427f75384677747
6
+ metadata.gz: ae0535036dd2df5545890147db397693b8c4afb5c86858d4affaf3f558c5c7a61dd08ece46b47387a280b1283f3f0518dcb916a0d5bd03622ff050b10904175a
7
+ data.tar.gz: fc61fda4602282fd0a708a695f0ab410f18f9eed931ced47e2aae8177241dda2d72bf2cce903d4cc2fb9ad0abfcebec91da42c1897635bc42c761ad3e1c65fac
@@ -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,14 +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",
9
- "5.1.5",
2
+ "5.2.4.3",
3
+ "6.0.3.2"
10
4
  ].each do |rails_version|
11
- next if RUBY_VERSION >= "2.4.0" && rails_version < "4.2.8"
12
5
  appraise "activesupport-#{rails_version}" do
13
6
  gem "activesupport", rails_version
14
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,37 @@ 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.1
89
+ - support having the rails gem in a bundle without activating the time bandits railtie
90
+ - automatically install the garbage collection time bandit in rails applications
91
+
92
+ ## Version 0.12.0
93
+ - drops support for Rails versions before 5.2.0 and Ruby versions before 2.2.0
94
+ - makes it possible to use individual time bandits without Rails (e.g. in a Sinatra app)
95
+
96
+ ## Version 0.11.0
97
+ - supports rails 6.0.0
98
+
99
+ ## Version 0.10.12
100
+ - supports rails 5.0.7
101
+
102
+ ## Version 0.10.11
103
+ - support rails 5.2.0
104
+
105
+ ## Version 0.10.10
106
+ - fixed regression introduced in 0.10.9
107
+
108
+ ### Version 0.10.9
109
+ - added specialized activerecord logging for Rails >= 5.1.5
110
+
111
+ ### Version 0.10.8
112
+ - rails has changed render_bind in 5.0.3
113
+
87
114
  ### Version 0.10.7
88
115
  - fixed bug in activerecord monkeypatch for Rails 5.1
89
116
 
@@ -160,7 +187,7 @@ In order for the test to run you need a running memcached, redis-server and mysq
160
187
 
161
188
  ## License
162
189
 
163
- Copyright (c) 2009-2014 Stefan Kaes <skaes@railsexpress.de>
190
+ Copyright (c) 2009-2020 Stefan Kaes <skaes@railsexpress.de>
164
191
 
165
192
  Permission is hereby granted, free of charge, to any person obtaining
166
193
  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::Railtie)
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