coverband 5.2.6.rc.4 → 5.2.6.rc.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45ab4b4c0eec8a0b642cb2236bb4fbf4b3117ec6af3c4279b37236f360fbeab6
4
- data.tar.gz: 07010dd790b47cecc8fd5318bc27ec779c8f801a33943694d794a6c23686723f
3
+ metadata.gz: a1de64754e397a6626449593243af6e5e89028b6b3a66b33ffe36d9ef7dde971
4
+ data.tar.gz: 58e2b221b3ed8e9c6280cd1a891dcb4e0d62e2d9d6ae14d565c0467e822af630
5
5
  SHA512:
6
- metadata.gz: 054ac7588139476dd9f0b51caa28023f037867eac12a89d523efa0ed220791e340a468f26a1fe5f67661986008449e492be2f005f948377f7d4e728604ed8c86
7
- data.tar.gz: d1c38bb92fb95e3125cb25eb188cefce1efe86ce68932078cd75a4ae417dd1626263aa3849f45edd37d72cbd86ba72627b78271354c6d6ddd23648859c47e5cf
6
+ metadata.gz: 4f68951b6a6d50dd4417970405ecc3d4ed00e64988ec3d2ef9da6136554c532edd9b7eddaacc12dbd4ee7a742e57bd90e565cd6fd2e35d9528bd4a35b20f37a8
7
+ data.tar.gz: bac5705947acbc4eb3619f7e0a6bc1c4055ffe2ea463017b583db65ea6b3ce281d14204b4b41149e44ab24b0ee722fad837595744158d452f19abc1941f5e245
@@ -22,11 +22,13 @@ jobs:
22
22
  # ruby: [2.3, 2.4, 2.5, 2.6, 2.7, "3.0", "3.1", jruby]
23
23
  # need to add support for multiple gemfiles
24
24
  ruby: ["2.7", "3.0", "3.1", "3.2"]
25
- redis-version: [4, 5, 6]
25
+ redis-version: [4, 5, 6, 7]
26
26
  runs-on: ${{ matrix.os }}-latest
27
27
  steps:
28
28
  - uses: actions/checkout@v3
29
29
  - uses: supercharge/redis-github-action@1.2.0
30
+ with:
31
+ redis-version: ${{ matrix.redis-version }}
30
32
  - uses: ruby/setup-ruby@v1
31
33
  with:
32
34
  ruby-version: ${{ matrix.ruby }}
data/README.md CHANGED
@@ -18,13 +18,13 @@
18
18
  <a href="/CODE_OF_CONDUCT.md">Code of Conduct</a>
19
19
  </p>
20
20
 
21
- A gem to measure production code usage, showing a counter for the number of times each line of code that is executed. Coverband allows easy configuration to collect and report on production code usage. It reports in the background via a thread or can be used as Rack middleware, or manually configured to meet any need.
21
+ A gem to measure production code usage, showing a counter for the number of times each line of code is executed. Coverband allows easy configuration to collect and report on production code usage. It reports in the background via a thread, can be used as Rack middleware, or can be manually configured to meet any need.
22
22
 
