coverband-service-client 0.0.12.rc.2 → 0.0.14

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: ecee5d46bea965ae3675532f956d99ad2617f1892dcf59cd302f080faf03acc1
4
- data.tar.gz: 9bde9ec5901ed84880692ded71d617d94e887cfb818e86bb4c3f7607f4f64f9e
3
+ metadata.gz: aba2da1ff17c90fec8adaf834a7aff1e1cb75b5d82d1f654e9273fe49aece61c
4
+ data.tar.gz: ebf5a93f18a2509ef806314e39afda8f677876f6b17f02a778728029f298540e
5
5
  SHA512:
6
- metadata.gz: 77e703011dcb88cdcb8e7fb107aca73c13419b4e1ed9bf72a47d67c7cb6847e80c2b477d7866ce030264578ee426e889b7789b46d5bc7b8e42b841b68ada7787
7
- data.tar.gz: a7277f954c3b6c1b418ab2230a41652e71788ddc68a6c8183325931f023b8b9bc52fcb56be51e4a1eb31a67ae3bc23509a197dfafa41a5b02f2e32b58f59a376
6
+ metadata.gz: c06a890c70829d0f4ea150564445f8c2d3848e59fb416020cf59209d9ff30b3427f448fda64664859cdcc7e0b745c259d22ea7048dbd50e1211fc42821e706ed
7
+ data.tar.gz: 57aa22e7ad96532b74823821b8ee23f7f4f89ca6bc790797987d5f5686b74eaf9676a97547136fd204d69be3eb6552da8235ec91e1a6dbb98f05584be2db5d8c
@@ -1,17 +1,17 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- coverband-service-client (0.0.12.rc.2)
5
- coverband (~> 4.2.4)
4
+ coverband-service-client (0.0.14)
5
+ coverband (~> 5.0.0.rc.3)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- coverband (4.2.5)
10
+ coverband (5.0.0.rc.3)
11
11
  redis
12
12
  minitest (5.14.0)
13
13
  rake (13.0.1)
14
- redis (4.1.4)
14
+ redis (4.2.1)
15
15
 
16
16
  PLATFORMS
17
17
  ruby
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+
5
+ ENV['COVERBAND_ENABLE_DEV_MODE'] = 'true'
6
+ ENV['COVERBAND_ENABLE_TEST_MODE'] = 'true'
7
+ ENV['PROCESS_TYPE'] = 'debug'
8
+ ENV['COVERBAND_REPORT_PERIOD'] = '30'
9
+ ENV['COVERBAND_API_KEY'] ||= 'set this'
10
+ ENV['COVERBAND_STATS_KEY'] ||='set this'
11
+
12
+ require "pry-byebug";
13
+ require "dogapi";
14
+ require "net/http/persistent";
15
+ # require "httplog";
16
+ require 'benchmark'
17
+
18
+ require_relative "../lib/coverband-service-client"
19
+
20
+ # HttpLog.configure do |config|
21
+ # config.url_SAFElist_pattern = /coverband/
22
+ # end
23
+
24
+ data = {
25
+ 'app/helpers/posts_helper.rb' => [1, nil]
26
+ }
27
+
28
+ collector = Coverband::Collectors::Coverage.instance
29
+ store = Coverband.configuration.store
30
+
31
+ # What is the recommended timeout against the target, from the lib
32
+ # puts store.recommended_timeout
33
+
34
+ Benchmark.bmbm do |x|
35
+ x.report("connection") do
36
+ 30.times do
37
+ store.save_report(data)
38
+ end
39
+ end
40
+ end
41
+
42
+ puts "done"
@@ -28,6 +28,14 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_development_dependency "bundler", "~> 2.0"
30
30
  spec.add_development_dependency "rake", "~> 13.0"
31
+
32
+ # For benchmarking stats
33
+ # spec.add_development_dependency "pry-byebug"
34
+ # spec.add_development_dependency "dogapi"
35
+ # spec.add_development_dependency "httplog"
36
+ # # to benchmark persistent connections
37
+ # spec.add_development_dependency "net-http-persistent"
38
+
31
39
  spec.add_development_dependency "minitest", "~> 5.0"
