coverband 3.0.0.alpha2 → 3.0.0

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: d163fe104d7966396a057777b51ce78a908c51875fbbc79923499c84c839005d
4
- data.tar.gz: 6fe8e31cfbb5045aca8082ebd741bcf0c67fc7acc6b0e62baa58ebb5671638bb
3
+ metadata.gz: c2b0fe96cfa4c9cfd336166b498bdbbba7d297265b5a7883d423b1b19d4738ad
4
+ data.tar.gz: 31b7d38ea823730d3855fa2203da308adc862c2c8320b756c10671873f6b016e
5
5
  SHA512:
6
- metadata.gz: '09c1da6a595dd6c0f69925f355a78e1d7373c0333c85cc34e1461f220d1eda4473031f874bb71ec2ed557a05fc506c6884c069732e746260059d864c5e7ff5ed'
7
- data.tar.gz: a3afd7d3c8706dff2150fc503805fcdf5c7b7cba7f98d2a104175fae6af41b0d05e9c446998ceda3104a4f1f5e6dbf4432d114f1c9f83d93f9809b2cf059afad
6
+ metadata.gz: 1ec633dcb00294b67974c083853cdb28148ce93fc68783aaab87fe2c343a00b880c3f5b653573cca147ce3eb2e0a1aa2933ed3629d157284fc34873838971918
7
+ data.tar.gz: 5f58cce89174ca835edcbc53ce9a30a53facc276ad7ae290510380c133e640abe899087132ceff408c959fa4be5f119e8d4bb2c31b3da2b2e66b72dfae62f931
data/README.md CHANGED
@@ -110,23 +110,15 @@ You need to configure cover band you can either do that passing in all configura
110
110
  #config/coverband.rb
111
111
  Coverband.configure do |config|
112
112
  config.root = Dir.pwd
113
- config.collector = 'coverage'
114
- config.redis = Redis.new(url: ENV['REDIS_URL']) if defined? Redis
115
- # TODO NOTE THIS IS A ISSUE IN THE 2.0 release you set something like redis and the store
116
- # I need to look a bit more at this but got one bug report quickly after release
117
- # (even though test builds didnt need)
118
- config.store = Redis.new(url: ENV['REDIS_URL']) if defined? Redis
113
+ config.store = Coverband::Adapters::RedisStore.new(Redis.new(url: ENV['REDIS_URL'])) if defined? Redis
119
114
  config.ignore = %w[vendor .erb$ .slim$]
120
115
  # add paths that you deploy to that might be different than your local dev root path
121
116
  config.root_paths = []
122
117
 
123
- # reporting frequency
118
+ # reporting frequency, how often coverage data is sent to the store
124
119
  # if you are debugging changes to coverband I recommend setting to 100.0
125
- # otherwise it is find to report slowly over time with less performance impact
126
- # with the Coverage collector coverage is ALWAYS captured this is just how frequently
127
- # it is reported to your back end store.
128
- config.percentage = Rails.env.production? ? 1.0 : 100.0
129
- config.logger = Rails.logger
120
+ config.reporting_frequency = Rails.env.production? ? 1.0 : 100.0
121
+ config.logger = Rails.logger
130
122
 
131
123
  # config options false, true, or 'debug'. Always use false in production
132
124
  # true and debug can give helpful and interesting code usage information
@@ -143,7 +135,7 @@ Either add the below to your `Rakefile` or to a file included in your Rakefile s
143
135
  ```ruby
144
136
  require 'coverband'
145
137
  Coverband.configure
146
- require 'coverband/tasks'
138
+ require 'coverband/utils/tasks'
147
139
  ```
148
140
  This should give you access to a number of Coverband tasks
149
141
 
@@ -179,10 +171,8 @@ module MyApplication
179
171
  # if one uses before_eager_load as I did previously
180
172
  # any files that get loaded as part of railties will have no coverage
181
173
  config.before_initialize do
182
- require 'coverage'
183
- Coverband::Collectors::Coverage.instance.start
174
+ Coverband.start
184
175
  end
185
-
186
176
  end
187
177
  end
