coverband-service-client 0.0.12.rc.3 → 0.0.12.rc.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/bin/stats +42 -0
- data/coverband-service-client.gemspec +8 -0
- data/lib/coverband-service-client.rb +53 -11
- data/lib/coverband/service/client/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8bd1387ac9c907dceb9a215b957d77bd30021615658f95163e627cd81239564
|
4
|
+
data.tar.gz: 303f7fa7b317f8b97bbb50f8a4f526c6e6bbf6860ef934fd3f23966b6f0611e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5be62bec964696cb38174cc21b1422335621c6745befe4b60d1ca62375ab558db60c161175bf1049f3cb824429fbeac256350c0781bc867c67b45941b644a4fa
|
7
|
+
data.tar.gz: 1c3dc9904513616b21bc86d051905663603ebc816683c11cad86d9a60cca187f38a3cf5bda5c3b15c49bd390688adecd7049f2f9fc9a637609d63f7861ab36b8
|
data/Gemfile.lock
CHANGED
data/bin/stats
ADDED
@@ -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
40
|
spec.add_runtime_dependency "coverband", "~> 4.2.4"
|
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
|
|
@@ -132,10 +134,11 @@ module Coverband
|
|
132
134
|
}
|
133
135
|
}
|
134
136
|
|
135
|
-
starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
137
|
+
starting = Process.clock_gettime(Process::CLOCK_MONOTONIC) if @stats
|
136
138
|
save_coverage(full_package)
|
137
|
-
ending = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
138
|
-
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
|
139
142
|
end&.join
|
140
143
|
end
|
141
144
|
|
@@ -145,20 +148,48 @@ module Coverband
|
|
145
148
|
|
146
149
|
private
|
147
150
|
|
151
|
+
def retry_failed_reports
|
152
|
+
retries = []
|
153
|
+
@failed_coverage_reports.any? do
|
154
|
+
report_body = arr.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
|
+
|
148
172
|
def save_coverage(data)
|
149
173
|
if api_key.nil?
|
150
174
|
puts "Coverband: Error: no Coverband API key was found!"
|
151
175
|
return
|
152
176
|
end
|
153
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)
|
154
186
|
uri = URI("#{coverband_url}/api/collector")
|
155
|
-
req = Net::HTTP::Post.new(uri,
|
187
|
+
req = ::Net::HTTP::Post.new(uri,
|
156
188
|
'Content-Type' => 'application/json',
|
157
189
|
'Coverband-Token' => api_key)
|
158
|
-
req.body =
|
159
|
-
|
190
|
+
req.body = coverage_body
|
160
191
|
logger&.info "Coverband: saving (#{uri}) #{req.body}" if Coverband.configuration.verbose
|
161
|
-
res = Net::HTTP.start(
|
192
|
+
res = ::Net::HTTP.start(
|
162
193
|
uri.hostname,
|
163
194
|
uri.port,
|
164
195
|
open_timeout: COVERBAND_TIMEOUT,
|
@@ -168,8 +199,9 @@ module Coverband
|
|
168
199
|
) do |http|
|
169
200
|
http.request(req)
|
170
201
|
end
|
171
|
-
|
172
|
-
|
202
|
+
if res.code.to_i >= 500
|
203
|
+
add_retry_message(coverage_body)
|
204
|
+
end
|
173
205
|
end
|
174
206
|
end
|
175
207
|
|
@@ -181,6 +213,10 @@ module Coverband
|
|
181
213
|
initiate_http
|
182
214
|
end
|
183
215
|
|
216
|
+
def recommended_timeout
|
217
|
+
puts Net::HTTP::Persistent.detect_idle_timeout URI("#{coverband_url}/api/collector")
|
218
|
+
end
|
219
|
+
|
184
220
|
private
|
185
221
|
|
186
222
|
def initiate_http
|
@@ -189,7 +225,13 @@ module Coverband
|
|
189
225
|
@http.headers['Coverband-Token'] = api_key
|
190
226
|
@http.open_timeout = COVERBAND_TIMEOUT
|
191
227
|
@http.read_timeout = COVERBAND_TIMEOUT
|
192
|
-
|
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
|
193
235
|
end
|
194
236
|
|
195
237
|
def save_coverage(data)
|
@@ -294,7 +336,7 @@ end
|
|
294
336
|
ENV['COVERBAND_DISABLE_AUTO_START'] = COVERBAND_ORIGINAL_START
|
295
337
|
Coverband.configure do |config|
|
296
338
|
# Use the Service Adapter
|
297
|
-
if defined?(Net::HTTP::Persistent)
|
339
|
+
if Coverband::COVERBAND_PERSISTENT_HTTP && defined?(Net::HTTP::Persistent)
|
298
340
|
config.store = Coverband::Adapters::PersistentService.new(Coverband::COVERBAND_SERVICE_URL)
|
299
341
|
else
|
300
342
|
config.store = Coverband::Adapters::Service.new(Coverband::COVERBAND_SERVICE_URL)
|
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.
|
4
|
+
version: 0.0.12.rc.4
|
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-
|
12
|
+
date: 2020-06-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -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
|