32
- spec.add_runtime_dependency "coverband", "~> 4.2.4"
40
+ spec.add_runtime_dependency "coverband", "~> 5.0.0.rc.3"
33
41
  end
@@ -15,6 +15,7 @@ module Coverband
15
15
  COVERBAND_ENABLE_TEST_MODE = ENV['COVERBAND_ENABLE_TEST_MODE'] || false
16
16
  COVERBAND_PROCESS_TYPE = ENV['PROCESS_TYPE'] || 'unknown'
17
17
  COVERBAND_REPORT_PERIOD = (ENV['COVERBAND_REPORT_PERIOD'] || 600).to_i
18
+ COVERBAND_PERSISTENT_HTTP = ENV['COVERBAND_PERSISTENT_HTTP'] || false
18
19
 
19
20
  def self.service_disabled_dev_test_env?
20
21
  (COVERBAND_ENV == 'test' && !COVERBAND_ENABLE_TEST_MODE) ||
@@ -48,6 +49,7 @@ module Coverband
48
49
  @hostname = opts.fetch(:hostname) { ENV["DYNO"] || Socket.gethostname.force_encoding('utf-8').encode }
49
50
  @hostname = @hostname.gsub("'",'').gsub("’",'')
50
51
  @runtime_env = opts.fetch(:runtime_env) { COVERBAND_ENV }
52
+ @failed_coverage_reports = []
51
53
  initialize_stats
52
54
  end
53
55
 
@@ -56,6 +58,7 @@ module Coverband
56
58
  return unless defined?(Dogapi::Client)
57
59
 
58
60
  @stats = Dogapi::Client.new(ENV['COVERBAND_STATS_KEY'])
61
+ @app_name = defined?(Rails) ? Rails.application.class.module_parent.to_s : "unknown"
59
62
  end
60
63
 
61
64
  def report_timing(timing)
@@ -131,10 +134,11 @@ module Coverband
131
134
  }
132
135
  }
133
136
 
134
- starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)
137
+ starting = Process.clock_gettime(Process::CLOCK_MONOTONIC) if @stats
135
138
  save_coverage(full_package)
136
- ending = Process.clock_gettime(Process::CLOCK_MONOTONIC)
137
- report_timing((ending - starting))
139
+ ending = Process.clock_gettime(Process::CLOCK_MONOTONIC) if @stats
140
+ report_timing((ending - starting)) if @stats
141
+ retry_failed_reports
138
142
  end&.join
139
143
  end
140
144
 
@@ -144,20 +148,48 @@ module Coverband
144
148
 
145
149
  private
146
150
 
151
+ def retry_failed_reports
152
+ retries = []
153
+ @failed_coverage_reports.any? do
154
+ report_body = @failed_coverage_reports.pop
155
+ send_report_body(report_body)
156
+ rescue StandardError
157
+ retries << report_body
158
+ end
159
+ retries.each do |report_body|
160
+ add_retry_message(report_body)
161
+ end
162
+ end
163
+
164
+ def add_retry_message(report_body)
165
+ if @failed_coverage_reports.length > 5
166
+ logger&.info "Coverband: The errored reporting queue has reached 5. Subsequent reports will not be transmitted"
167
+ else
168
+ @failed_coverage_reports << report_body
169
+ end
170
+ end
171
+
147
172
  def save_coverage(data)
148
173
  if api_key.nil?
149
174
  puts "Coverband: Error: no Coverband API key was found!"
150
175
  return
151
176
  end
152
177
 
178
+ coverage_body = { remote_uuid: SecureRandom.uuid, data: data }.to_json
179
+ send_report_body(coverage_body)
180
+ rescue StandardError => e
181
+ add_retry_message(coverage_body)
182
+ logger&.info "Coverband: Error while saving coverage #{e}" if Coverband.configuration.verbose || COVERBAND_ENABLE_DEV_MODE
183
+ end
184
+
185
+ def send_report_body(coverage_body)
153
186
  uri = URI("#{coverband_url}/api/collector")
