buildkite-test_collector 2.15.0 → 2.16.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: de04f3cd718a70ec62965dd2e491c5eca981e9781118b3ab7c6a7c05e6ad7655
4
- data.tar.gz: c4a0fdbf14634c404ff6ade3db7d639b3f22fa4c5c6e21ba083ef92313ca6743
3
+ metadata.gz: 83d45811e314ed3a6defa2daebb928af60cf113a555e0409c5a842ad44cf0385
4
+ data.tar.gz: bb1687220b76611bb509f12d1804bf9ec530423e55b66a89cfd4ac0bb66acfd4
5
5
  SHA512:
6
- metadata.gz: 8682918b8784f2544a3da68e0a6dfd00ce8b2ab8decd9eb24bb0d458381c402697f3d20799bff9d38bd9ebec4a4f48e5ffe5b89d80ce88c89ffc7f54130e573a
7
- data.tar.gz: 2c1316f5b43bc3ea14df5aeae2e48496755edfe1892594403df6af499efe5b2aecbef4b1c3f8c5289100b4cacaeffc63da917109611cc5b84d0122a39eb8052c
6
+ metadata.gz: 42527c632311eafe2cc64e48b92b3a4da9e148b0a32fb72a687393f7ccf227cbee57be3fc8e50ba555844ef3d27e9dfae8b923285588ccf8cd0c635f9e92baab
7
+ data.tar.gz: 554ca53a2271210bdc6c796187f60bc5069038c98137514c156c5d9f0ef877767608a4d44d6f9357687c4892e7743e55550ca49e097bb08099cefdcc5872dfc4
@@ -12,13 +12,15 @@
12
12
  # - The build step is side-effect-free: it builds the gem, checks
13
13
  # tag/version consistency, and queries RubyGems read-only. It runs on
14
14
  # every rehearsal, so rehearsals exercise the release code. It never sees
15
- # RELEASE_EXECUTE (deliberately not propagated into its container).
15
+ # RELEASE_PUBLISH (set only on the publish step below), so it stops
16
+ # before `gem push` even on tag builds.
16
17
  # - The publish steps mint a push token via the rubygems.org OIDC API key
17
18
  # role, whose access policy trusts this pipeline (see the credential
18
19
  # cut-over section of ctg docs/publishing.md).
19
- # - The publish steps exist only on an exact test-collector-ruby/vX.Y.Z
20
- # tag AND RELEASE_EXECUTE=true set on the build, behind a block step;
21
- # the release script independently re-checks both before `gem push`.
20
+ # - The publish step exists only on an exact test-collector-ruby/vX.Y.Z
21
+ # tag, behind a block step; it sets RELEASE_PUBLISH=true in its own
22
+ # environment, and the release script independently re-checks the tag
23
+ # and RELEASE_PUBLISH before `gem push`.
22
24
 
23
25
  agents:
24
26
  queue: hosted
@@ -35,13 +37,17 @@ steps:
35
37
 
36
38
  - block: ":rocket: Publish test-collector-ruby to RubyGems?"
37
39
  key: ruby-confirm
38
- if: build.tag =~ /^test-collector-ruby\/v[0-9]+\.[0-9]+\.[0-9]+$/ && build.env("RELEASE_EXECUTE") == "true"
40
+ if: build.tag =~ /^test-collector-ruby\/v[0-9]+\.[0-9]+\.[0-9]+$/
39
41
 
40
42
  - label: ":rubygems: test-collector-ruby: publish to RubyGems"
41
- if: build.tag =~ /^test-collector-ruby\/v[0-9]+\.[0-9]+\.[0-9]+$/ && build.env("RELEASE_EXECUTE") == "true"
43
+ if: build.tag =~ /^test-collector-ruby\/v[0-9]+\.[0-9]+\.[0-9]+$/
42
44
  depends_on:
43
45
  - ruby-build
44
46
  - ruby-confirm
47
+ env:
48
+ # Step-local publish signal: distinguishes this credentialed step from
49
+ # the rehearsal build step, which runs the same script.
50
+ RELEASE_PUBLISH: "true"
45
51
  command: test-collector-ruby/.buildkite/steps/release
46
52
  plugins:
47
53
  - rubygems-oidc#v0.2.0:
@@ -51,4 +57,4 @@ steps:
51
57
  environment:
52
58
  - GEM_HOST_API_KEY
53
59
  - BUILDKITE_TAG
54
- - RELEASE_EXECUTE
60
+ - RELEASE_PUBLISH
@@ -1,9 +1,11 @@
1
1
  #!/usr/bin/env bash
