buildkite-test_collector 2.6.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2bb798155684d3e4703de75ea06ccaf67b4f6d1b26c98459e621b34dea157e54
4
- data.tar.gz: 6eb653f87c490762cadef81b202cb5f77d900b9a628ca245fd9718307e506dd5
3
+ metadata.gz: 646d052c76b21f29bedb5526bf78b6a936c2c68091160ba393d4247936aeaf91
4
+ data.tar.gz: 4755eab1880142bfd38ef61413e9bf868f9d5b48c95c23a849735710d31d3bdf
5
5
  SHA512:
6
- metadata.gz: d2e371578afd8e21a3736b86c5158ebc72e57f61dd771a3365ae932e16d2b0b5add98e139ffc2cfd1ac0b54b6ea08a664f1ebc4a3082e1e07ef10b5ea318fad9
7
- data.tar.gz: 817afafdd348cb3f2e4b8dd0b720a1afc6e988094bb872b1306a958eea1c9432abba0edcbbba94b920df6d415115bb60e5e55d9ccd70772d9ac71e88b0e13646
6
+ metadata.gz: 6c4688fd37b1031374a0ff483bc36d751ae99dcd8b6f4ddf2d561ebfe2b71974316c6c0bd83fead42e20b5e355658a2f9cbbfa564427dc4021576286a6cd2cc1
7
+ data.tar.gz: '0298aa60472fd0f52c97e98c581268345798f41781ee8234021cd4c8837e91f336adebef4ee209db0a2b14fac7001ecff3cd8991b6f0d723b3479ae80792a4c3'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
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
+
3
13
  ## v2.6.1
4
14
 
5
15
  - Fix missing failed examples if rspec hooks fail #221 - @zhming0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- buildkite-test_collector (2.6.1)
4
+ buildkite-test_collector (2.7.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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
@@ -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.1"
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.1
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-09-09 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