23
- **Note:** Coverband is not intended for test code coverage, for that we recommended using [SimpleCov](https://github.com/colszowka/simplecov).
23
+ **Note:** Coverband is not intended for test code coverage; for that we recommend using [SimpleCov](https://github.com/colszowka/simplecov).
24
24
 
25
25
  ## Key Features
26
26
 
27
- The primary goal of Coverband is giving deep insight into your production runtime usage of your application code, while having the least impact on performance possible.
27
+ The primary goal of Coverband is to give you deep insight into the production runtime usage of your application code, while having the least impact on performance possible.
28
28
 
29
29
  - Low performance overhead
30
30
  - Simple setup and configuration
@@ -55,7 +55,7 @@ gem 'coverband'
55
55
 
56
56
  ### No custom code or middleware required
57
57
 
58
- With older versions of coverband, projects would report to redis using rack or sidekiq middleware. After coverband 4.0, this should no longer be required and could cause performance issues. Reporting to redis is now automatically done within a background thread with no custom code needed.
58
+ With older versions of Coverband, projects would report to redis using rack or sidekiq middleware. After Coverband 4.0, this should no longer be required and could cause performance issues. Reporting to redis is now automatically done within a background thread with no custom code needed.
59
59
 
60
60
  See [changelog](https://github.com/danmayer/coverband/blob/master/changes.md).
61
61
 
@@ -65,7 +65,7 @@ The Railtie integration means you shouldn't need to do anything else other than
65
65
 
66
66
  ## Sinatra
67
67
 
68
- For the best coverage you want this loaded as early as possible. We recommend requiring cover band directly in the `config.ru`. Requiring coverband within an initializer could also work, but you may end up missing some boot up coverage. To start collection require Coverband as early as possible.
68
+ For the best coverage, you want this loaded as early as possible. We recommend requiring cover band directly in the `config.ru`. Requiring Coverband within an initializer could also work, but you may end up missing some boot up coverage. To start collection require Coverband as early as possible.
69
69
 
70
70
  ```ruby
71
71
  require 'coverband'
@@ -79,7 +79,7 @@ run ActionController::Dispatcher.new
79
79
 
80
80
  ![image](https://raw.github.com/danmayer/coverband/master/docs/coverband_web_ui.png)
81
81
 
82
- > The web index as available on the [Coverband Demo site](https://coverband-demo.herokuapp.com/coverage?#_Coverage)
82
+ > The web index is available on the [Coverband Demo site](https://coverband-demo.herokuapp.com/coverage?#_Coverage).
83
83
 
84
84
  - View overall coverage information
85
85
 
@@ -87,7 +87,7 @@ run ActionController::Dispatcher.new
87
87
 
88
88
  - View individual file details
89
89
 
90
- - Clear Coverage - disabled by default as it could be considered a dangerous operation in production. Enable with `config.web_enable_clear` or leave off and clear from [rake task](#clear-coverage).
90
+ - Clear Coverage - disabled by default as it could be considered a dangerous operation in production. Enable with `config.web_enable_clear` or leave off and clear from the [rake task](#clear-coverage).
91
91
 
92
92
  - Clear coverage report
93
93
 
@@ -139,10 +139,10 @@ If you want to run on an alternative port:
139
139
  COVERBAND_COVERAGE_PORT=8086 bundle exec rake coverband:coverage_server
140
140
  ```
141
141
 
142
- This is especially useful for projects that are api only and cannot support the mounted rack app. To get production coverage, point coverband at your production redis server and ensure to checkout the production version of your project code locally.
142
+ This is especially useful for projects that are api only and cannot support the mounted rack app. To get production coverage, point Coverband at your production redis server and ensure to checkout the production version of your project code locally.
143
143
 
144
144
  ```
145
- COVERBAND_REDIS_URL=redis://username:password:redis_production_server:2322 bundle exec rake coverband:coverage_server
145
+ COVERBAND_REDIS_URL=redis://username:password@redis_production_server:2322 bundle exec rake coverband:coverage_server
146
146
  ```
147
147
 
148
148
  # Coverband Demo
@@ -157,7 +157,7 @@ Take Coverband for a spin on the live Heroku deployed [Coverband Demo](https://c
157
157
 
158
158
  # Advanced Config
159
159
 
160
- If you need to configure coverband, this can be done by creating a `config/coverband.rb` file relative to your project root.
160
+ If you need to configure Coverband, this can be done by creating a `config/coverband.rb` file relative to your project root.
161
161
 
162
162
  - See [lib/coverband/configuration.rb](https://github.com/danmayer/coverband/blob/master/lib/coverband/configuration.rb) for all options
163
163
  - By default Coverband will try to store data to Redis \* Redis endpoint is looked for in this order: `ENV['COVERBAND_REDIS_URL']`, `ENV['REDIS_URL']`, or `localhost`
@@ -183,12 +183,15 @@ Coverband.configure do |config|
183
183
  # Does not track line-level usage, only indicates if an entire file
184
184
  # is used or not.
185
185
  config.track_views = true
186
+
187
+ # default false. Experimental support for routes usage tracking.
188
+ config.track_routes = true
186
189
  end
187
190
  ```
188
191
 
189
192
  ### Working with environment variables
190
193
 
191
- Do you use figaro, mc-settings, dotenv or something else to inject environment variables into your app? If so ensure you have that done BEFORE coverband is required.
194
+ Do you use figaro, mc-settings, dotenv or something else to inject environment variables into your app? If so ensure you have that done BEFORE Coverband is required.
192
195
 
193
196
  For example if you use dotenv, you need to do this, see https://github.com/bkeepers/dotenv#note-on-load-order
194
197
 
@@ -200,7 +203,7 @@ gem 'other-gem-that-requires-env-variables'
200
203
 
201
204
  ### Ignoring Files
202
205
 
203
- Sometimes you have files that are known to be valuable perhaps in other environments or something that is just run very infrequently. Opposed to having to mentally filter them out of the report, you can just have them ignored in the Coverband reporting by using `config.ignore` as shown below. Ignore takes a string but can also match with regex rules see how below ignores all rake tasks as an example.
206
+ Sometimes you have files that are known to be valuable, perhaps in other environments or something that is just run very infrequently. Opposed to having to mentally filter them out of the report, you can just have them ignored in the Coverband reporting by using `config.ignore` as shown below. Ignore takes a string but can also match with regex rules see how below ignores all rake tasks as an example.
204
207
 
205
208
  ```
206
209
  config.ignore += ['config/application.rb',
@@ -212,7 +215,7 @@ config.ignore += ['config/application.rb',
212
215
  'lib/tasks/.*']
213
216
  ```
214
217
 
215
- **Ignoring Custom Gem Locations:** Note, if you have your gems in a custom location under your app folder you likely want to add them to `config.ignore`. For example, if you have your gems not in a default ignored location of `app/vendor` but have them in `app/gems` you would need to add `gems/*` to your ignore list.
218
+ **Ignoring Custom Gem Locations:** Note, if you have your gems in a custom location under your app folder you likely want to add them to `config.ignore`. For example, if you have your gems not in the default ignored location of `app/vendor` but in `app/gems`, you would need to add `gems/*` to your ignore list.
216
219
 
217
220
  ### View Tracking
218
221
 
@@ -249,7 +252,7 @@ end
249
252
 
250
253
  ### Avoiding Cache Stampede
251
254
 
252
- If you have many servers and they all hit Redis at the same time you can see spikes in your Redis CPU, and memory. This is due to a concept called [cache stampede](https://en.wikipedia.org/wiki/Cache_stampede). It is better to spread out the reporting across your servers. A simple way to do this is to add a random wiggle on your background reporting. This configuration option allows a wiggle. The right amount of wiggle depends on the numbers of servers you have and how willing you are to have delays in your coverage reporting. I would recommend at least 1 second per server. Note, the default wiggle is set to 30 seconds.
255
+ If you have many servers and they all hit Redis at the same time you can see spikes in your Redis CPU, and memory. This is due to a concept called [cache stampede](https://en.wikipedia.org/wiki/Cache_stampede). It is better to spread out the reporting across your servers. A simple way to do this is to add a random wiggle on your background reporting. This configuration option allows a wiggle. The right amount of wiggle depends on the number of servers you have and how willing you are to have delays in your coverage reporting. I would recommend at least 1 second per server. Note, the default wiggle is set to 30 seconds.
253
256
 
254
257
  Add a wiggle (in seconds) to the background thread to avoid all your servers reporting at the same time:
255
258
 
@@ -257,16 +260,16 @@ Add a wiggle (in seconds) to the background thread to avoid all your servers rep
257
260
 
258
261
  ### Redis Hash Store
259
262
 
260
- Coverband on very high volume sites with many server processes reporting can have a race condition which can cause hit counts to be inaccurate. To resolve the race condition and reduce Ruby memory overhead we have introduced a new Redis storage option. This moves the some of the work from the Ruby processes to Redis. It is worth noting because of this, it has a larger demands on the Redis server. So adjust your Redis instance accordingly. To help reduce the extra redis load you can also change the background reporting frequency.
263
+ Coverband on very high volume sites with many server processes reporting can have a race condition which can cause hit counts to be inaccurate. To resolve the race condition and reduce Ruby memory overhead we have introduced a new Redis storage option. This moves the some of the work from the Ruby processes to Redis. It is worth noting because of this, it has larger demands on the Redis server. So adjust your Redis instance accordingly. To help reduce the extra redis load you can also change the background reporting frequency.
261
264
 
262
- - Use a dedicated coverband redis instance: `config.store = Coverband::Adapters::HashRedisStore.new(Redis.new(url: redis_url))`
265
+ - Use a dedicated Coverband redis instance: `config.store = Coverband::Adapters::HashRedisStore.new(Redis.new(url: redis_url))`
263
266
  - Adjust from default 30s reporting `config.background_reporting_sleep_seconds = 120`
264
267
 
265
268
  See more discussion [here](https://github.com/danmayer/coverband/issues/384).
266
269
 
267
270
  ### Clear Coverage
268
271
 
269
- Now that Coverband uses MD5 hashes there should be no reason to manually clear coverage unless one is testing, changing versions, possibly debugging Coverband itself.
272
+ Now that Coverband uses MD5 hashes there should be no reason to manually clear coverage unless one is testing, changing versions, or possibly debugging Coverband itself.
270
273
 
271
274
  `rake coverband:clear`
272
275
 
@@ -302,11 +305,11 @@ rake coverband:coverage # report runtime coverband code coverage
302
305
 
303
306
  ### Manually Starting Coverband
304
307
 
305
- Coverband starts on require of the the library which is usually done within the Gemfile. This can be disabled by setting the `COVERBAND_DISABLE_AUTO_START` environment variable. This environment variable can be useful to toggle coverband on and off in certain environments.
308
+ Coverband starts on require of the the library which is usually done within the Gemfile. This can be disabled by setting the `COVERBAND_DISABLE_AUTO_START` environment variable. This environment variable can be useful to toggle Coverband on and off in certain environments.
306
309
 
307
310
  **NOTE:** That any value set for `COVERBAND_DISABLE_AUTO_START` is considered true, it does not match the string content but only checks the presence of the ENV variable.
308
311
 
309
- In order to start coverband manually yourself when this flag is enabled, call `Coverband.configure` followed by `Coverband.start`.
312
+ In order to start Coverband manually when this flag is enabled, call `Coverband.configure` followed by `Coverband.start`.
310
313
 
311
314
  ```ruby
312
315
  Coverband.configure
@@ -315,7 +318,7 @@ Coverband.start
315
318
 
316
319
  ### Verbose Debug / Development Mode
317
320
 
318
- Note: To debug issues getting Coverband working. I recommend running in development mode, by turning verbose logging on `config.verbose = true` and passing in the Rails.logger `config.logger = Rails.logger` to the Coverband config. We respect the log level, and I would recommend log level info generally, but if you are investigating a problem Coverband logs additional data at the `debug` level. This makes it easy to follow in development mode. Be careful to not leave these on in production as they will affect performance.
321
+ Note: To debug issues getting Coverband working. I recommend running in development mode, by turning verbose logging on `config.verbose = true` and passing in the Rails.logger `config.logger = Rails.logger` to the Coverband config. We respect the log level, and I would recommend log level info generally, but if you are investigating a problem Coverband logs additional data at the `debug` level. This makes it easy to follow in development mode. Be careful not to leave these on in production as they will affect performance.
319
322
 
320
323
  ---
321
324
 
@@ -323,7 +326,7 @@ If you are trying to debug locally wondering what code is being run during a req
323
326
 
324
327
  ### Solving: stack level too deep errors
325
328
 
326
- If you start seeing SystemStackError: stack level too deep errors from background jobs after installing Coverband, this means there is another patch for ResqueWorker that conflicts with Coverband's patch in your application. To fix this, change coverband gem line in your Gemfile to the following:
329
+ If you start seeing SystemStackError: stack level too deep errors from background jobs after installing Coverband, this means there is another patch for ResqueWorker that conflicts with Coverband's patch in your application. To fix this, change Coverband gem line in your Gemfile to the following:
327
330
 
328
331
  ```
329
332
  gem 'coverband', require: ['alternative_coverband_patch', 'coverband']
@@ -335,11 +338,11 @@ If you currently have require: false, remove the 'coverband' string from the req
335
338
  gem 'coverband', require: ['alternative_coverband_patch']
336
339
  ```
337
340
 
338
- This conflict happens when a ruby method is patched twice, once using module prepend, and once using method aliasing. See this ruby issue for details. The fix is to apply all patches the same way. Coverband by default will apply its patch using prepend, but you can change that to method aliasing by adding require: ['alternative_coverband_patch'] to the gem line as shown above.
341
+ This conflict happens when a ruby method is patched twice, once using module prepend, and once using method aliasing. See this ruby issue for details. The fix is to apply all patches the same way. By default, Coverband will apply its patch using prepend, but you can change that to method aliasing by adding require: ['alternative_coverband_patch'] to the gem line as shown above.
339
342
 
340
343
  ### Redis Sizing Info
341
344
 
342
- A few folks have asked about what size of Redis is needed to run coverband. I have some of our largest services with hundreds of servers on cache.m3.medium with plenty of room to spare. I run most apps on the smallest AWS Redis instances available and bump up only if needed or if I am forced to be on a shared Redis instance, which I try to avoid. On Heroku, I have used it with most of the 3rd party and also been fine on the smallest Redis instances, if you have hundreds of dynos you would likely need to scale up. Also note there is a tradeoff one can make, `Coverband::Adapters::HashRedisStore` will use LUA on Redis and increase the Redis load, while being nicer to your app servers and avoid potential lost data during race conditions. While the `Coverband::Adapters::RedisStore` uses in app memory and merging and has lower load on Redis.
345
+ A few folks have asked about what size of Redis is needed to run Coverband. I have some of our largest services with hundreds of servers on cache.m3.medium with plenty of room to spare. I run most apps on the smallest AWS Redis instances available and bump up only if needed or if I am forced to be on a shared Redis instance, which I try to avoid. On Heroku, I have used it with most of the 3rd party and also been fine on the smallest Redis instances, if you have hundreds of dynos you would likely need to scale up. Also note there is a tradeoff one can make, `Coverband::Adapters::HashRedisStore` will use LUA on Redis and increase the Redis load, while being nicer to your app servers and avoid potential lost data during race conditions. While the `Coverband::Adapters::RedisStore` uses in app memory and merging and has lower load on Redis.
343
346
 
344
347
  # Newer Features
345
348
 
data/changes.md CHANGED
@@ -6,6 +6,11 @@ __NOTE: the current RCs include below, but this might turn into coverband 6.0__
6
6
  - refactor non Coverage.so based trackers
7
7
  - adds CSP report support (thanks @jwg2s)
8
8
  - add JSON reporter (thanks @mark-davenport-fountain)
9
+ - README improvements (thanks @jfvanderwalt)
10
+ - Fix on test mode configuration (thanks @rileyanderson)
11
+ - Text Improvements (thanks @etagwerker)
12
+ - readme update on configuration options (thanks @D-system)
13
+ - fix for rack mount of class vs instance (thanks @vs37559)
9
14
 
10
15
  ### Coverband 5.2.5
11
16
 
@@ -93,7 +93,7 @@ module Coverband
93
93
  end
94
94
 
95
95
  def file_hash(file)
96
- Coverband::Utils::FileHasher.hash(file)
96
+ Coverband::Utils::FileHasher.hash_file(file)
97
97
  end
98
98
 
99
99
  # TODO: modify to extend report inline?
@@ -272,7 +272,7 @@ module Coverband
272
272
  end
273
273
 
274
274
  def service_test_mode
275
- @service_dev_mode ||= ENV["COVERBAND_ENABLE_TEST_MODE"] || false
275
+ @service_test_mode ||= ENV["COVERBAND_ENABLE_TEST_MODE"] || false
276
276
  end
277
277
 
278
278
  def process_type
@@ -46,6 +46,11 @@ module Coverband
46
46
  Coverband.configuration.password == Base64.decode64(auth_header.split[1]).split(":")[1]
47
47
  end
48
48
 
49
+ def self.call(env)
50
+ @app ||= new
51
+ @app.call(env)
52
+ end
53
+
49
54
  def call(env)
50
55
  @request = Rack::Request.new(env)
51
56
 
@@ -5,7 +5,7 @@ module Coverband
5
5
  class FileHasher
6
6
  @cache = {}
7
7
 
8
- def self.hash(file, path_converter: AbsoluteFileConverter.instance)
8
+ def self.hash_file(file, path_converter: AbsoluteFileConverter.instance)
9
9
  @cache[file] ||= begin
10
10
  file = path_converter.convert(file)
11
11
  Digest::MD5.file(file).hexdigest if File.exist?(file)
@@ -5,5 +5,5 @@
5
5
  # use format "4.2.1.rc.1" ~> 4.2.1.rc to prerelease versions like v4.2.1.rc.2 and v4.2.1.rc.3
6
6
  ###
7
7
  module Coverband
8
- VERSION = "5.2.6.rc.4"
8
+ VERSION = "5.2.6.rc.5"
9
9
  end
@@ -20,7 +20,7 @@ class RouterTrackerTest < Minitest::Test
20
20
  test "init correctly" do
21
21
  Coverband::Collectors::RouteTracker.expects(:supported_version?).returns(true)
22
22
  tracker = Coverband::Collectors::RouteTracker.new(store: fake_store, roots: "dir")
23
- assert_equal nil, tracker.target.first
23
+ assert_nil tracker.target.first
24
24
  assert !tracker.store.nil?
25
25
  assert_equal [], tracker.target
26
26
  assert_equal [], tracker.logged_keys
@@ -25,7 +25,7 @@ class TranslationTrackerTest < Minitest::Test
25
25
  test "init correctly" do
26
26
  Coverband::Collectors::TranslationTracker.expects(:supported_version?).returns(true)
27
27
  tracker = Coverband::Collectors::TranslationTracker.new(store: fake_store, roots: "dir")
28
- assert_equal nil, tracker.target.first
28
+ assert_nil tracker.target.first
29
29
  assert !tracker.store.nil?
30
30
  assert_equal [], tracker.target
31
31
  assert_equal [], tracker.logged_keys
@@ -6,17 +6,17 @@ module Coverband
6
6
  module Utils
7
7
  class FileHasherTest < Minitest::Test
8
8
  def test_hash_same_file
9
- refute_nil FileHasher.hash("./test/dog.rb")
10
- assert_equal(FileHasher.hash("./test/dog.rb"), FileHasher.hash("./test/dog.rb"))
11
- assert_equal(FileHasher.hash(File.expand_path("./test/dog.rb")), FileHasher.hash("./test/dog.rb"))
9
+ refute_nil FileHasher.hash_file("./test/dog.rb")
10
+ assert_equal(FileHasher.hash_file("./test/dog.rb"), FileHasher.hash_file("./test/dog.rb"))
11
+ assert_equal(FileHasher.hash_file(File.expand_path("./test/dog.rb")), FileHasher.hash_file("./test/dog.rb"))
12
12
  end
13
13
 
14
14
  def test_hash_different_files
15
- refute_equal(FileHasher.hash("./test/dog.rb"), FileHasher.hash("./lib/coverband.rb"))
15
+ refute_equal(FileHasher.hash_file("./test/dog.rb"), FileHasher.hash_file("./lib/coverband.rb"))
16
16
  end
17
17
 
18
18
  def test_hash_file_not_exists
19
- assert_nil(FileHasher.hash("./made_up_file.py"))
19
+ assert_nil(FileHasher.hash_file("./made_up_file.py"))
20
20
  end
21
21
  end
22
22
  end
data/test/test_helper.rb CHANGED
@@ -110,7 +110,7 @@ def test(name, &block)
110
110
  end
111
111
 
112
112
  def mock_file_hash(hash: "abcd")
113
- Coverband::Utils::FileHasher.expects(:hash).at_least_once.returns(hash)
113
+ Coverband::Utils::FileHasher.expects(:hash_file).at_least_once.returns(hash)
114
114
  end
115
115
 
116
116
  def example_line
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coverband
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.6.rc.4
4
+ version: 5.2.6.rc.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Mayer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-03-05 00:00:00.000000000 Z
12
+ date: 2023-07-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: benchmark-ips