time_bandits 0.10.11 → 0.12.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +16 -4
  3. data/Appraisals +2 -10
  4. data/LICENSE.txt +20 -0
  5. data/README.md +25 -27
  6. data/Rakefile +1 -0
  7. data/docker-compose.yml +4 -4
  8. data/gemfiles/activesupport_5.2.4.3.gemfile +8 -0
  9. data/gemfiles/activesupport_5.2.4.3.gemfile.lock +81 -0
  10. data/gemfiles/activesupport_6.0.3.2.gemfile +8 -0
  11. data/gemfiles/activesupport_6.0.3.2.gemfile.lock +81 -0
  12. data/lib/time_bandits.rb +2 -6
  13. data/lib/time_bandits/monkey_patches/action_controller.rb +0 -79
  14. data/lib/time_bandits/monkey_patches/active_record.rb +18 -98
  15. data/lib/time_bandits/rack/logger.rb +46 -19
  16. data/lib/time_bandits/railtie.rb +6 -8
  17. data/lib/time_bandits/time_consumers/dalli.rb +0 -12
  18. data/lib/time_bandits/time_consumers/garbage_collection.rb +5 -29
  19. data/lib/time_bandits/version.rb +1 -1
  20. data/test/test_helper.rb +2 -10
  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 +21 -37
  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/gemfiles/activesupport_5.2.0.gemfile +0 -8
  42. data/gemfiles/activesupport_5.2.0.gemfile.lock +0 -85
  43. data/lib/time_bandits/monkey_patches/active_support_cache_store.rb +0 -18
  44. data/lib/time_bandits/rack/logger40.rb +0 -94
  45. 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.2.0"
6
- gem "activerecord", "5.2.0"
7
-
8
- gemspec :path => "../"
@@ -1,85 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- time_bandits (0.10.10)
5
- activesupport (>= 2.3.2)
6
- thread_variables
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- activemodel (5.2.0)
12
- activesupport (= 5.2.0)
13
- activerecord (5.2.0)
14
- activemodel (= 5.2.0)
15
- activesupport (= 5.2.0)
16
- arel (>= 9.0)
17
- activesupport (5.2.0)
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.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 (9.0.0)
32
- beetle (2.1.1)
33
- activesupport (>= 2.3.4)
34
- amq-protocol (= 2.0.1)
35
- amqp (= 1.6.0)
36
- bunny (~> 0.7.10)
37
- hiredis (>= 0.4.5)
38
- redis (>= 2.2.2)
39
- uuid4r (>= 0.1.2)
40
- bunny (0.7.11)
41
- byebug (10.0.2)
42
- concurrent-ruby (1.0.5)
43
- dalli (2.7.8)
44
- eventmachine (1.2.5)
45
- hiredis (0.6.1)
46
- i18n (1.0.0)
47
- concurrent-ruby (~> 1.0)
48
- memcached (1.8.0)
49
- metaclass (0.0.4)
50
- minitest (5.11.3)
51
- mocha (1.5.0)
52
- metaclass (~> 0.0.1)
53
- mysql2 (0.5.1)
54
- rake (10.5.0)
55
- redis (4.0.1)
56
- sequel (5.7.1)
57
- thor (0.20.0)
58
- thread_safe (0.3.6)
59
- thread_variables (0.2.0)
60
- tzinfo (1.2.5)
61
- thread_safe (~> 0.1)
62
- uuid4r (0.2.0)
63
-
64
- PLATFORMS
65
- ruby
66
-
67
- DEPENDENCIES
68
- activerecord (= 5.2.0)
69
- activesupport (= 5.2.0)
70
- ansi
71
- appraisal
72
- beetle (>= 0.4.6)
73
- byebug
74
- dalli
75
- memcached (~> 1.8.0)
76
- minitest (~> 5.5)
77
- mocha
78
- mysql2
79
- rake (~> 10.5.0)
80
- redis
81
- sequel
82
- time_bandits!
83
-
84
- BUNDLED WITH
85
- 1.16.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
@@ -1 +0,0 @@
1
- require File.expand_path('../../init.rb', __FILE__)