154
- req = Net::HTTP::Post.new(uri,
187
+ req = ::Net::HTTP::Post.new(uri,
155
188
  'Content-Type' => 'application/json',
156
189
  'Coverband-Token' => api_key)
157
- req.body = { remote_uuid: SecureRandom.uuid, data: data }.to_json
158
-
190
+ req.body = coverage_body
159
191
  logger&.info "Coverband: saving (#{uri}) #{req.body}" if Coverband.configuration.verbose
160
- res = Net::HTTP.start(
192
+ res = ::Net::HTTP.start(
161
193
  uri.hostname,
162
194
  uri.port,
163
195
  open_timeout: COVERBAND_TIMEOUT,
@@ -167,8 +199,9 @@ module Coverband
167
199
  ) do |http|
168
200
  http.request(req)
169
201
  end
170
- rescue StandardError => e
171
- logger&.info "Coverband: Error while saving coverage #{e}" if Coverband.configuration.verbose || COVERBAND_ENABLE_DEV_MODE
202
+ if res.code.to_i >= 500
203
+ add_retry_message(coverage_body)
204
+ end
172
205
  end
173
206
  end
174
207
 
@@ -180,6 +213,10 @@ module Coverband
180
213
  initiate_http
181
214
  end
182
215
 
216
+ def recommended_timeout
217
+ puts Net::HTTP::Persistent.detect_idle_timeout URI("#{coverband_url}/api/collector")
218
+ end
219
+
183
220
  private
184
221
 
185
222
  def initiate_http
@@ -188,7 +225,13 @@ module Coverband
188
225
  @http.headers['Coverband-Token'] = api_key
189
226
  @http.open_timeout = COVERBAND_TIMEOUT
190
227
  @http.read_timeout = COVERBAND_TIMEOUT
191
- @http.ssl_timeout = COVERBAND_TIMEOUT
228
+ # the two below seem inconsistent in terms of how they are set
229
+ # leaving off for now
230
+ # @http.ssl_timeout = COVERBAND_TIMEOUT
231
+ # @http.write_timeout = COVERBAND_TIMEOUT
232
+ # default is 5-10 seconds but we report ever few min, heroku kills them
233
+ # before our reporting period... ;(
234
+ # @http.idle_timeout = 1000
192
235
  end
193
236
 
194
237
  def save_coverage(data)
@@ -293,7 +336,7 @@ end
293
336
  ENV['COVERBAND_DISABLE_AUTO_START'] = COVERBAND_ORIGINAL_START
294
337
  Coverband.configure do |config|
295
338
  # Use the Service Adapter
296
- if defined?(Net::HTTP::Persistent)
339
+ if Coverband::COVERBAND_PERSISTENT_HTTP && defined?(Net::HTTP::Persistent)
297
340
  config.store = Coverband::Adapters::PersistentService.new(Coverband::COVERBAND_SERVICE_URL)
298
341
  else
299
342
  config.store = Coverband::Adapters::Service.new(Coverband::COVERBAND_SERVICE_URL)
@@ -1,7 +1,7 @@
1
1
  module Coverband
2
2
  module Service
3
3
  module Client
4
- VERSION = '0.0.12.rc.2'
4
+ VERSION = '0.0.14'
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coverband-service-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12.rc.2
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Mayer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2020-06-20 00:00:00.000000000 Z
12
+ date: 2020-07-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -59,14 +59,14 @@ dependencies:
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: 4.2.4
62
+ version: 5.0.0.rc.3
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: 4.2.4
69
+ version: 5.0.0.rc.3
70
70
  description: Coverband service client
71
71
  email:
72
72
  - danmayer@gmail.com
@@ -84,6 +84,7 @@ files:
84
84
  - Rakefile
85
85
  - bin/console
86
86
  - bin/setup
87
+ - bin/stats
87
88
  - changelog.md
88
89
  - coverband-service-client.gemspec
89
90
  - lib/coverband-service-client.rb
@@ -106,9 +107,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
107
  version: '0'
107
108
  required_rubygems_version: !ruby/object:Gem::Requirement
108
109
  requirements:
109
- - - ">"
110
+ - - ">="
110
111
  - !ruby/object:Gem::Version
111
- version: 1.3.1
112
+ version: '0'
112
113
  requirements: []
113
114
  rubygems_version: 3.0.3
114
115
  signing_key: