time_bandits 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +16 -4
  3. data/Appraisals +2 -16
  4. data/README.md +11 -6
  5. data/Rakefile +1 -0
  6. data/docker-compose.yml +4 -4
  7. data/gemfiles/{activesupport_5.0.4.gemfile → activesupport_5.2.4.3.gemfile} +2 -2
  8. data/gemfiles/{activesupport_5.2.3.gemfile.lock → activesupport_5.2.4.3.gemfile.lock} +29 -31
  9. data/gemfiles/{activesupport_4.2.9.gemfile → activesupport_6.0.3.2.gemfile} +2 -2
  10. data/gemfiles/{activesupport_5.1.7.gemfile.lock → activesupport_6.0.3.2.gemfile.lock} +31 -33
  11. data/lib/time_bandits.rb +2 -6
  12. data/lib/time_bandits/monkey_patches/action_controller.rb +1 -66
  13. data/lib/time_bandits/monkey_patches/active_record.rb +18 -116
  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 +2 -10
  20. data/test/unit/gc_consumer_test.rb +2 -3
  21. data/test/unit/sequel_test.rb +5 -1
  22. data/time_bandits.gemspec +6 -3
  23. metadata +20 -46
  24. data/gemfiles/activesupport_4.1.16.gemfile +0 -8
  25. data/gemfiles/activesupport_4.1.16.gemfile.lock +0 -91
  26. data/gemfiles/activesupport_4.2.8.gemfile +0 -8
  27. data/gemfiles/activesupport_4.2.8.gemfile.lock +0 -85
  28. data/gemfiles/activesupport_4.2.9.gemfile.lock +0 -85
  29. data/gemfiles/activesupport_5.0.3.gemfile +0 -8
  30. data/gemfiles/activesupport_5.0.3.gemfile.lock +0 -83
  31. data/gemfiles/activesupport_5.0.4.gemfile.lock +0 -83
  32. data/gemfiles/activesupport_5.0.7.2.gemfile +0 -8
  33. data/gemfiles/activesupport_5.0.7.2.gemfile.lock +0 -83
  34. data/gemfiles/activesupport_5.0.7.gemfile +0 -8
  35. data/gemfiles/activesupport_5.0.7.gemfile.lock +0 -83
  36. data/gemfiles/activesupport_5.1.1.gemfile +0 -8
  37. data/gemfiles/activesupport_5.1.1.gemfile.lock +0 -83
  38. data/gemfiles/activesupport_5.1.2.gemfile +0 -8
  39. data/gemfiles/activesupport_5.1.2.gemfile.lock +0 -83
  40. data/gemfiles/activesupport_5.1.5.gemfile +0 -8
  41. data/gemfiles/activesupport_5.1.5.gemfile.lock +0 -83
  42. data/gemfiles/activesupport_5.1.7.gemfile +0 -8
  43. data/gemfiles/activesupport_5.2.0.gemfile +0 -8
  44. data/gemfiles/activesupport_5.2.0.gemfile.lock +0 -83
  45. data/gemfiles/activesupport_5.2.3.gemfile +0 -8
  46. data/gemfiles/activesupport_6.0.0.gemfile +0 -8
  47. data/gemfiles/activesupport_6.0.0.gemfile.lock +0 -83
  48. data/lib/time_bandits/monkey_patches/active_support_cache_store.rb +0 -18
  49. data/lib/time_bandits/rack/logger40.rb +0 -94
  50. data/rails/init.rb +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 83242fd7d0fdb8779fea9b22a97773fccb5c311be2f81f87221987a00e2dcef8
4
- data.tar.gz: 4fa8253a1a6c280f05006969bfc21445cbe9bde31fe7389248b4118dc915f1f4
3
+ metadata.gz: 0ac35c38f3393a0ff15bd629eaa862ab6f80b8c23dd199bd7ab0a21081ed7adc
4
+ data.tar.gz: 640caa883d9975cd47a662c0995b97fba05de0795e374ab4719f4c50cc3e773a
5
5
  SHA512:
6
- metadata.gz: fd6139b93e05a294aab44109f5568c3492af1ac7bced768169d0ce0d7454caac10aee5da0b3f0d166d9103fe7e8eaefe0da7e52d1dd8dd70bf2a2e4d9b207882
7
- data.tar.gz: 509da4a961ab2640b464ed090286f6f43c4328e1a011f5d99e063150d9772bb236a4a0a5b168d754bcb68b52771e796bc8dd1eac8075e79966b237fb22fe8201
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.3.6
4
- - 2.4.3
5
- - 2.5.0
4
+ - 2.5.7
5
+ - 2.6.5
6
+ - 2.7.0
7
+ before_install:
8
+ - gem install bundler
6
9
  script: "bundle exec rake appraisal:test"
7
- sudo: false
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,21 +1,7 @@
1
1
  [
2
- "4.1.16",
3
- "4.2.8",
4
- "4.2.9",
5
- "4.2.11.1",
6
- "5.0.3",
7
- "5.0.4",
8
- "5.0.7",
9
- "5.0.7.2",
10
- "5.1.1",
11
- "5.1.2",
12
- "5.1.5",
13
- "5.1.7",
14
- "5.2.0",
15
- "5.2.3",
16
- "6.0.0"
2
+ "5.2.4.3",
3
+ "6.0.3.2"
17
4
  ].each do |rails_version|
18
- next if RUBY_VERSION >= "2.4.0" && rails_version < "4.2.8"
19
5
  appraise "activesupport-#{rails_version}" do
20
6
  gem "activesupport", rails_version
21
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,15 @@ 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
+
87
92
  ## Version 0.11.0
88
93
  - supports rails 6.0.0
89
94
 
@@ -178,7 +183,7 @@ In order for the test to run you need a running memcached, redis-server and mysq
178
183
 
179
184
  ## License
180
185
 
181
- Copyright (c) 2009-2014 Stefan Kaes <skaes@railsexpress.de>
186
+ Copyright (c) 2009-2020 Stefan Kaes <skaes@railsexpress.de>
182
187
 
183
188
  Permission is hereby granted, free of charge, to any person obtaining
184
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"
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem "activesupport", "5.0.4"
6
- gem "activerecord", "5.0.4"
5
+ gem "activesupport", "5.2.4.3"
6
+ gem "activerecord", "5.2.4.3"
7
7
 
8
8
  gemspec path: "../"
@@ -1,83 +1,81 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- time_bandits (0.10.12)
5
- activesupport (>= 2.3.2)
4
+ time_bandits (0.11.0)
5
+ activesupport (>= 5.2.4.3)
6
6
  thread_variables
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- activemodel (5.2.3)
12
- activesupport (= 5.2.3)
13
- activerecord (5.2.3)
14
- activemodel (= 5.2.3)
15
- activesupport (= 5.2.3)
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
16
  arel (>= 9.0)
17
- activesupport (5.2.3)
17
+ activesupport (5.2.4.3)
18
18
  concurrent-ruby (~> 1.0, >= 1.0.2)
19
19
  i18n (>= 0.7, < 2)
20
20
  minitest (~> 5.1)
21
21
  tzinfo (~> 1.1)
22
- amq-protocol (2.3.0)
22
+ amq-protocol (2.3.1)
23
23
  amqp (1.8.0)
24
24
  amq-protocol (>= 2.2.0)
25
25
  eventmachine
26
26
  ansi (1.5.0)
27
- appraisal (2.2.0)
27
+ appraisal (2.3.0)
28
28
  bundler
29
29
  rake
30
30
  thor (>= 0.14.0)
31
31
  arel (9.0.0)
32
- beetle (3.3.1)
32
+ beetle (3.4.1)
33
33
  activesupport (>= 2.3.4)
34
- amq-protocol (= 2.3.0)
34
+ amq-protocol (= 2.3.1)
35
35
  amqp (= 1.8.0)
36
36
  bunny (~> 0.7.12)
37
37
  hiredis (>= 0.4.5)
38
- redis (>= 2.2.2)
38
+ redis (>= 4.2.1)
39
39
  bunny (0.7.12)
40
- byebug (11.0.1)
41
- concurrent-ruby (1.1.5)
40
+ byebug (11.1.3)
41
+ concurrent-ruby (1.1.6)
42
42
  dalli (2.7.10)
43
43
  eventmachine (1.2.7)
44
44
  hiredis (0.6.3)
45
- i18n (1.6.0)
45
+ i18n (1.8.3)
46
46
  concurrent-ruby (~> 1.0)
47
47
  memcached (1.8.0)
48
- metaclass (0.0.4)
49
- minitest (5.11.3)
50
- mocha (1.9.0)
51
- metaclass (~> 0.0.1)
52
- mysql2 (0.5.2)
53
- rake (10.5.0)
54
- redis (4.1.2)
55
- sequel (5.23.0)
56
- thor (0.20.3)
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)
57
55
  thread_safe (0.3.6)
58
56
  thread_variables (0.2.0)
59
- tzinfo (1.2.5)
57
+ tzinfo (1.2.7)
60
58
  thread_safe (~> 0.1)
61
59
 
62
60
  PLATFORMS
63
61
  ruby
64
62
 
65
63
  DEPENDENCIES