188
178
  ```
@@ -208,9 +198,9 @@ run ActionController::Dispatcher.new
208
198
  * run app and hit a controller (hit at least +1 time over your `config.startup_delay` setting default is 0)
209
199
  * run `rake coverband:coverage` and you should see coverage increasing for the endpoints you hit.
210
200
 
211
- ## Installation Script
201
+ ## Installation Session
212
202
 
213
- These are the steps show in setting up coverband in the gif in the readme.
203
+ These are the steps taken to install and configure Coverband
214
204
 
215
205
  ```
216
206
  rails new coverage_example
@@ -219,7 +209,7 @@ atom .
219
209
 
220
210
  # open Gemfile, add lines
221
211
  gem 'redis'
222
- gem 'coverband', '>= 2.0.0.alpha1', require: false
212
+ gem 'coverband', '>= 3.0.0.alpha2', require: false
223
213
 
224
214
  bundle install
225
215
 
@@ -234,7 +224,7 @@ rake db:migrate
234
224
  # open Rakefile, add lines
235
225
  require 'coverband'
236
226
  Coverband.configure
237
- require 'coverband/tasks'
227
+ require 'coverband/utils/tasks'
238
228
 
239
229
  # verify rake
240
230
  rake -T coverband
@@ -260,7 +250,7 @@ rake coverband:coverage
260
250
 
261
251
  ### Example apps
262
252
 
