time_bandits 0.12.1 → 0.12.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e7b550a5d77896484401846b736c019fba606ae7ab266a14cff054c5f392f61
4
- data.tar.gz: d8d58687ebe4687e75ec71b8caf0cba39229a72a50edc614cdd0f0df2200bdbe
3
+ metadata.gz: be90aa917ea9d4256501dc921da7fea5c9f1c9608f89fc7e5e5dace634b0353f
4
+ data.tar.gz: 29d87ff61dfa62a3202434df9d687ae9dc8e9d5e6e4b9e0ef4709049b7abee51
5
5
  SHA512:
6
- metadata.gz: ae0535036dd2df5545890147db397693b8c4afb5c86858d4affaf3f558c5c7a61dd08ece46b47387a280b1283f3f0518dcb916a0d5bd03622ff050b10904175a
7
- data.tar.gz: fc61fda4602282fd0a708a695f0ab410f18f9eed931ced47e2aae8177241dda2d72bf2cce903d4cc2fb9ad0abfcebec91da42c1897635bc42c761ad3e1c65fac
6
+ metadata.gz: e6692b8d8d10889442cc67f583fb6b98535f6a7ab3b060698c9dfef256f933bb976670dd1e672ba16a63d085d5238ade7704e7c1e9240ffc3da67d60e9a33435
7
+ data.tar.gz: b98ab1c3669dd66162199ad6a78bf113a598b8836a0a793404fa1dd28248fc43751ad32439ae03b3732a16f7476ad2109cacdc2c9cc7b57eec24ecb07475c460
@@ -0,0 +1,46 @@
1
+ name: build
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+
12
+ runs-on: ubuntu-latest
13
+
14
+ strategy:
15
+ matrix:
16
+ ruby-version: [3.1.0, 3.0.3, 2.7.5, 2.6.9]
17
+
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+
21
+ - name: Start containers
22
+ run: docker-compose -f docker-compose.yml up -d
23
+
24
+ - name: Set up Ruby ${{ matrix.ruby-version }}
25
+ uses: ruby/setup-ruby@v1
26
+ with:
27
+ ruby-version: ${{ matrix.ruby-version }}
28
+
29
+ - name: Install dependencies
30
+ run: sudo apt-get install libsasl2-dev
31
+
32
+ - name: Install gems
33
+ run: bundle install
34
+
35
+ - name: Run tests
36
+ run: bundle exec rake test
37
+
38
+ - name: Install appraisals
39
+ run: bundle exec appraisal install
40
+
41
+ - name: Run appraisals
42
+ run: bundle exec appraisal rake test
43
+
44
+ - name: Stop containers
45
+ if: always()
46
+ run: docker-compose -f "docker-compose.yml" down
data/.gitignore CHANGED
@@ -6,3 +6,4 @@ pkg/*
6
6
  .DS_Store
7
7
  .rvmrc
8
8
  dump.rdb
9
+ gemfiles/*
data/Appraisals CHANGED
@@ -1,7 +1,12 @@
1
- [
2
- "5.2.4.3",
3
- "6.0.3.2"
4
- ].each do |rails_version|
1
+ appraisals = [
2
+ "6.0.4.4",
3
+ "6.1.4.4",
4
+ ]
5
+
6
+ appraisals.insert(0, "5.2.6") if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3.0.0")
7
+ appraisals << "7.0.1" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.0")
8
+
9
+ appraisals.each do |rails_version|
5
10
  appraise "activesupport-#{rails_version}" do
6
11
  gem "activesupport", rails_version
7
12
  gem "activerecord", rails_version
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009-2020 Stefan Kaes <skaes@railsexpress.de>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -4,6 +4,9 @@
4
4
 
5
5
  Time Bandits is a gem plugin for Rails which enhances Rails' controller/view/db benchmark logging.
6
6
 
7
+ ![Build](https://github.com/skaes/time_bandits/actions/workflows/run-tests.yml/badge.svg)
8
+
9
+
7
10
  ## Usage
8
11
 
9
12
  Without configuration, the standard Rails 'Completed line' will change
@@ -85,6 +88,12 @@ Run `docker-compose up` to start Redis, MySQL, RabbitMQ and Memached containers,
85
88
 
86
89
  ## Release Notes
87
90
 
91
+ ## Version 0.12.3
92
+ - suppress Ruby 2.7 warnings about keyword parameters in controller tests
93
+
94
+ ## Version 0.12.2
95
+ - fixed that completed line was logged twice in Rails test environment
96
+
88
97
  ## Version 0.12.1
89
98
  - support having the rails gem in a bundle without activating the time bandits railtie
90
99
  - automatically install the garbage collection time bandit in rails applications
@@ -185,26 +194,4 @@ Run `docker-compose up` to start Redis, MySQL, RabbitMQ and Memached containers,
185
194
  - times are all measured in milliseconds internally
186
195
  - added class TimeBandits::TimeConsumers::BaseConsumer to simplify writing custom consumers
187
196
 
188
- ## License
189
-
190
- Copyright (c) 2009-2020 Stefan Kaes <skaes@railsexpress.de>
191
-
192
- Permission is hereby granted, free of charge, to any person obtaining
193
- a copy of this software and associated documentation files (the
194
- "Software"), to deal in the Software without restriction, including
195
- without limitation the rights to use, copy, modify, merge, publish,
196
- distribute, sublicense, and/or sell copies of the Software, and to
197
- permit persons to whom the Software is furnished to do so, subject to
198
- the following conditions:
199
-
200
- The above copyright notice and this permission notice shall be
201
- included in all copies or substantial portions of the Software.
202
-
203
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
204
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
205
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
206
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
207
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
208
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
209
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
210
197
 
data/docker-compose.yml CHANGED
@@ -11,18 +11,18 @@ services:
11
11
 
12
12
  memcached:
13
13
  container_name: memcached
14
- image: memcached:1.6.6
14
+ image: memcached:1.6.8
15
15
  ports:
16
16
  - "11211:11211"
17
17
 
18
18
  redis:
19
19
  container_name: redis
20
- image: redis:5.0.9
20
+ image: redis:5.0
21
21
  ports:
22
22
  - "6379:6379"
23
23
 
24
24
  rabbitmq:
25
25
  container_name: rabbitmq
26
- image: rabbitmq:3.8.5
26
+ image: rabbitmq:3.8
27
27
  ports:
28
28
  - "5672:5672"
@@ -36,20 +36,6 @@ module ActionController #:nodoc:
36
36
  :time_bandits_completed_info,
37
37
  [ event.duration, additions, payload[:view_runtime], "#{payload[:controller]}##{payload[:action]}" ]
38
38
  )
39
-
40
- # this is an ugly hack to ensure completed lines show up in the test logs
41
- # TODO: move this code to some other place
42
- return unless Rails.env.test?
43
-
44
- status = payload[:status]
45
- if status.nil? && payload[:exception].present?
46
- exception_class_name = payload[:exception].first
47
- status = ActionDispatch::ExceptionWrapper.status_code_for_exception(exception_class_name)
48
- end
49
- message = "Completed #{status} #{Rack::Utils::HTTP_STATUS_CODES[status]} in %.1fms" % event.duration
50
- message << " (#{additions.join(" | ")})" unless additions.blank?
51
-
52
- info(message)
53
39
  end
54
40
  end
55
41
 
@@ -7,7 +7,8 @@ module TimeBandits
7
7
  class Railtie < Rails::Railtie
8
8
 
9
9
  initializer "time_bandits" do |app|
10
- app.config.middleware.swap(Rails::Rack::Logger, TimeBandits::Rack::Logger)
10
+ app.config.middleware.insert_after(Rails::Rack::Logger, TimeBandits::Rack::Logger)
11
+ app.config.middleware.delete(Rails::Rack::Logger)
11
12
 
12
13
  ActiveSupport.on_load(:action_controller) do
13
14
  require 'time_bandits/monkey_patches/action_controller'
@@ -25,9 +26,9 @@ module TimeBandits
25
26
  # Rails 5 fires on_load events multiple times, so we need to protect against endless recursion here
26
27
  next if ActionController::TestCase::Behavior.instance_methods.include?(:process_without_time_bandits)
27
28
  module ActionController::TestCase::Behavior
28
- def process_with_time_bandits(*args)
29
+ def process_with_time_bandits(action, **opts)
29
30
  TimeBandits.reset
30
- process_without_time_bandits(*args)
31
+ process_without_time_bandits(action, **opts)
31
32
  end
32
33
  alias_method :process_without_time_bandits, :process
33
34
  alias_method :process, :process_with_time_bandits
@@ -29,6 +29,8 @@ module TimeBandits
29
29
 
30
30
  if GC.respond_to?(:time)
31
31
  def _get_gc_time; GC.time; end
32
+ elsif GC.respond_to?(:total_time)
33
+ def _get_gc_time; GC.total_time / 1000; end
32
34
  else
33
35
  def _get_gc_time; 0; end
34
36
  end
@@ -40,7 +42,8 @@ module TimeBandits
40
42
  if GC.respond_to?(:total_malloced_bytes)
41
43
  def _get_allocated_size; GC.total_malloced_bytes; end
42
44
  else
43
- def _get_allocated_size; 0; end
45
+ # this will wrap around :malloc_increase_bytes_limit so is not really correct
46
+ def _get_allocated_size; GC.stat(:malloc_increase_bytes); end
44
47
  end
45
48
 
46
49
  if GC.respond_to?(:heap_slots)
@@ -81,7 +84,9 @@ module TimeBandits
81
84
  end
82
85
 
83
86
  def allocated_size
84
- _get_allocated_size - @allocated_size
87
+ new_size = _get_allocated_size
88
+ old_size = @allocated_size
89
+ new_size <= old_size ? new_size : new_size - old_size
85
90
  end
86
91
 
87
92
  def heap_growth
@@ -1,3 +1,3 @@
1
1
  module TimeBandits
2
- VERSION = "0.12.1"
2
+ VERSION = "0.12.5"
3
3
  end
@@ -32,11 +32,11 @@ class SequelTest < Test::Unit::TestCase
32
32
  end
33
33
 
34
34
  def mysql_port
35
- ENV['TRAVIS'] == "true" ? 3306 : 3601
35
+ 3601
36
36
  end
37
37
 
38
38
  def sequel
39
- @sequel ||= Sequel.mysql2(host: "localhost", port: mysql_port, user: "root")
39
+ @sequel ||= Sequel.mysql2(host: "127.0.0.1", port: mysql_port, user: "root")
40
40
  end
41
41
 
42
42
  def metrics
data/time_bandits.gemspec CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
29
29
  s.add_development_dependency("byebug")
30
30
  s.add_development_dependency("dalli")
31
31
  s.add_development_dependency("memcached", "~> 1.8.0")
32
- s.add_development_dependency("minitest", "~> 5.5")
32
+ s.add_development_dependency("minitest")
33
33
  s.add_development_dependency("mocha")
34
34
  s.add_development_dependency("mysql2")
35
35
  s.add_development_dependency("rake")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time_bandits
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.12.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Kaes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-04 00:00:00.000000000 Z
11
+ date: 2022-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thread_variables
@@ -112,16 +112,16 @@ dependencies:
112
112
  name: minitest
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - "~>"
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
- version: '5.5'
117
+ version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - "~>"
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
- version: '5.5'
124
+ version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: mocha
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -227,18 +227,15 @@ executables: []
227
227
  extensions: []
228
228
  extra_rdoc_files: []
229
229
  files:
230
+ - ".github/workflows/run-tests.yml"
230
231
  - ".gitignore"
231
- - ".travis.yml"
232
232
  - Appraisals
233
233
  - Gemfile
234
+ - LICENSE.txt
234
235
  - README.md
235
236
  - Rakefile
236
237
  - TODO
237
238
  - docker-compose.yml
238
- - gemfiles/activesupport_5.2.4.3.gemfile
239
- - gemfiles/activesupport_5.2.4.3.gemfile.lock
240
- - gemfiles/activesupport_6.0.3.2.gemfile
241
- - gemfiles/activesupport_6.0.3.2.gemfile.lock
242
239
  - lib/time_bandits.rb
243
240
  - lib/time_bandits/monkey_patches/action_controller.rb
244
241
  - lib/time_bandits/monkey_patches/active_record.rb
@@ -291,7 +288,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
291
288
  - !ruby/object:Gem::Version
292
289
  version: '0'
293
290
  requirements: []
294
- rubygems_version: 3.1.2
291
+ rubygems_version: 3.2.33
295
292
  signing_key:
296
293
  specification_version: 4
297
294
  summary: Custom performance logging for Rails
data/.travis.yml DELETED
@@ -1,23 +0,0 @@
1
- dist: bionic
2
- language: ruby
3
- rvm:
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"
10
- services:
11
- - redis-server
12
- - memcached
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
@@ -1,8 +0,0 @@
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: "../"
@@ -1,81 +0,0 @@
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
@@ -1,8 +0,0 @@
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: "../"
@@ -1,81 +0,0 @@
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