buildkite-test_collector 2.6.0 → 2.7.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: 0e8ff4ceff4d825291a8878bf19a912362d45c36d6750c5e14628f446cec0bbd
4
- data.tar.gz: 215441296a3c91547b0c43b062893239fbe5bae5ca2e1a80cca7b2ec65277e77
3
+ metadata.gz: 646d052c76b21f29bedb5526bf78b6a936c2c68091160ba393d4247936aeaf91
4
+ data.tar.gz: 4755eab1880142bfd38ef61413e9bf868f9d5b48c95c23a849735710d31d3bdf
5
5
  SHA512:
6
- metadata.gz: d31e59e76f2dc92ef5951f9d97663f14cb84d9ba1256c8586931146151222c7ce3769a8913517910312d0a75a7cafb3488f0b9690257c4fc6686fbf37cbed9ee
7
- data.tar.gz: 995fc9e592b74a41385058c4eac868e9639f6ef9bfb2ba9068cd156fd6ab5d90bf40aca86a9ab9c8560cf7c9ba80c4f172747a948e4e219976c680d035eae0af
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- buildkite-test_collector (2.6.0)
4
+ buildkite-test_collector (2.7.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/buildkite.yaml CHANGED
@@ -1,22 +1,17 @@
1
- steps:
2
- - label: ":rspec: Tests :ruby: 3.3-rc"
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: "445615400570.dkr.ecr.us-east-1.amazonaws.com/ecr-public/docker/library/ruby:{{matrix}}"
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
- example.run
27
- Thread.current[:_buildkite_tracer] = nil
28
-
29
- tracer.finalize
30
-
31
- trace = Buildkite::TestCollector::RSpecPlugin::Trace.new(example, history: tracer.history)
32
- Buildkite::TestCollector.uploader.traces[example.id] = trace
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
- current_span.children.pop if @min_duration && duration < @min_duration
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
- response = begin
42
+ begin
42
43
  upload_attempts ||= 0
43
44
  http.post_json(data)
44
45
  rescue *Buildkite::TestCollector::Uploader::RETRYABLE_UPLOAD_ERRORS => e
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Buildkite
4
4
  module TestCollector
5
- VERSION = "2.6.0"
5
+ VERSION = "2.7.0"
6
6
  NAME = "buildkite-test_collector"
7
7
  end
8
8
  end
@@ -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.6.0
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-03-21 00:00:00.000000000 Z
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.4.10
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