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
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "activesupport", "5.0.3"
6
- gem "activerecord", "5.0.3"
7
-
8
- gemspec :path => "../"
@@ -1,88 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- time_bandits (0.10.7)
5
- activesupport (>= 2.3.2)
6
- thread_variables
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- activemodel (5.0.3)
12
- activesupport (= 5.0.3)
13
- activerecord (5.0.3)
14
- activemodel (= 5.0.3)
15
- activesupport (= 5.0.3)
16
- arel (~> 7.0)
17
- activesupport (5.0.3)
18
- concurrent-ruby (~> 1.0, >= 1.0.2)
19
- i18n (~> 0.7)
20
- minitest (~> 5.1)
21
- tzinfo (~> 1.1)
22
- amq-protocol (2.0.1)
23
- amqp (1.6.0)
24
- amq-protocol (>= 2.0.1)
25
- eventmachine
26
- ansi (1.5.0)
27
- appraisal (2.2.0)
28
- bundler
29
- rake
30
- thor (>= 0.14.0)
31
- arel (7.1.4)
32
- beetle (1.0.3)
33
- activesupport (>= 2.3.4)
34
- amq-protocol (= 2.0.1)
35
- amqp (= 1.6.0)
36
- bunny (~> 0.7.10)
37
- daemons (>= 1.2.0)
38
- eventmachine_httpserver (>= 0.2.1)
39
- hiredis (>= 0.4.5)
40
- redis (>= 2.2.2)
41
- uuid4r (>= 0.1.2)
42
- bunny (0.7.10)
43
- byebug (9.0.6)
44
- concurrent-ruby (1.0.5)
45
- daemons (1.2.4)
46
- dalli (2.7.6)
47
- eventmachine (1.2.3)
48
- eventmachine_httpserver (0.2.1)
49
- hiredis (0.6.1)
50
- i18n (0.8.4)
51
- memcached (1.8.0)
52
- metaclass (0.0.4)
53
- minitest (5.10.2)
54
- mocha (1.2.1)
55
- metaclass (~> 0.0.1)
56
- mysql2 (0.4.6)
57
- rake (10.5.0)
58
- redis (3.3.3)
59
- sequel (4.47.0)
60
- thor (0.19.4)
61
- thread_safe (0.3.6)
62
- thread_variables (0.2.0)
63
- tzinfo (1.2.3)
64
- thread_safe (~> 0.1)
65
- uuid4r (0.2.0)
66
-
67
- PLATFORMS
68
- ruby
69
-
70
- DEPENDENCIES
71
- activerecord (= 5.0.3)
72
- activesupport (= 5.0.3)
73
- ansi
74
- appraisal
75
- beetle (>= 0.4.6)
76
- byebug
77
- dalli
78
- memcached (~> 1.8.0)
79
- minitest (~> 5.5)
80
- mocha
81
- mysql2
82
- rake (~> 10.5.0)
83
- redis
84
- sequel
85
- time_bandits!
86
-
87
- BUNDLED WITH
88
- 1.15.1
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "activesupport", "5.0.4"
6
- gem "activerecord", "5.0.4"
7
-
8
- gemspec :path => "../"
@@ -1,88 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- time_bandits (0.10.7)
5
- activesupport (>= 2.3.2)
6
- thread_variables
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- activemodel (5.0.4)
12
- activesupport (= 5.0.4)
13
- activerecord (5.0.4)
14
- activemodel (= 5.0.4)
15
- activesupport (= 5.0.4)
16
- arel (~> 7.0)
17
- activesupport (5.0.4)
18
- concurrent-ruby (~> 1.0, >= 1.0.2)
19
- i18n (~> 0.7)
20
- minitest (~> 5.1)
21
- tzinfo (~> 1.1)
22
- amq-protocol (2.0.1)
23
- amqp (1.6.0)
24
- amq-protocol (>= 2.0.1)
25
- eventmachine
26
- ansi (1.5.0)
27
- appraisal (2.2.0)
28
- bundler
29
- rake
30
- thor (>= 0.14.0)
31
- arel (7.1.4)
32
- beetle (1.0.3)
33
- activesupport (>= 2.3.4)
34
- amq-protocol (= 2.0.1)
35
- amqp (= 1.6.0)
36
- bunny (~> 0.7.10)
37
- daemons (>= 1.2.0)
38
- eventmachine_httpserver (>= 0.2.1)
39
- hiredis (>= 0.4.5)
40
- redis (>= 2.2.2)
41
- uuid4r (>= 0.1.2)
42
- bunny (0.7.10)
43
- byebug (9.0.6)
44
- concurrent-ruby (1.0.5)
45
- daemons (1.2.4)
46
- dalli (2.7.6)
47
- eventmachine (1.2.3)
48
- eventmachine_httpserver (0.2.1)
49
- hiredis (0.6.1)
50
- i18n (0.8.4)
51
- memcached (1.8.0)
52
- metaclass (0.0.4)
53
- minitest (5.10.2)
54
- mocha (1.2.1)
55
- metaclass (~> 0.0.1)
56
- mysql2 (0.4.7)
57
- rake (10.5.0)
58
- redis (3.3.3)
59
- sequel (4.48.0)
60
- thor (0.19.4)
61
- thread_safe (0.3.6)
62
- thread_variables (0.2.0)
63
- tzinfo (1.2.3)
64
- thread_safe (~> 0.1)
65
- uuid4r (0.2.0)
66
-
67
- PLATFORMS
68
- ruby
69
-
70
- DEPENDENCIES
71
- activerecord (= 5.0.4)
72
- activesupport (= 5.0.4)
73
- ansi
74
- appraisal
75
- beetle (>= 0.4.6)
76
- byebug
77
- dalli
78
- memcached (~> 1.8.0)
79
- minitest (~> 5.5)
80
- mocha
81
- mysql2
82
- rake (~> 10.5.0)
83
- redis
84
- sequel
85
- time_bandits!
86
-
87
- BUNDLED WITH
88
- 1.15.1
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "activesupport", "5.1.1"
6
- gem "activerecord", "5.1.1"
7
-
8
- gemspec :path => "../"
@@ -1,88 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- time_bandits (0.10.7)
5
- activesupport (>= 2.3.2)
6
- thread_variables
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- activemodel (5.1.1)
12
- activesupport (= 5.1.1)
13
- activerecord (5.1.1)
14
- activemodel (= 5.1.1)
15
- activesupport (= 5.1.1)
16
- arel (~> 8.0)
17
- activesupport (5.1.1)
18
- concurrent-ruby (~> 1.0, >= 1.0.2)
19
- i18n (~> 0.7)
20
- minitest (~> 5.1)
21
- tzinfo (~> 1.1)
22
- amq-protocol (2.0.1)
23
- amqp (1.6.0)
24
- amq-protocol (>= 2.0.1)
25
- eventmachine
26
- ansi (1.5.0)
27
- appraisal (2.2.0)
28
- bundler
29
- rake
30
- thor (>= 0.14.0)
31
- arel (8.0.0)
32
- beetle (1.0.3)
33
- activesupport (>= 2.3.4)
34
- amq-protocol (= 2.0.1)
35
- amqp (= 1.6.0)
36
- bunny (~> 0.7.10)
37
- daemons (>= 1.2.0)
38
- eventmachine_httpserver (>= 0.2.1)
39
- hiredis (>= 0.4.5)
40
- redis (>= 2.2.2)
41
- uuid4r (>= 0.1.2)
42
- bunny (0.7.10)
43
- byebug (9.0.6)
44
- concurrent-ruby (1.0.5)
45
- daemons (1.2.4)
46
- dalli (2.7.6)
47
- eventmachine (1.2.3)
48
- eventmachine_httpserver (0.2.1)
49
- hiredis (0.6.1)
50
- i18n (0.8.4)
51
- memcached (1.8.0)
52
- metaclass (0.0.4)
53
- minitest (5.10.2)
54
- mocha (1.2.1)
55
- metaclass (~> 0.0.1)
56
- mysql2 (0.4.6)
57
- rake (10.5.0)
58
- redis (3.3.3)
59
- sequel (4.47.0)
60
- thor (0.19.4)
61
- thread_safe (0.3.6)
62
- thread_variables (0.2.0)
63
- tzinfo (1.2.3)
64
- thread_safe (~> 0.1)
65
- uuid4r (0.2.0)
66
-
67
- PLATFORMS
68
- ruby
69
-
70
- DEPENDENCIES
71
- activerecord (= 5.1.1)
72
- activesupport (= 5.1.1)
73
- ansi
74
- appraisal
75
- beetle (>= 0.4.6)
76
- byebug
77
- dalli
78
- memcached (~> 1.8.0)
79
- minitest (~> 5.5)
80
- mocha
81
- mysql2
82
- rake (~> 10.5.0)
83
- redis
84
- sequel
85
- time_bandits!
86
-
87
- BUNDLED WITH
88
- 1.15.1
@@ -1,8 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "activesupport", "5.1.2"
6
- gem "activerecord", "5.1.2"
7
-
8
- gemspec :path => "../"
@@ -1,88 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- time_bandits (0.10.7)
5
- activesupport (>= 2.3.2)
6
- thread_variables
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- activemodel (5.1.2)
12
- activesupport (= 5.1.2)
13
- activerecord (5.1.2)
14
- activemodel (= 5.1.2)
15
- activesupport (= 5.1.2)
16
- arel (~> 8.0)
17
- activesupport (5.1.2)
18
- concurrent-ruby (~> 1.0, >= 1.0.2)
19
- i18n (~> 0.7)
20
- minitest (~> 5.1)
21
- tzinfo (~> 1.1)
22
- amq-protocol (2.0.1)
23
- amqp (1.6.0)
24
- amq-protocol (>= 2.0.1)
25
- eventmachine
26
- ansi (1.5.0)
27
- appraisal (2.2.0)
28
- bundler
29
- rake
30
- thor (>= 0.14.0)
31
- arel (8.0.0)
32
- beetle (1.0.3)
33
- activesupport (>= 2.3.4)
34
- amq-protocol (= 2.0.1)
35
- amqp (= 1.6.0)
36
- bunny (~> 0.7.10)
37
- daemons (>= 1.2.0)
38
- eventmachine_httpserver (>= 0.2.1)
39
- hiredis (>= 0.4.5)
40
- redis (>= 2.2.2)
41
- uuid4r (>= 0.1.2)
42
- bunny (0.7.10)
43
- byebug (9.0.6)
44
- concurrent-ruby (1.0.5)
45
- daemons (1.2.4)
46
- dalli (2.7.6)
47
- eventmachine (1.2.3)
48
- eventmachine_httpserver (0.2.1)
49
- hiredis (0.6.1)
50
- i18n (0.8.4)
51
- memcached (1.8.0)
52
- metaclass (0.0.4)
53
- minitest (5.10.2)
54
- mocha (1.2.1)
55
- metaclass (~> 0.0.1)
56
- mysql2 (0.4.7)
57
- rake (10.5.0)
58
- redis (3.3.3)
59
- sequel (4.48.0)
60
- thor (0.19.4)
61
- thread_safe (0.3.6)
62
- thread_variables (0.2.0)
63
- tzinfo (1.2.3)
64
- thread_safe (~> 0.1)
65
- uuid4r (0.2.0)
66
-
67
- PLATFORMS
68
- ruby
69
-
70
- DEPENDENCIES
71
- activerecord (= 5.1.2)
72
- activesupport (= 5.1.2)
73
- ansi
74
- appraisal
75
- beetle (>= 0.4.6)
76
- byebug
77
- dalli
78
- memcached (~> 1.8.0)
79
- minitest (~> 5.5)
80
- mocha
81
- mysql2
82
- rake (~> 10.5.0)
83
- redis
84
- sequel
85
- time_bandits!
86
-
87
- BUNDLED WITH
88
- 1.15.1
@@ -1,18 +0,0 @@
1
- require "active_support/cache"
2
-
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
-
7
- class ActiveSupport::Cache::Store
8
- private
9
- # only called by fetch
10
- def find_cached_entry(key, name, options)
11
- instrument(:read, name, options) do |payload|
12
- payload[:super_operation] = :fetch if payload
13
- res = read_entry(key, options)
14
- payload[:hit] = !!res if payload
15
- res
16
- end
17
- end
18
- end
@@ -1,94 +0,0 @@
1
- require 'active_support/core_ext/time/conversions'
2
- require 'active_support/core_ext/object/blank'
3
- require 'active_support/log_subscriber'
4
- require 'action_dispatch/http/request'
5
- require 'rack/body_proxy'
6
-
7
- module TimeBandits
8
- module Rack
9
- # Sets log tags, logs the request, calls the app, and flushes the logs.
10
- class Logger < ActiveSupport::LogSubscriber
11
- def initialize(app, taggers = nil)
12
- @app = app
13
- @taggers = taggers || Rails.application.config.log_tags || []
14
- @instrumenter = ActiveSupport::Notifications.instrumenter
15
- end
16
-
17
- def call(env)
18
- request = ActionDispatch::Request.new(env)
19
-
20
- if logger.respond_to?(:tagged) && !@taggers.empty?
21
- logger.tagged(compute_tags(request)) { call_app(request, env) }
22
- else
23
- call_app(request, env)
24
- end
25
- end
26
-
27
- protected
28
-
29
- def call_app(request, env)
30
- start_time = Time.now
31
- start(request, start_time)
32
- resp = @app.call(env)
33
- resp[2] = ::Rack::BodyProxy.new(resp[2]) { finish(request) }
34
- resp
35
- rescue
36
- finish(request)
37
- raise
38
- ensure
39
- completed(request, (Time.now - start_time) * 1000, resp)
40
- ActiveSupport::LogSubscriber.flush_all!
41
- end
42
-
43
- # Started GET "/session/new" for 127.0.0.1 at 2012-09-26 14:51:42 -0700
44
- def started_request_message(request, start_time=Time.now)
45
- 'Started %s "%s" for %s at %s' % [
46
- request.request_method,
47
- request.filtered_path,
48
- request.ip,
49
- start_time.to_default_s ]
50
- end
51
-
52
- def compute_tags(request)
53
- @taggers.collect do |tag|
54
- case tag
55
- when Proc
56
- tag.call(request)
57
- when Symbol
58
- request.send(tag)
59
- else
60
- tag
61
- end
62
- end
63
- end
64
-
65
- private
66
-
67
- def start(request, start_time)
68
- TimeBandits.reset
69
- Thread.current.thread_variable_set(:time_bandits_completed_info, nil)
70
- @instrumenter.start 'action_dispatch.request', request: request
71
-
72
- logger.debug ""
73
- logger.info started_request_message(request, start_time)
74
- end
75
-
76
- def completed(request, run_time, resp)
77
- status = resp ? resp.first.to_i : 500
78
- completed_info = Thread.current.thread_variable_get(:time_bandits_completed_info)
79
- additions = completed_info[1] if completed_info
80
- message = "Completed #{status} #{::Rack::Utils::HTTP_STATUS_CODES[status]} in %.1fms" % run_time
81
- message << " (#{additions.join(' | ')})" unless additions.blank?
82
- logger.info message
83
- end
84
-
85
- def finish(request)
86
- @instrumenter.finish 'action_dispatch.request', request: request
87
- end
88
-
89
- def logger
90
- @logger ||= Rails.logger
91
- end
92
- end
93
- end
94
- end