2
2
  # Monorepo release script for test-collector-ruby: build the gem, check
3
- # tag/version consistency and RubyGems state, then publish — but the publish
4
- # side effect only happens when RELEASE_EXECUTE=true (set explicitly on the
5
- # release build; see pipeline.release.yml). Everything before the push runs
6
- # in rehearsals too, so dry-runs exercise this code.
3
+ # tag/version consistency and RubyGems state, then publish — but only in
4
+ # the publish step, which sets RELEASE_PUBLISH=true in its own container
5
+ # (see pipeline.release.yml); the pre-confirmation build step runs this
6
+ # same script as a side-effect-free rehearsal, even on tag builds.
7
+ # Everything before the push runs in rehearsals too, so dry-runs exercise
8
+ # this code.
7
9
  #
8
10
  # Injected by `ctg gather` from the ctg repo's overlay/ directory during the
9
11
  # dry-run era; post-cutover this file is maintained here, in the monorepo.
@@ -50,15 +52,15 @@ else
50
52
  echo "${GEM_NAME} ${VERSION} is not on rubygems.org (HTTP ${STATUS})"
51
53
  fi
52
54
 
53
- if [ "${RELEASE_EXECUTE:-}" != "true" ]; then
55
+ if [ "${RELEASE_PUBLISH:-}" != "true" ]; then
54
56
  echo "--- Rehearsal only"
55
- echo "RELEASE_EXECUTE is not 'true': stopping before 'gem push ${GEM_FILENAME}'."
57
+ echo "RELEASE_PUBLISH is not 'true': stopping before 'gem push ${GEM_FILENAME}'."
56
58
  exit 0
57
59
  fi
58
60
 
59
61
  echo "--- Publishing ${GEM_FILENAME} to RubyGems"
60
62
  if [ -z "${BUILDKITE_TAG:-}" ]; then
61
- echo "RELEASE_EXECUTE=true without a ${PROJECT}/vX.Y.Z tag; refusing" >&2
63
+ echo "RELEASE_PUBLISH=true without a ${PROJECT}/vX.Y.Z tag; refusing" >&2
62
64
  exit 1
63
65
  fi
64
66
  if [ "${ALREADY_PUBLISHED}" = "true" ]; then