263
- - [Rails 5.1.x App](https://github.com/danmayer/coverage_rails_benchmark)
253
+ - [Rails 5.2.x App](https://github.com/danmayer/coverage_demo)
264
254
  - [Sinatra app](https://github.com/danmayer/churn-site)
265
255
  - [Non Rack Ruby app](https://github.com/danmayer/coverband_examples)
266
256
 
@@ -280,7 +270,7 @@ If your code has changed and your coverage line data doesn't seem to match run t
280
270
 
281
271
  ### Automated Clearing Line Coverage Data
282
272
 
283
- After a deploy where code has changed significantly.
273
+ After a deploy where code has changed significantly. This is to avoid coverage drift
284
274
 
285
275
  The line numbers previously recorded in Redis may no longer match the current state of the files.
286
276
  If being slightly out of sync isn't as important as gathering data over a long period,
@@ -305,42 +295,43 @@ For example if you had a base Resque class, you could use the `before_perform` a
305
295
  ```ruby
306
296
  require 'coverband'
307
297
  Coverband.configure
308
-
309
- def before_perform(*args)
310
- if (rand * 100.0) <= Coverband.configuration.percentage
311
- @recording_samples = true
312
- Coverband::Base.instance.start
313
- else
314
- @recording_samples = false
315
- end
316
- end
298
+ Coverband.start
317
299
 
318
300
  def after_perform(*args)
319
301
  if @recording_samples
320
- Coverband::Base.instance.stop
321
- Coverband::Base.instance.save
302
+ Coverband::Collectors::Coverage.instance.report_coverage
322
303
  end
323
304
  end
324
305
  ```
325
306
 
307
+ or sidekiq middleware:
308
+
309
+ ```ruby
310
+ # capture code usage in background jobs
311
+ class CoverbandMiddleware
312
+ def call(_worker, _msg, _queue)
313
+ Coverband.start
314
+ yield
315
+ ensure
316
+ Coverband::Collectors::Coverage.instance.report_coverage
317
+ end
318
+ end
319
+
320
+ ...
321
+ chain.add Sidekiq::CoverbandMiddleware
322
+ ```
323
+
326
324
  In general you can run Coverband anywhere by using the lines below. This can be useful to wrap all cron jobs, background jobs, or other code run outside of web requests. I recommend trying to run both background and cron jobs at 100% coverage as the performance impact is less important and often old code hides around those jobs.
327
325
 
328
326
 
329
327
  ```ruby
330
328
  require "coverband"
331
329
  Coverband.configure
330
+ Coverband.start
332
331
 
333
- coverband = Coverband::Base.instance
332
+ # do whatever
333
+ Coverband::Collectors::Coverage.instance.report_coverage
334
334
 
335
- #manual
336
- coverband.start
337
- coverband.stop
338
- coverband.save
339
-
340
- #sampling
341
- coverband.sample {
342
- #code to sample coverband
343
- }
344
335
  ```
345
336
 
346
337
  ### Manual Configuration (for cron jobs / Raketasks)
@@ -352,7 +343,7 @@ He extended the Coverband Rake tasks by adding `lib/tasks/coverband.rake` with s
352
343
  ```
353
344
  require 'coverband'
354
345
  Coverband.configure
355
- require 'coverband/tasks'
346
+ require 'coverband/utils/tasks'
356
347
 
357
348
  # Wrap all Rake tasks with Coverband
358
349
  current_tasks = Rake.application.top_level_tasks
@@ -363,12 +354,11 @@ end
363
354
 
364
355
  namespace :coverband do
365
356
  task :start do
366
- Coverband::Base.instance.start
357
+ Coverband.start
367
358
  end
368
359
 
369
360
  task :stop_and_save do
370
- Coverband::Base.instance.stop
371
- Coverband::Base.instance.save
361
+ Coverband::Collectors::Coverage.instance.report_coverage
372
362
  end
373
363
  end
374
364
  ```
@@ -381,7 +371,7 @@ require 'rails'
381
371
  # Capture code coverage during our cron jobs
382
372
  class CoverageRunner < ::Rails::Railtie
383
373
  runner do
384
- Coverband::Collectors::Coverage.instance.start
374
+ Coverband.start
385
375
  at_exit do
386
376
  Coverband::Collectors::Coverage.instance.report_coverage
387
377
  end
@@ -444,22 +434,6 @@ If you are trying to debug locally wondering what code is being run during a req
444
434
  ...
445
435
  [517, 1617], [516, 38577]]
446
436
 
447
- ### Merge coverage data over time
448
-
449
- If you are clearing data on every deploy. You might want to write the data out to a file first. Then you could merge the data into the final results later.
450
-
451
- __note:__ I don't actually recommend clearing on every deploy, but only following significant releases where many line numbers would be off. If you follow that approach you don't need to merge data over time as this example shows how.
452
-
453
- ```ruby
454
- data = JSON.generate Coverband::Reporter.get_current_scov_data
455
- File.write("blah.json", data)
456
- # Then later on, pass it in to the html reporter:
457
- data = JSON.parse(File.read("blah.json"))
458
- Coverband::Reporter.report :additional_scov_data => [data]
459
- ```
460
-
461
- You can also pass a `:additional_scov_data => [data]` option to `Coverband::Reporter.get_current_scov_data` to write out merged data.
462
-
463
437
  ### Writing Coverband Results to S3
464
438
 
465
439
  If you add some additional Coverband configuration your coverage html report will be written directly to S3, update `config/coverband.rb` like below.
@@ -574,101 +548,6 @@ What is the coverage data in Redis?
574
548
 
575
549
  `Coverband.configuration.store.coverage`
576
550
 
577
- ### Internal Formats
578
-
579
- If you are doing development having some documented examples of various internal data formats can be helpfu....
580
-
581
- The format we get from TracePoint, Coverage, Internal Representations, and Used by SimpleCov for reporting have traditionally varied a bit. We can document the differences in formats here.
582
-
583
- #### Coverage
584
-
585
- ```
586
- >> require 'coverage'
587
- => true
588
- >> Coverage.start
589
- => nil
590
- >> require './test/unit/dog.rb'
591
- => true
592
- >> 5.times { Dog.new.bark }
593
- => 5
594
- >> Coverage.peek_result
595
- => {"/Users/danmayer/projects/coverband/test/unit/dog.rb"=>[nil, nil, 1, 1, 5, nil, nil]}
596
- ```
597
-
598
- #### SimpleCov
599
-
600
- The same format, but relative paths.
601
-
602
- ```
603
- {"test/unit/dog.rb"=>[1, 2, nil, nil, nil, nil, nil]}
604
- ```
605
-
606
- #### Redis Store
607
-
608
- We store relative path in Redis, the Redis hash stores line numbers -> count (as strings).
609
-
610
- ```
611
- # Array
612
- ["test/unit/dog.rb"]
613
-
614
- # Hash
615
- {"test/unit/dog.rb"=>{"1"=>"1", "2"=>"2"}}
616
- ```
617
-
618
- #### File Store
619
-
620
- Similar format to redis store, but array with integer values
621
-
622
- ```
623
- {"test/unit/dog.rb"=>{"1"=>1, "2"=>2}}
624
- ```
625
-
626
- # Future Coverband
627
-
628
- ### Alternative Redis formats
629
-
630
- * Look at alternative storage formats for Redis
631
- * [redis bitmaps](http://blog.getspool.com/2011/11/29/fast-easy-realtime-metrics-using-redis-bitmaps/)
632
- * [redis bitfield](https://stackoverflow.com/questions/47100606/optimal-way-to-store-array-of-integers-in-redis-database)
633
-
634
- ### Todo
635
-
636
- * add articles / podcasts like prontos readme https://github.com/prontolabs/pronto
637
- * graphite adapters (it would allow passing in date ranges on usage)
638
- * perf test for array vs hash
639
- * redis pipeline around hash (or batch get then push)
640
- * move to SimpleCov console out, or make similar console tabular output
641
- * Improve network performance by logging to files that purge later (like NR) (far more time lost in TracePoint than sending files, hence not a high priority, but would be cool)
642
- * Add support for [zadd](http://redis.io/topics/data-types-intro) so one could determine single call versus multiple calls on a line, letting us determine the most executed code in production.
643
- * Possibly add ability to record code run for a given route
644
- * integrate recording with deploy tag or deploy timestamp
645
- * diff code usage across deployed versions
646
- * Improve client code api, around manual usage of sampling (like event usage)
647
- * ability to change the Coverband config at runtime by changing the config pushed to the Redis hash. In memory cache around the changes to only make that call periodically.
648
- * Opposed to just showing code usage on a route allow 'tagging' events which would record line coverage for that tag (this would allow tagging all code that modified an ActiveRecord model for example
649
- * support runner, active job, etc without needed extra config (improved railtie integration)
650
-
651
- # Resources
652
-
653
- These notes of kind of for myself, but if anyone is seriously interested in contributing to the project, these resources might be helpful. I learned a lot looking at various existing projects and open source code.
654
-
655
- ##### Ruby Std-lib Coverage
656
-
657
- * [Ruby Coverage docs](https://ruby-doc.org/stdlib-2.5.0/libdoc/coverage/rdoc/Coverage.html)
658
-
659
- ##### Other
660
-
661
- * [erb code coverage](http://stackoverflow.com/questions/13030909/how-to-test-code-coverage-for-rails-erb-templates)
662
- * [more erb code coverage](https://github.com/colszowka/simplecov/issues/38)
663
- * [erb syntax](http://stackoverflow.com/questions/7996695/rails-erb-syntax) parse out and mark lines as important
664
- * [ruby 2 tracer](https://github.com/brightbox/deb-ruby2.0/blob/master/lib/tracer.rb)
665
- * [coveralls hosted code coverage tracking](https://coveralls.io/docs/ruby) currently for test coverage but might be a good partner for production coverage
666
- * [simplecov usage example](http://www.cakesolutions.net/teamblogs/brief-introduction-to-rspec-and-simplecov-for-ruby) copy some of the syntax sugar setup for cover band
667
- * [Jruby coverage bug](https://github.com/jruby/jruby/issues/1196)
668
- * [learn from oboe ruby code](https://github.com/appneta/oboe-ruby#writing-custom-instrumentation)
669
- * [learn from stackprof](https://github.com/tmm1/stackprof#readme)
670
- * I believe there are possible ways to get even better data using the new [Ruby2 TracePoint API](http://www.ruby-doc.org/core/TracePoint.html)
671
-
672
551
  # License
673
552
 
674
553
  This is a MIT License project...
data/changes.md CHANGED
@@ -1,6 +1,14 @@
1
1
  # Future Roadmap
2
2
 
3
- ### Coverband 4.0
3
+ ### Research Alternative Redis formats
4
+
5
+ * Look at alternative storage formats for Redis
6
+ * [redis bitmaps](http://blog.getspool.com/2011/11/29/fast-easy-realtime-metrics-using-redis-bitmaps/)
7
+ * [redis bitfield](https://stackoverflow.com/questions/47100606/optimal-way-to-store-array-of-integers-in-redis-database)
8
+ * Add support for [zadd](http://redis.io/topics/data-types-intro) so one could determine single call versus multiple calls on a line, letting us determine the most executed code in production.
9
+
10
+
11
+ ### Coverband 4.X
4
12
 
5
13
  Will be the fully modern release that drops maintenance legacy support in favor of increased performance, ease of use, and maintainability.
6
14
 
@@ -17,7 +25,7 @@ Will be the fully modern release that drops maintenance legacy support in favor
17
25
  - add coverage timerange support
18
26
  - Drop Simplecov dependency
19
27
 
20
- ### Coverband 3.0.X
28
+ ### Coverband 3.X
21
29
 
22
30
  Will be a stable and fast release that drops maintenance legacy support in favor of increased performance and maintainability.
23
31
 
@@ -28,14 +36,30 @@ Will be a stable and fast release that drops maintenance legacy support in favor
28
36
  - reduced configuration options
29
37
  - improved web reporting
30
38
  - no longer relying directly on HTML in S3 but dynamically generated from any adapter
39
+ - lists current config options
40
+ - eventually allow updating remote config
41
+ - full theming
42
+ - list redis data dump for debugging
31
43
  - additional adapters: Memcache, S3, and ActiveRecord
32
44
  - add additional config / protection options on Coverage clear
33
45
  - add memory benchmarks showing memory overhead of coverband
46
+ - add articles / podcasts like prontos readme https://github.com/prontolabs/pronto
34
47
 
35
48
  ### Coverband_jam_session
36
49
 
37
- This is a possible gem to host experimental or more complex features, which would require tuning, configuration, and performance trade offs
50
+ This is a possible gem to host experimental or more complex features, which would require tuning, configuration, and performance trade offs. If something is really valuable it could be promoted into the main line.
38
51
 
52
+ Feature Ideas:
53
+
54
+ - statsd adapters (it would allow passing in date ranges on usage)
55
+ - move to SimpleCov console out, or make similar console tabular output
56
+ - Possibly add ability to record code run for a given route
57
+ - integrate recording with deploy tag or deploy timestamp
58
+ - diff code usage across deployed versions
59
+ - what methods increased usage or decreased
60
+ - Improve client code api, around manual usage of sampling (like event usage)
61
+ - ability to change the Coverband config at runtime by changing the config pushed to the Redis hash. In memory cache around the changes to only make that call periodically.
62
+ - Opposed to just showing code usage on a route allow 'tagging' events which would record line coverage for that tag (this would allow tagging all code that modified an ActiveRecord model for example
39
63
  - additional adapters (tracepoint, ruby-profiler, etc)
40
64
  - code route tracing (entry point to all code executed for example /some_path -> code coverage of that path)
41
65
  - tagging of reported Coverage
@@ -44,17 +68,25 @@ This is a possible gem to host experimental or more complex features, which woul
44
68
 
45
69
  # Alpha
46
70
 
71
+ ### Coverband 3.0.1
72
+
73
+ * ??? ;)
74
+
75
+
76
+ # Released
77
+
47
78
  ### Coverband 3.0.0
48
79
 
49
80
  * drops Tracepoint
50
81
  * drops Ruby <= 2.3.0
51
- * drops JSON gem
52
- * rewrites redis store, for 60X perf
82
+ * drops JSON Gem dependency
53
83
  * drops various other features not needed without Tracepoint
54
- * drops memory cache
84
+ * memory cache, sampling, restricted to app folders, etc
55
85
  * standardizes on Coverage array format vs sparse hash
86
+ * rewrites store methods, for 60X perf
87
+ * implemented for Redis and File store
88
+ * improved mountable web interface
56
89
 
57
- # Released
58
90
 
59
91
  # 2.0.3
60
92
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Coverband
4
- VERSION = '3.0.0.alpha2'
4
+ VERSION = '3.0.0'
5
5
  end
@@ -199,7 +199,16 @@ namespace :benchmarks do
199
199
  task :coverband_demo do
200
200
  # for local testing
201
201
  # puts `ab -n 200 -c 5 "http://127.0.0.1:3000/posts"`
202
- puts `ab -n 500 -c 5 "https://coverband-demo.herokuapp.com/posts"`
202
+ puts `ab -n 2000 -c 10 "https://coverband-demo.herokuapp.com/posts"`
203
+ end
204
+
205
+ desc 'benchmarks external requests to coverband_demo site'
206
+ task :coverband_demo_graph do
207
+ # for local testing
208
+ # puts `ab -n 200 -c 5 "http://127.0.0.1:3000/posts"`
209
+ puts `ab -n 2000 -c 10 -g tmp/ab_brench.tsv "https://coverband-demo.herokuapp.com/posts"`
210
+ puts `test/benchmarks/graph_bench.sh`
211
+ `open tmp/timeseries.jpg`
203
212
  end
204
213
 
205
214
  desc 'compare Coverband Ruby Coverage with Filestore with normal Ruby'
@@ -0,0 +1,30 @@
1
+ #!/usr/local/bin//gnuplot
2
+
3
+ # from http://www.bradlanders.com/2013/04/15/apache-bench-and-gnuplot-youre-probably-doing-it-wrong/
4
+ # Let's output to a jpeg file
5
+ set terminal jpeg size 900,500
6
+ # This sets the aspect ratio of the graph
7
+ set size 1, 1
8
+ # The file we'll write to
9
+ set output "tmp/timeseries.jpg"
10
+ # The graph title
11
+ set title "Benchmark testing"
12
+ # Where to place the legend/key
13
+ set key left top
14
+ # Draw gridlines oriented on the y axis
15
+ set grid y
16
+ # Specify that the x-series data is time data
17
+ set xdata time
18
+ # Specify the *input* format of the time data
19
+ set timefmt "%s"
20
+ # Specify the *output* format for the x-axis tick labels
21
+ set format x "%S"
22
+ # Label the x-axis
23
+ set xlabel 'seconds'
24
+ # Label the y-axis
25
+ set ylabel "response time (ms)"
26
+ # Tell gnuplot to use tabs as the delimiter instead of spaces (default)
27
+ set datafile separator '\t'
28
+ # Plot the data
29
+ plot "tmp/ab_brench.tsv" every ::2 using 2:5 title 'response time' with points
30
+ exit
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coverband
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.alpha2
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Mayer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-03 00:00:00.000000000 Z
11
+ date: 2018-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -214,6 +214,7 @@ files:
214
214
  - test/benchmarks/.gitignore
215
215
  - test/benchmarks/benchmark.rake
216
216
  - test/benchmarks/dog.rb
217
+ - test/benchmarks/graph_bench.sh
217
218
  - test/fake_app/basic_rack.rb
218
219
  - test/test_helper.rb
219
220
  - test/unit/adapters_base_test.rb
@@ -244,9 +245,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
244
245
  version: '0'
245
246
  required_rubygems_version: !ruby/object:Gem::Requirement
246
247
  requirements:
247
- - - ">"
248
+ - - ">="
248
249
  - !ruby/object:Gem::Version
249
- version: 1.3.1
250
+ version: '0'
250
251
  requirements: []
251
252
  rubyforge_project:
252
253
  rubygems_version: 2.7.3
@@ -257,6 +258,7 @@ test_files:
257
258
  - test/benchmarks/.gitignore
258
259
  - test/benchmarks/benchmark.rake
259
260
  - test/benchmarks/dog.rb
261
+ - test/benchmarks/graph_bench.sh
260
262
  - test/fake_app/basic_rack.rb
261
263
  - test/test_helper.rb
262
264
  - test/unit/adapters_base_test.rb