buildkite-test_collector 2.6.0 → 2.7.0
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 +4 -4
- data/CHANGELOG.md +14 -0
- data/Gemfile.lock +1 -1
- data/buildkite.yaml +5 -10
- data/lib/buildkite/test_collector/http_client.rb +7 -1
- data/lib/buildkite/test_collector/library_hooks/rspec.rb +14 -7
- data/lib/buildkite/test_collector/tracer.rb +14 -5
- data/lib/buildkite/test_collector/uploader.rb +3 -2
- data/lib/buildkite/test_collector/version.rb +1 -1
- data/lib/buildkite/test_collector.rb +16 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 646d052c76b21f29bedb5526bf78b6a936c2c68091160ba393d4247936aeaf91
|
4
|
+
data.tar.gz: 4755eab1880142bfd38ef61413e9bf868f9d5b48c95c23a849735710d31d3bdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c4688fd37b1031374a0ff483bc36d751ae99dcd8b6f4ddf2d561ebfe2b71974316c6c0bd83fead42e20b5e355658a2f9cbbfa564427dc4021576286a6cd2cc1
|
7
|
+
data.tar.gz: '0298aa60472fd0f52c97e98c581268345798f41781ee8234021cd4c8837e91f336adebef4ee209db0a2b14fac7001ecff3cd8991b6f0d723b3479ae80792a4c3'
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## v2.7.0
|
4
|
+
|
5
|
+
Features:
|
6
|
+
|
7
|
+
- Add configurable span filters #220 - @catkins
|
8
|
+
|
9
|
+
Fixes:
|
10
|
+
|
11
|
+
- Correctly report HTTP error during upload #223 - @zhming0
|
12
|
+
|
13
|
+
## v2.6.1
|
14
|
+
|
15
|
+
- Fix missing failed examples if rspec hooks fail #221 - @zhming0
|
16
|
+
|
3
17
|
## v2.6.0
|
4
18
|
|
5
19
|
- Trace spans can be filtered by minimum duration #215 - @pda
|
data/Gemfile.lock
CHANGED
data/buildkite.yaml
CHANGED
@@ -1,22 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
command:
|
4
|
-
- "bundle"
|
5
|
-
- "bundle exec rake"
|
6
|
-
plugins:
|
7
|
-
- docker#v3.7.0:
|
8
|
-
image: "445615400570.dkr.ecr.us-east-1.amazonaws.com/ecr-public/docker/library/ruby:3.3-rc"
|
9
|
-
soft_fail: true
|
1
|
+
agents:
|
2
|
+
queue: hosted
|
10
3
|
|
4
|
+
steps:
|
11
5
|
- label: ":rspec: Tests :ruby: {{matrix}}"
|
12
6
|
command:
|
13
7
|
- "bundle"
|
14
8
|
- "bundle exec rake"
|
15
9
|
plugins:
|
16
10
|
- docker#v3.7.0:
|
17
|
-
image: "
|
11
|
+
image: "public.ecr.aws/docker/library/ruby:{{matrix}}"
|
18
12
|
matrix:
|
19
13
|
- "latest"
|
14
|
+
- "3.3"
|
20
15
|
- "3.2"
|
21
16
|
- "3.1"
|
22
17
|
- "3.0"
|
@@ -38,7 +38,13 @@ module Buildkite::TestCollector
|
|
38
38
|
|
39
39
|
contact.body = compressed_body.string
|
40
40
|
|
41
|
-
http.request(contact)
|
41
|
+
response = http.request(contact)
|
42
|
+
|
43
|
+
if response.is_a?(Net::HTTPSuccess)
|
44
|
+
response
|
45
|
+
else
|
46
|
+
raise "HTTP Request Failed: #{response.code} #{response.message}"
|
47
|
+
end
|
42
48
|
end
|
43
49
|
|
44
50
|
def metadata
|
@@ -23,13 +23,20 @@ RSpec.configure do |config|
|
|
23
23
|
# The _buildkite prefix here is added as a safeguard against name collisions
|
24
24
|
# as we are in the main thread
|
25
25
|
Thread.current[:_buildkite_tracer] = tracer
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
26
|
+
# It's important to use begin/ensure here, because otherwise if other hooks fail,
|
27
|
+
# the cleanup code won't run, meaning we will miss some data.
|
28
|
+
#
|
29
|
+
# Having said that, this behavior isn't documented by RSpec.
|
30
|
+
begin
|
31
|
+
example.run
|
32
|
+
ensure
|
33
|
+
Thread.current[:_buildkite_tracer] = nil
|
34
|
+
|
35
|
+
tracer.finalize
|
36
|
+
|
37
|
+
trace = Buildkite::TestCollector::RSpecPlugin::Trace.new(example, history: tracer.history)
|
38
|
+
Buildkite::TestCollector.uploader.traces[example.id] = trace
|
39
|
+
end
|
33
40
|
end
|
34
41
|
|
35
42
|
config.after(:suite) do
|
@@ -58,7 +58,6 @@ module Buildkite::TestCollector
|
|
58
58
|
def initialize(min_duration: nil)
|
59
59
|
@top = Span.new(:top, MonotonicTime.call, nil, {})
|
60
60
|
@stack = [@top]
|
61
|
-
@min_duration = min_duration
|
62
61
|
end
|
63
62
|
|
64
63
|
def enter(section, **detail)
|
@@ -69,17 +68,17 @@ module Buildkite::TestCollector
|
|
69
68
|
|
70
69
|
def leave
|
71
70
|
current_span.end_at = MonotonicTime.call
|
72
|
-
duration = current_span.duration
|
73
71
|
@stack.pop
|
74
|
-
|
72
|
+
|
73
|
+
current_span.children.pop unless retain_span?(current_span.children.last)
|
74
|
+
|
75
75
|
nil # avoid ambiguous return type/value
|
76
76
|
end
|
77
77
|
|
78
78
|
def backfill(section, duration, **detail)
|
79
|
-
return if @min_duration && duration < @min_duration
|
80
79
|
now = MonotonicTime.call
|
81
80
|
new_entry = Span.new(section, now - duration, now, detail)
|
82
|
-
current_span.children << new_entry
|
81
|
+
current_span.children << new_entry if retain_span?(new_entry)
|
83
82
|
end
|
84
83
|
|
85
84
|
def current_span
|
@@ -95,5 +94,15 @@ module Buildkite::TestCollector
|
|
95
94
|
def history
|
96
95
|
@top.as_hash
|
97
96
|
end
|
97
|
+
|
98
|
+
private
|
99
|
+
|
100
|
+
def retain_span?(span)
|
101
|
+
return true unless Buildkite::TestCollector.span_filters
|
102
|
+
|
103
|
+
Buildkite::TestCollector.span_filters.all? do |filter|
|
104
|
+
filter.call(span)
|
105
|
+
end
|
106
|
+
end
|
98
107
|
end
|
99
108
|
end
|
@@ -25,7 +25,8 @@ module Buildkite::TestCollector
|
|
25
25
|
OpenSSL::SSL::SSLError,
|
26
26
|
OpenSSL::SSL::SSLErrorWaitReadable,
|
27
27
|
EOFError,
|
28
|
-
Errno::ETIMEDOUT
|
28
|
+
Errno::ETIMEDOUT,
|
29
|
+
# TODO: some retries for server-side error would be great.
|
29
30
|
]
|
30
31
|
|
31
32
|
def self.tracer
|
@@ -38,7 +39,7 @@ module Buildkite::TestCollector
|
|
38
39
|
http = Buildkite::TestCollector::HTTPClient.new(Buildkite::TestCollector.url)
|
39
40
|
|
40
41
|
Thread.new do
|
41
|
-
|
42
|
+
begin
|
42
43
|
upload_attempts ||= 0
|
43
44
|
http.post_json(data)
|
44
45
|
rescue *Buildkite::TestCollector::Uploader::RETRYABLE_UPLOAD_ERRORS => e
|
@@ -28,7 +28,6 @@ module Buildkite
|
|
28
28
|
module TestCollector
|
29
29
|
DEFAULT_URL = "https://analytics-api.buildkite.com/v1/uploads"
|
30
30
|
DEFAULT_UPLOAD_BATCH_SIZE = 500
|
31
|
-
|
32
31
|
class << self
|
33
32
|
attr_accessor :api_token
|
34
33
|
attr_accessor :url
|
@@ -39,6 +38,7 @@ module Buildkite
|
|
39
38
|
attr_accessor :env
|
40
39
|
attr_accessor :batch_size
|
41
40
|
attr_accessor :trace_min_duration
|
41
|
+
attr_accessor :span_filters
|
42
42
|
end
|
43
43
|
|
44
44
|
def self.configure(hook:, token: nil, url: nil, tracing_enabled: true, artifact_path: nil, env: {})
|
@@ -54,6 +54,11 @@ module Buildkite
|
|
54
54
|
Float(trace_min_ms_string) / 1000
|
55
55
|
end
|
56
56
|
|
57
|
+
self.span_filters = []
|
58
|
+
unless self.trace_min_duration.nil?
|
59
|
+
self.span_filters << MinDurationSpanFilter.new(self.trace_min_duration)
|
60
|
+
end
|
61
|
+
|
57
62
|
self.hook_into(hook)
|
58
63
|
end
|
59
64
|
|
@@ -84,5 +89,15 @@ module Buildkite
|
|
84
89
|
Buildkite::TestCollector::Uploader.tracer&.backfill(:sql, finish - start, **{ query: payload[:sql] })
|
85
90
|
end
|
86
91
|
end
|
92
|
+
|
93
|
+
class MinDurationSpanFilter
|
94
|
+
def initialize(min_duration)
|
95
|
+
@min_duration = min_duration
|
96
|
+
end
|
97
|
+
|
98
|
+
def call(span)
|
99
|
+
span.duration > @min_duration
|
100
|
+
end
|
101
|
+
end
|
87
102
|
end
|
88
103
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: buildkite-test_collector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Buildkite
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0'
|
117
117
|
requirements: []
|
118
|
-
rubygems_version: 3.
|
118
|
+
rubygems_version: 3.5.11
|
119
119
|
signing_key:
|
120
120
|
specification_version: 4
|
121
121
|
summary: Track test executions and report to Buildkite Test Analytics
|