data/CHANGELOG.md CHANGED
@@ -1,5 +1,87 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v2.16.0
4
+
5
+ * Report `code.line.number` for shared example inclusions (`it_behaves_like`,
6
+ `include_examples`, `include_context`) in OpenTelemetry test spans; the line
7
+ was previously omitted because RSpec's inclusion location includes the frame
8
+ label.
9
+ * Prevent OpenTelemetry export failures outside `StandardError`, including
10
+ WebMock network-blocking errors, from failing the test suite.
11
+ * Add the OTLP endpoint host to WebMock's allow list when WebMock is loaded.
12
+ * Validate OpenTelemetry run keys before export and fall back to the JSON upload
13
+ with a warning when they are invalid (or report that results cannot be
14
+ uploaded when no JSON token is available).
15
+ * Ignore empty `BUILDKITE_ANALYTICS_*` metadata overrides so they do not replace
16
+ values detected from the CI environment.
17
+ * Read bktec's relay credential from `BUILDKITE_TESTS_OTLP_TOKEN` and stop
18
+ reading `OTEL_EXPORTER_OTLP_*_HEADERS`, so credentials the process configures
19
+ for other OpenTelemetry destinations are never sent to Buildkite.
20
+ * Pin OpenTelemetry export to gzip, peer-verified HTTPS, and the system
21
+ certificate store, ignoring process-wide `OTEL_EXPORTER_OTLP_*` transport
22
+ overrides. Requires `opentelemetry-exporter-otlp` 0.29+; older versions fall
23
+ back to the JSON upload with a warning.
24
+ * Reduce the experimental OpenTelemetry test span batch size from 512 to 120 so
25
+ a batch of failures with maximum-length output fits the server's 900 KiB
26
+ request limit. Override the batch and queue sizes with
27
+ `BUILDKITE_TESTS_OTEL_TEST_SPAN_BATCH_SIZE` and
28
+ `BUILDKITE_TESTS_OTEL_TEST_SPAN_QUEUE_SIZE`; invalid values warn and use
29
+ the defaults.
30
+ * Override the OpenTelemetry child span batch and queue sizes with
31
+ `BUILDKITE_TESTS_OTEL_CHILD_SPAN_BATCH_SIZE` and
32
+ `BUILDKITE_TESTS_OTEL_CHILD_SPAN_QUEUE_SIZE`, and warn when child spans are
33
+ dropped instead of discarding them silently. `test.execution` results are
34
+ unaffected by child span drops.
35
+ * Set every OpenTelemetry batch processor option explicitly, including the export
36
+ timeout and starting the export thread on boot, so `OTEL_BSP_*` and
37
+ `OTEL_RUBY_BSP_START_THREAD_ON_BOOT` no longer affect Buildkite export.
38
+ * Truncate OpenTelemetry test span attributes to 10,243 characters (test names
39
+ keep the same identity as the JSON upload), exception messages to 10,243
40
+ characters, other event attributes to 16,384 characters, events to the newest
41
+ 100 per span, and the failure summary in the span status to 1,024 characters.
42
+ * **Breaking change to the experimental OpenTelemetry support:** opt-in
43
+ submission is now OTLP-only for RSpec. `otel_enabled: true` submits executions
44
+ as spans without also uploading legacy JSON, and the separate `otel_only`
45
+ option has been removed (passing it now raises `ArgumentError`). OpenTelemetry
46
+ remains off by default, so suites that never opted in are unaffected. When
47
+ OpenTelemetry cannot be used, the collector warns and uploads JSON instead:
48
+ at configure time for a non-RSpec hook, and at suite start when the
49
+ OpenTelemetry gems are missing or Ruby is older than 3.3. Without a token,
50
+ `otel_enabled` stays off and nothing is exported, the same as the JSON path,
51
+ which skips uploading without a token. When only `BUILDKITE_TESTS_OTLP_TOKEN`
52
+ held the credential, the fallback warning says results will not be uploaded,
53
+ since the JSON path has no token to use. Execution name
54
+ affixes (`BUILDKITE_ANALYTICS_EXECUTION_NAME_PREFIX`/`SUFFIX`) and custom
55
+ `env:` values have no OTLP equivalent and are not sent when `otel_enabled` is
56
+ on; the JSON upload that carried them in the old dual mode no longer happens.
57
+ * **Breaking change to the experimental OpenTelemetry support:** remove the
58
+ `otel_instrumentations` option (passing it now raises `ArgumentError`). It
59
+ only accepted `nil` or `[]`, and `[]` skipped installing the instrumentation
60
+ gems the suite had already required. Choose instrumentation by requiring the
61
+ gems you want; the collector installs every registered instrumentation when it
62
+ configures the SDK, and installs none when the suite configures the SDK
63
+ itself. There is no replacement switch that disables all instrumentation at
64
+ once: to skip one gem your bundle requires anyway, set the SDK's
65
+ `OTEL_RUBY_INSTRUMENTATION_<NAME>_ENABLED=false`; to skip them all, configure
66
+ the SDK yourself without `use_all` (see [Choosing
67
+ instrumentation](docs/opentelemetry.md#choosing-instrumentation)).
68
+ * Warn prominently, usually naming the HTTP status or connection error, the first
69
+ time Buildkite rejects or the collector drops `test.execution` spans, since
70
+ OTLP is now the only upload path. A test span that could not be started counts
71
+ as dropped too. When more are dropped after that, report the total at the
72
+ suite-end flush and again at process exit for anything still draining.
73
+ * Keep stable suite, CI worker/run, and VCS identity on OpenTelemetry resources,
74
+ while moving Test Engine run metadata, framework details, and configured tags
75
+ to each `test.execution` span. Child spans no longer carry execution-only
76
+ metadata as duplicated resource attributes.
77
+ * Send the Ruby version and configured location prefix with OpenTelemetry test
78
+ executions so OTLP-only uploads retain their classic upload tags and selector
79
+ paths.
80
+ * Add `otel_span_filter` to drop selected OpenTelemetry child spans before they
81
+ are queued for export. `test.execution` spans are never filtered, and a
82
+ filter that fails retains the span and warns once. Passing a value that does
83
+ not respond to `call` raises `ArgumentError` at configure time.
84
+
3
85
  ## v2.15.0
4
86
 
5
87
  * Add [experimental, opt-in OpenTelemetry trace export](docs/opentelemetry.md)
data/README.md CHANGED
@@ -5,7 +5,7 @@ Versions prior to 2.1.x are unsupported and will not work after mid-2023. Please
5
5
 
6
6
  Official [Buildkite Test Engine](https://buildkite.com/platform/test-engine) collectors for Ruby test frameworks ✨
7
7
 
8
- ⚒ **Supported test frameworks:** RSpec, Minitest, Cucumber, and [more coming soon](https://github.com/buildkite/test-collector-ruby/issues?q=is%3Aissue+is%3Aopen+label%3A%22test+frameworks%22).
8
+ ⚒ **Supported test frameworks:** RSpec, Minitest, Cucumber, and [more coming soon](https://github.com/buildkite/bktest/issues).
9
9
 
10
10
  📦 **Supported CI systems:** Buildkite, GitHub Actions, CircleCI, Codeship, and others via the `BUILDKITE_ANALYTICS_*` environment variables.
11
11
 
@@ -83,102 +83,35 @@ BUILDKITE_ANALYTICS_TOKEN=xyz cucumber
83
83
 
84
84
  Add the `BUILDKITE_ANALYTICS_TOKEN` secret to your CI, push your changes to a branch, and open a pull request 🎉
85
85
 
86
- ### OpenTelemetry export (experimental)
86
+ ### OpenTelemetry submission (experimental)
87
87
 
88
- RSpec suites can also send an OpenTelemetry trace per test execution to Buildkite,
89
- showing what each test did and where it spent its time. Each trace is rooted in a
90
- `test.execution` span carrying its name, location, result, and any failure detail.
91
- Tags passed to `configure` appear as resource attributes, while `tag_execution`
92
- adds attributes to the current test's root span.
88
+ RSpec suites can submit each test execution as an OpenTelemetry trace. Each
89
+ trace is rooted in a `test.execution` span carrying the test's name, location,
90
+ result, and failure detail. Instrumented child spans show what the test did and
91
+ where it spent its time.
93
92
 
94
- This feature is still under development and may change. This first release is
95
- intended for suites that do not already configure OpenTelemetry. It may work
96
- with an existing OpenTelemetry setup, but that configuration is not yet
97
- supported or guaranteed to work.
98
-
99
- OpenTelemetry export is off by default. Opt in when you configure the collector:
93
+ This feature is still under development and may change. OpenTelemetry is off by
94
+ default. Enable it when you configure the collector:
100
95
 
101
96
  ```ruby
102
97
  Buildkite::TestCollector.configure(hook: :rspec, otel_enabled: true)
103
98
  ```
104
99
 
105
- Execution roots use a private AlwaysOn provider so a suite's sampling policy
106
- cannot remove them.
107
-
108
- The collector configures a global provider for child spans and installs all
109
- applicable instrumentation registered when the suite starts. Because export is
110
- optional and its dependencies require Ruby 3.3+, the collector does not install
111
- them automatically. Add the OpenTelemetry SDK and OTLP exporter, plus any
112
- instrumentation you want to use:
113
-
114
- ```ruby
115
- # Gemfile
116
- gem "opentelemetry-exporter-otlp", "~> 0.34", require: false
117
- gem "opentelemetry-sdk", "~> 1.13", require: false
118
- gem "opentelemetry-instrumentation-pg", require: false
119
-
120
- # spec/spec_helper.rb
121
- require "opentelemetry-instrumentation-pg"
122
- require "buildkite/test_collector"
123
-
124
- Buildkite::TestCollector.configure(hook: :rspec, otel_enabled: true)
125
- ```
100
+ When enabled, OpenTelemetry is the only submission path. Every `test.execution` span includes
101
+ `buildkite.execution.via=otlp`, which tells Buildkite to synthesize the test
102
+ execution from the span. Nothing is uploaded to `/v1/uploads`.
126
103
 
127
- Adding a gem to the Gemfile may auto-require it in applications that call
128
- `Bundler.require`, but that is not guaranteed. An explicit `require` is the
129
- recommended setup. To disable instrumentations and export only root
130
- `test.execution` spans, set `otel_instrumentations: []`. Any other value is
131
- reserved for a future release and disables span export with a warning. See the
132
- [OpenTelemetry guide](docs/opentelemetry.md#choosing-instrumentation) for more.
133
-
134
- Export needs Ruby 3.3 or newer, which is what the OpenTelemetry gems require. If
135
- those gems are unavailable, the option is accepted and export remains disabled.
136
-
137
- The collector honors standard `OTEL_EXPORTER_OTLP_TRACES_HEADERS` (or the
138
- generic `OTEL_EXPORTER_OTLP_HEADERS`) and gives them precedence over its own
139
- headers, including `Authorization`. bktec's OTLP relay uses this to provide its
140
- local credential without changing `BUILDKITE_ANALYTICS_TOKEN`, which remains
141
- available for normal JSON uploads in `otel_enabled` mode. Without an OTLP
142
- Authorization header, spans use `BUILDKITE_ANALYTICS_TOKEN`, which must be an
143
- agent OIDC token with the `write_uploads` scope; a suite API token still uploads
144
- executions, but its spans are rejected.
145
-
146
- Export failures never fail a test or block the normal Test Engine upload. See the
147
- [OpenTelemetry guide](docs/opentelemetry.md) for setup details and current
148
- limitations.
149
-
150
- ### OTLP-only submission (experimental)
151
-
152
- RSpec suites can go one step further and submit results *only* over OTLP, with
153
- no JSON upload at all. It exports the same spans as `otel_enabled` and adds
154
- `buildkite.execution.via=otlp`, which tells Buildkite to synthesize each test
155
- execution from its span server-side:
156
-
157
- ```ruby
158
- Buildkite::TestCollector.configure(hook: :rspec, otel_only: true)
159
- ```
104
+ This requires Ruby 3.3 or newer and the optional `opentelemetry-sdk` and
105
+ `opentelemetry-exporter-otlp` gems, which the collector does not install. If
106
+ OpenTelemetry cannot be configured, the collector warns and uploads results as
107
+ JSON instead.
160
108
 
161
- In this mode the collector's legacy machinery is switched off: nothing is
162
- uploaded to `/v1/uploads`, and `Net::HTTP` and `Object` are left unpatched. The
163
- gem's whole job is to configure OpenTelemetry so each test gets a suitable span:
164
-
165
- - `Buildkite::TestCollector.annotate` adds a `test.annotation` event to the
166
- current span.
167
- - `Buildkite::TestCollector.tag_execution` sets attributes on the test span.
168
- - `tags:` given to `configure` become resource attributes on every span.
169
- - Instrumentation works exactly as it does with `otel_enabled`: everything you
170
- require and register installs, and `otel_instrumentations: []` exports only
171
- the `test.execution` spans. See
172
- [choosing instrumentation](docs/opentelemetry.md#choosing-instrumentation).
173
- - Your code can also talk to OpenTelemetry directly — the collector configures
174
- the global tracer provider, so
175
- `OpenTelemetry::Trace.current_span.set_attribute(...)` works during a test,
176
- and any instrumentation joins the test's trace.
177
-
178
- `otel_only` is currently RSpec-only and has the same Ruby 3.3+ and OpenTelemetry
179
- gem requirements as `otel_enabled`. It's an alternative to `otel_enabled`; the
180
- two are mutually exclusive, and passing both (either value) raises
181
- `ArgumentError`.
109
+ If Buildkite rejects the exported `test.execution` spans, the collector prints a
110
+ prominent warning. Tests continue to run, but the affected results are not
111
+ uploaded. See the
112
+ [OpenTelemetry guide](docs/opentelemetry.md) for dependency setup,
113
+ instrumentation, filtering noisy child spans with `otel_span_filter`,
114
+ authentication, attributes, and current limitations.
182
115
 
183
116
  ## More information
184
117
 
@@ -204,7 +137,7 @@ See [DESIGN.md](DESIGN.md) for an overview of the design of this gem.
204
137
 
205
138
  ## 👩‍💻 Contributing
206
139
 
207
- Bug reports and pull requests are welcome on GitHub at https://github.com/buildkite/test-collector-ruby
140
+ Bug reports and pull requests are welcome on GitHub at https://github.com/buildkite/bktest
208
141
 
209
142
  ## 🚀 Releasing
210
143
 
@@ -9,11 +9,13 @@ Gem::Specification.new do |spec|
9
9
  spec.email = ["support+analytics@buildkite.com"]
10
10
 
11
11
  spec.summary = "Track test executions and report to Buildkite Test Engine"
12
- spec.homepage = "https://github.com/buildkite/test-collector-ruby"
12
+ spec.homepage = "https://github.com/buildkite/bktest/tree/main/test-collector-ruby"
13
13
  spec.license = "MIT"
14
14
 
15
15
  spec.metadata["homepage_uri"] = spec.homepage
16
- spec.metadata["source_code_uri"] = "https://github.com/buildkite/test-collector-ruby"
16
+ spec.metadata["source_code_uri"] = "https://github.com/buildkite/bktest"
17
+ spec.metadata["changelog_uri"] = "https://github.com/buildkite/bktest/blob/main/test-collector-ruby/CHANGELOG.md"
18
+ spec.metadata["bug_tracker_uri"] = "https://github.com/buildkite/bktest/issues"
17
19
 
18
20
  # Specify which files should be added to the gem when it is released.
19
21
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -31,4 +33,5 @@ Gem::Specification.new do |spec|
31
33
  spec.add_development_dependency "ostruct"
32
34
  spec.add_development_dependency "rspec-core", '~> 3.10'
33
35
  spec.add_development_dependency "rspec-expectations", '~> 3.10'
36
+ spec.add_development_dependency "webmock"
34
37
  end