66
- activerecord (= 5.2.3)
67
- activesupport (= 5.2.3)
64
+ activerecord (= 5.2.4.3)
65
+ activesupport (= 5.2.4.3)
68
66
  ansi
69
67
  appraisal
70
- beetle (>= 0.4.6)
68
+ beetle (>= 3.4.1)
71
69
  byebug
72
70
  dalli
73
71
  memcached (~> 1.8.0)
74
72
  minitest (~> 5.5)
75
73
  mocha
76
74
  mysql2
77
- rake (~> 10.5.0)
75
+ rake
78
76
  redis
79
77
  sequel
80
78
  time_bandits!
81
79
 
82
80
  BUNDLED WITH
83
- 1.17.3
81
+ 2.1.4
@@ -2,7 +2,7 @@
2
2
 
3
3
  source "http://rubygems.org"
4
4
 
5
- gem "activesupport", "4.2.9"
6
- gem "activerecord", "4.2.9"
5
+ gem "activesupport", "6.0.3.2"
6
+ gem "activerecord", "6.0.3.2"
7
7
 
8
8
  gemspec path: "../"
@@ -1,83 +1,81 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- time_bandits (0.10.12)
5
- activesupport (>= 2.3.2)
4
+ time_bandits (0.11.0)
5
+ activesupport (>= 5.2.4.3)
6
6
  thread_variables
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- activemodel (5.1.7)
12
- activesupport (= 5.1.7)
13
- activerecord (5.1.7)
14
- activemodel (= 5.1.7)
15
- activesupport (= 5.1.7)
16
- arel (~> 8.0)
17
- activesupport (5.1.7)
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)
18
17
  concurrent-ruby (~> 1.0, >= 1.0.2)
19
18
  i18n (>= 0.7, < 2)
20
19
  minitest (~> 5.1)
21
20
  tzinfo (~> 1.1)
22
- amq-protocol (2.3.0)
21
+ zeitwerk (~> 2.2, >= 2.2.2)
22
+ amq-protocol (2.3.1)
23
23
  amqp (1.8.0)
24
24
  amq-protocol (>= 2.2.0)
25
25
  eventmachine
26
26
  ansi (1.5.0)
27
- appraisal (2.2.0)
27
+ appraisal (2.3.0)
28
28
  bundler
29
29
  rake
30
30
  thor (>= 0.14.0)
31
- arel (8.0.0)
32
- beetle (3.3.1)
31
+ beetle (3.4.1)
33
32
  activesupport (>= 2.3.4)
34
- amq-protocol (= 2.3.0)
33
+ amq-protocol (= 2.3.1)
35
34
  amqp (= 1.8.0)
36
35
  bunny (~> 0.7.12)
37
36
  hiredis (>= 0.4.5)
38
- redis (>= 2.2.2)
37
+ redis (>= 4.2.1)
39
38
  bunny (0.7.12)
40
- byebug (11.0.1)
41
- concurrent-ruby (1.1.5)
39
+ byebug (11.1.3)
40
+ concurrent-ruby (1.1.6)
42
41
  dalli (2.7.10)
43
42
  eventmachine (1.2.7)
44
43
  hiredis (0.6.3)
45
- i18n (1.6.0)
44
+ i18n (1.8.3)
46
45
  concurrent-ruby (~> 1.0)
47
46
  memcached (1.8.0)
48
- metaclass (0.0.4)
49
- minitest (5.11.3)
50
- mocha (1.9.0)
51
- metaclass (~> 0.0.1)
52
- mysql2 (0.5.2)
53
- rake (10.5.0)
54
- redis (4.1.2)
55
- sequel (5.23.0)
56
- thor (0.20.3)
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)
57
54
  thread_safe (0.3.6)
58
55
  thread_variables (0.2.0)
59
- tzinfo (1.2.5)
56
+ tzinfo (1.2.7)
60
57
  thread_safe (~> 0.1)
58
+ zeitwerk (2.3.0)
61
59
 
62
60
  PLATFORMS
63
61
  ruby
64
62
 
65
63
  DEPENDENCIES
66
- activerecord (= 5.1.7)
67
- activesupport (= 5.1.7)
64
+ activerecord (= 6.0.3.2)
65
+ activesupport (= 6.0.3.2)
68
66
  ansi
69
67
  appraisal
70
- beetle (>= 0.4.6)
68
+ beetle (>= 3.4.1)
71
69
  byebug
72
70
  dalli
73
71
  memcached (~> 1.8.0)
74
72
  minitest (~> 5.5)
75
73
  mocha
76
74
  mysql2
77
- rake (~> 10.5.0)
75
+ rake
78
76
  redis
79
77
  sequel
80
78
  time_bandits!
81
79
 
82
80
  BUNDLED WITH
83
- 1.17.3
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?