gitlab-labkit 1.5.0 → 1.12.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.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/.copier-answers.yml +3 -1
  3. data/.gitlab/merge_request_templates/default.md +9 -0
  4. data/.gitlab-ci-asdf-versions.yml +2 -2
  5. data/.gitlab-ci.yml +14 -15
  6. data/.pre-commit-config.yaml +1 -1
  7. data/.releaserc.json +7 -1
  8. data/.tool-versions +2 -2
  9. data/CODEOWNERS +1 -1
  10. data/doc/FIELD_STANDARDIZATION.md +148 -128
  11. data/gitlab-labkit.gemspec +2 -2
  12. data/lib/labkit/context.rb +4 -0
  13. data/lib/labkit/fields.rb +127 -42
  14. data/lib/labkit/logging/field_validator/config.rb +5 -18
  15. data/lib/labkit/logging/field_validator.rb +1 -1
  16. data/lib/labkit/net_http_publisher.rb +20 -1
  17. data/lib/labkit/rspec/README.md +0 -9
  18. data/lib/labkit/rspec/matchers/user_experience_matchers.rb +53 -0
  19. data/lib/labkit/tracing/README.md +50 -25
  20. data/lib/labkit/tracing/abstract_instrumenter.rb +7 -8
  21. data/lib/labkit/tracing/adapters/opentelemetry_span.rb +4 -0
  22. data/lib/labkit/tracing/adapters/opentelemetry_tracer.rb +12 -0
  23. data/lib/labkit/tracing/adapters/opentracing_span.rb +4 -0
  24. data/lib/labkit/tracing/adapters/opentracing_tracer.rb +9 -6
  25. data/lib/labkit/tracing/auto_initialize.rb +28 -6
  26. data/lib/labkit/tracing/external_http/request_instrumenter.rb +4 -13
  27. data/lib/labkit/tracing/open_telemetry_factory.rb +3 -13
  28. data/lib/labkit/tracing/open_tracing_factory.rb +1 -10
  29. data/lib/labkit/tracing/rails/action_view/render_template_instrumenter.rb +6 -1
  30. data/lib/labkit/tracing/rails/active_record/sql_instrumenter.rb +9 -4
  31. data/lib/labkit/tracing/tracing_utils.rb +9 -7
  32. data/lib/labkit/tracing.rb +3 -1
  33. data/lib/labkit/user_experience_sli/README.md +20 -0
  34. data/lib/labkit/user_experience_sli/experience.rb +33 -12
  35. data/lib/labkit/user_experience_sli/null.rb +5 -2
  36. data/lib/labkit/user_experience_sli.rb +15 -3
  37. data/scripts/prepare-dev-env.sh +1 -0
  38. metadata +10 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf6262472d851bcdfeb96b0ed3b7acf25f462b0b968d2ac2f431ea946b68b33a
4
- data.tar.gz: b04bfc82c7ea63848849af40c7940788796b486a16c41416de824b7440f01992
3
+ metadata.gz: e99cf18b21d9da22b488d0dd0031fc9030aeded745239b4e72e8d3f7c1c36555
4
+ data.tar.gz: 664ba45d3535d3310431eece7890c58ddfa9cd8a9dfa3c235b66fd20b2b5480e
5
5
  SHA512:
6
- metadata.gz: 7c5a7b9002239cf23e7609fd8c07174bf588c0f2f1f2177616d6f98f4490c8e32f74cb7c8e62c1bf8ae839da24e30023e9bd733f1a6e40bbf75484d614a3d9ad
7
- data.tar.gz: e699b4a653c268c7333bdad41006a5c52d0fbdaf0aa4c21ca90bbb396695d6519695243e0548e0f5439f9bd11366c6a3359c013766deadaa6996e31bbbfb7c7a
6
+ metadata.gz: f7959c2eb8f54ee928a7841c2b8de8011c1e2a481c3c6aaf8e94b53a7ca186e8c28ad192a641c4c8ffac5bd8fd39a2c7c6afad324dfae77531b00e3089de3dc0
7
+ data.tar.gz: 05d07f6b1dffe39907c372ca0cb1c638cbc3898f39faf33f82ef5e042c9ea916a94d297963706e0010bc30dc14df2ebf2a1d89a342866630753af233f52934d1
data/.copier-answers.yml CHANGED
@@ -3,7 +3,7 @@
3
3
  # See the project for instructions on how to update the project
4
4
  #
5
5
  # Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
6
- _commit: v1.39.0
6
+ _commit: v1.45.0
7
7
  _src_path: https://gitlab.com/gitlab-com/gl-infra/common-template-copier.git
8
8
  ee_licensed: false
9
9
  golang: false
@@ -11,6 +11,8 @@ helm: false
11
11
  initial_codeowners: '@reprazent @andrewn @mkaeppler @ayufan'
12
12
  jsonnet: false
13
13
  project_name: labkit-ruby
14
+ release_platform: false
14
15
  ruby: true
15
16
  rubygem: true
16
17
  terraform: false
18
+ truncated_tags: true
@@ -0,0 +1,9 @@
1
+ ## Description
2
+
3
+ <!-- Briefly describe what this MR does and why -->
4
+
5
+ ## Related Issues
6
+
7
+ <!-- Link to related issues using #issue_number -->
8
+
9
+ /assign me
@@ -1,5 +1,5 @@
1
1
  # DO NOT MANUALLY EDIT; Run ./scripts/update-asdf-version-variables.sh to update this
2
2
  variables:
3
- GL_ASDF_RUBY_VERSION: "3.4.8"
3
+ GL_ASDF_RUBY_VERSION: "4.0.1"
4
4
  GL_ASDF_SHELLCHECK_VERSION: "0.11"
5
- GL_ASDF_SHFMT_VERSION: "3.12"
5
+ GL_ASDF_SHFMT_VERSION: "3.13"
data/.gitlab-ci.yml CHANGED
@@ -19,29 +19,28 @@ include:
19
19
  # It includes standard checks, gitlab-scanners, validations and release processes
20
20
  # common to all projects using this template library.
21
21
  # see https://gitlab.com/gitlab-com/gl-infra/common-ci-tasks/-/blob/main/templates/standard.md
22
- - component: $CI_SERVER_FQDN/gitlab-com/gl-infra/common-ci-tasks/standard-build@v3.5
22
+ - component: $CI_SERVER_FQDN/gitlab-com/gl-infra/common-ci-tasks/standard-build@v3.12
23
23
 
24
24
  # Runs rspec tests and rubocop on the project
25
25
  # see https://gitlab.com/gitlab-com/gl-infra/common-ci-tasks/-/blob/main/templates/ruby.md
26
- - component: $CI_SERVER_FQDN/gitlab-com/gl-infra/common-ci-tasks/ruby-build@v3.5
26
+ - component: $CI_SERVER_FQDN/gitlab-com/gl-infra/common-ci-tasks/ruby-build@v3.12
27
27
 
28
- - component: $CI_SERVER_FQDN/gitlab-com/gl-infra/common-ci-tasks/danger@v3.5
29
-
30
- .test_template: &test_definition
31
- extends: .with_bundle
32
- image: ruby:${RUBY_VERSION}
33
- stage: validate
34
- script:
35
- - gem install bundler --no-document
36
- - bundle config --local path vendor
37
- - bundle install
38
- - bundle exec rake verify build install
28
+ - component: $CI_SERVER_FQDN/gitlab-com/gl-infra/common-ci-tasks/danger@v3.12
39
29
 
40
30
  ruby-versions:
41
- <<: *test_definition
31
+ extends: rspec
32
+ image: ${CI_REGISTRY}/gitlab-com/gl-infra/common-ci-tasks-images/ruby:${RUBY_VERSION}
33
+ parallel:
34
+ matrix:
35
+ - RUBY_VERSION: ["3.4"]
36
+
37
+ # These versions aren't built in common CI tasks, so use a public ruby image
38
+ legacy-ruby-versions:
39
+ extends: rspec
40
+ image: ruby:${RUBY_VERSION}
42
41
  parallel:
43
42
  matrix:
44
- - RUBY_VERSION: ["3.2", "3.3"]
43
+ - RUBY_VERSION: ["3.3"]
45
44
 
46
45
  deploy:
47
46
  rules:
@@ -25,7 +25,7 @@ repos:
25
25
  # Documentation available at
26
26
  # https://gitlab.com/gitlab-com/gl-infra/common-ci-tasks/-/blob/main/docs/pre-commit.md
27
27
  - repo: https://gitlab.com/gitlab-com/gl-infra/common-ci-tasks
28
- rev: v3.5 # renovate:managed
28
+ rev: v3.12 # renovate:managed
29
29
 
30
30
  hooks:
31
31
  - id: shellcheck # Run shellcheck for changed Shell files
data/.releaserc.json CHANGED
@@ -1,5 +1,11 @@
1
1
  {
2
- "branches": ["master"],
2
+ "branches": [
3
+ {
4
+ "name": "+([0-9])-+([0-9])-stable",
5
+ "range": "${name.replace(/^(\\d+)-(\\d+)-stable$/, '$1.$2.x')}"
6
+ },
7
+ "master"
8
+ ],
3
9
  "plugins": [
4
10
  [
5
11
  "@semantic-release/commit-analyzer",
data/.tool-versions CHANGED
@@ -1,3 +1,3 @@
1
- ruby 3.4.8
2
- shfmt 3.12
1
+ ruby 4.0.1
2
+ shfmt 3.13
3
3
  shellcheck 0.11
data/CODEOWNERS CHANGED
@@ -1,4 +1,4 @@
1
1
  # CODEOWNERS is used to lookup assignees for
2
2
  # Renovate Bot dependency change Merge Requests.
3
3
  # https://docs.renovatebot.com/configuration-options/#assigneesfromcodeowners
4
- * @reprazent @andrewn @mkaeppler @ayufan @hmerscher @d.barrett @splattael
4
+ * @reprazent @andrewn @mkaeppler @ayufan @hmerscher @d.barrett @splattael @e_forbes @M_Alvarez
@@ -2,134 +2,172 @@
2
2
 
3
3
  ## Overview
4
4
 
5
- The LabKit Field Validator detects when your code uses deprecated logging field names and helps you migrate to standardized fields. This supports the [Observability Field Standardisation initiative](https://handbook.gitlab.com/handbook/engineering/architecture/design-documents/observability_field_standardisation/).
5
+ The LabKit Field Validator detects deprecated logging field names and helps
6
+ migrate them to standardized fields.
7
+ It supports the [Observability Field Standardisation initiative](https://handbook.gitlab.com/handbook/engineering/architecture/design-documents/observability_field_standardisation/).
6
8
 
7
- **Goal:** Standardize logging field names across GitLab so logs are queryable and actionable across all systems.
9
+ The validator intercepts logging calls in non-production environments, detects
10
+ deprecated fields, and compares them against a frozen baseline stored in
11
+ `.labkit_logging_todo.yml`.
12
+ New offenses raise an error. Known offenses are allowed.
8
13
 
9
- **How it works:** The validator intercepts logging calls during development and testing, detects deprecated fields, and compares them against a frozen baseline. New offenses fail CI; known offenses are tracked in `.labkit_logging_todo.yml`. The validator is **not** active in production environments.
14
+ For the architectural decision and rationale, see
15
+ [ADR: Dynamic Runtime Linting](./architecture/decisions/001_field_standardization_dynamic_runtime_linting.md).
10
16
 
11
- For the architectural decision and rationale, see [ADR: Dynamic Runtime Linting](./architecture/decisions/001_field_standardization_dynamic_runtime_linting.md).
17
+ ## Key concepts
12
18
 
13
- ## Key Concepts
19
+ Offense
20
+ : A unique combination of file path, deprecated field, and logger class.
21
+ Multiple log calls in the same file using the same deprecated field count as
22
+ one offense.
23
+ An offense exists until the deprecated field is entirely removed from the
24
+ file.
14
25
 
15
- **Offense**
16
- - A unique combination of [File Path] + [Deprecated Field] + [Logger Class]
17
- - Multiple log calls in the same file using the same deprecated field = 1 offense
18
- - Offenses exist until the deprecated field is entirely removed from the file
26
+ TODO Baseline
27
+ : The list of known offenses in `.labkit_logging_todo.yml`.
28
+ The baseline prevents regression while allowing incremental cleanup.
19
29
 
20
- **TODO Baseline**
21
- - A list of known offenses tracked in `.labkit_logging_todo.yml`
22
- - Existing offenses in this baseline are allowed
23
- - Any new offenses detected during development raise an error
24
- - Prevents regression while allowing incremental cleanup
30
+ ## Quick start
25
31
 
26
- ## Quick Start
32
+ 1. Initialize the todo file:
27
33
 
28
- ### First-Time Setup
29
-
30
- 1. **Initialize the todo file:**
31
-
32
- ```bash
34
+ ```shell
33
35
  bundle exec labkit-logging init
34
36
  ```
35
37
 
36
- This creates `.labkit_logging_todo.yml` with `skip_ci_failure: true`, which allows CI to pass while collecting the initial baseline.
38
+ This creates `.labkit_logging_todo.yml` with `skip_ci_failure: true`, which
39
+ allows CI to pass while outputting found offenses.
40
+ These are later collected to create the baseline.
37
41
 
38
- 2. **Commit and push:**
42
+ 1. Commit and push:
39
43
 
40
- ```bash
44
+ ```shell
41
45
  git add .labkit_logging_todo.yml
42
46
  git commit -m "Add LabKit logging todo baseline"
43
47
  git push
44
48
  ```
45
49
 
46
- 3. **Wait for CI to complete**, then fetch the baseline:
50
+ 1. Wait for CI to complete, then fetch the baseline:
47
51
 
48
- ```bash
52
+ ```shell
49
53
  bundle exec labkit-logging fetch <project> <pipeline_id>
50
54
  ```
51
55
 
52
56
  For example:
53
- ```bash
57
+
58
+ ```shell
54
59
  bundle exec labkit-logging fetch gitlab-org/gitlab 12345
55
60
  ```
56
61
 
57
- This fetches all detected offenses from the CI pipeline logs and populates the todo file. The `skip_ci_failure` flag is automatically removed.
62
+ This fetches detected offenses from CI pipeline logs and populates the todo
63
+ file.
64
+ The `skip_ci_failure` flag is automatically removed.
58
65
 
59
- 4. **Commit the populated baseline:**
66
+ 1. Commit the populated baseline:
60
67
 
61
- ```bash
68
+ ```shell
62
69
  git add .labkit_logging_todo.yml
63
70
  git commit -m "Populate LabKit logging todo baseline"
64
71
  git push
65
72
  ```
66
73
 
67
- Future CI runs will now enforce this baseline—new offenses will fail the pipeline.
74
+ Future CI runs enforce this baseline.
75
+ New offenses fail the pipeline.
68
76
 
69
- ## Developer Workflow
77
+ ## How to deprecate a field
70
78
 
71
- ### Fixing Offenses (Recommended)
79
+ 1. In `lib/labkit/fields.rb`, confirm the standard field constant exists in
80
+ `Labkit::Fields`. Add it if it does not exist:
72
81
 
73
- Replace deprecated fields with standard constants:
82
+ ```ruby
83
+ GL_PROJECT_ID = "gl_project_id"
84
+ ```
74
85
 
75
- ```ruby
76
- # Before
77
- logger.info(user_id: current_user.id)
86
+ 1. In the same file, add the deprecated names to
87
+ `Labkit::Fields::Deprecated::MAPPINGS`:
78
88
 
79
- # After
80
- logger.info(Labkit::Fields::GL_USER_ID => current_user.id)
81
- ```
89
+ ```ruby
90
+ Fields::GL_PROJECT_ID => %w[project_id projectid],
91
+ ```
82
92
 
83
- When you fix an offense, it's automatically removed from the baseline on the next test run. Run your tests locally to verify:
93
+ 1. Create a Kibana field alias in the relevant index patterns to map the
94
+ deprecated field to the standard field.
95
+ This ensures log queries continue to work during the migration period.
84
96
 
85
- ```bash
86
- LABKIT_LOGGING_TODO_UPDATE=true bundle exec rspec
87
- ```
97
+ 1. Release a new version of `labkit-ruby`.
88
98
 
89
- ### Adding Offenses Temporarily
99
+ 1. In each consumer repository (for example, `gitlab-org/gitlab`), the MR to
100
+ update `labkit-ruby` fails with new offenses.
101
+ To add these offenses to the baseline, run `fetch` against the failed
102
+ pipeline and push the updated baseline to the branch:
90
103
 
91
- If you can't fix an offense immediately, add it to the baseline:
104
+ ```shell
105
+ bundle exec labkit-logging fetch <project> <pipeline_id>
106
+ git add .labkit_logging_todo.yml
107
+ git commit -m "Add new deprecated field offenses to baseline"
108
+ git push
109
+ ```
92
110
 
93
- ```bash
94
- LABKIT_LOGGING_TODO_UPDATE=true bundle exec rspec
95
- ```
111
+ ## How to fix an offense
96
112
 
97
- This updates `.labkit_logging_todo.yml` with any new offenses found during the test run. Commit the updated file with your changes.
113
+ The field validator runs during any non-production process that exercises
114
+ logging code paths, including tests, local development, and CI pipelines.
115
+ When a log call uses the standard field instead of the deprecated field, the
116
+ validator detects the fix automatically and removes the offense from the
117
+ baseline.
98
118
 
99
- **Note:** Justify in your MR why you can't fix immediately. Keep the baseline as small as possible.
119
+ 1. Replace the deprecated field with the standard field constant.
100
120
 
101
- ### Regenerating the Baseline
121
+ 1. Remove the deprecated field entirely from each log call in the file.
122
+ Adding the new field is not enough. The old key must be deleted.
102
123
 
103
- To regenerate the entire baseline from scratch:
124
+ 1. Run any process that exercises the logging code path:
104
125
 
105
- ```bash
106
- rm .labkit_logging_todo.yml
107
- bundle exec labkit-logging init
108
- # Run CI, then:
109
- bundle exec labkit-logging fetch <project> <pipeline_id>
126
+ ```shell
127
+ bundle exec rspec
128
+ ```
129
+
130
+ The offense is automatically removed from `.labkit_logging_todo.yml`.
131
+
132
+ 1. Commit the updated baseline to complete the cleanup.
133
+
134
+ ### Example
135
+
136
+ ```ruby
137
+ # Before
138
+ logger.info(user_id: current_user.id)
139
+
140
+ # After
141
+ logger.info(Labkit::Fields::GL_USER_ID => current_user.id)
110
142
  ```
111
143
 
112
- ## CI Behavior
144
+ ### Add an offense to the baseline temporarily
113
145
 
114
- ### Baseline Generation Mode
146
+ If you cannot fix an offense immediately, add it to the baseline:
115
147
 
116
- When `skip_ci_failure: true` is set in the todo file:
148
+ ```shell
149
+ LABKIT_LOGGING_TODO_UPDATE=true bundle exec rspec
150
+ ```
117
151
 
118
- - CI passes even when deprecated fields are detected
119
- - Offenses are logged for collection via `labkit-logging fetch`
120
- - Use this mode only during initial setup
152
+ Commit the updated `.labkit_logging_todo.yml` with your changes.
153
+ Justify in your MR why you cannot fix the offense immediately.
121
154
 
122
- ### Enforcement Mode
155
+ ## CI behavior
156
+
157
+ When `skip_ci_failure: true` is set in the todo file, CI passes even when
158
+ deprecated fields are detected.
159
+ Offenses are logged for collection with `labkit-logging fetch`.
160
+ Use this mode only during initial setup or recreating the todo file.
123
161
 
124
162
  When `skip_ci_failure` is not set (normal operation):
125
163
 
126
- - **New offenses fail the pipeline** with a detailed error message
127
- - **Known offenses** (in the baseline) are allowed
128
- - **Fixed offenses** are automatically detected and can be removed from the baseline
164
+ - New offenses fail the pipeline.
165
+ - Known offenses in the baseline are allowed.
166
+ - Fixed offenses are detected automatically.
129
167
 
130
168
  Example CI failure output:
131
169
 
132
- ```
170
+ ```plaintext
133
171
  ================================================================================
134
172
  LabKit Logging Field Standardization: New Offenses Detected
135
173
  ================================================================================
@@ -139,93 +177,75 @@ app/models/project.rb:15: 'project_id' is deprecated. Use 'Labkit::Fields::GL_PR
139
177
 
140
178
  ================================================================================
141
179
  Total: 2 new offense(s) in 2 file(s)
142
- ================================================================================
143
- ```
144
-
145
- ### When Offenses Are Fixed
146
-
147
- When you fix offenses that were in the baseline, you'll see a message indicating which offenses were resolved. Update the baseline locally to remove them:
148
180
 
149
- ```bash
150
- LABKIT_LOGGING_TODO_UPDATE=true bundle exec rspec
151
- git add .labkit_logging_todo.yml
152
- git commit -m "Remove fixed logging offenses from baseline"
181
+ See https://gitlab.com/gitlab-org/ruby/gems/labkit-ruby/-/blob/master/doc/FIELD_STANDARDIZATION.md#new-offenses-detected
182
+ ================================================================================
153
183
  ```
154
184
 
155
- ## CLI Reference
156
-
157
- The `labkit-logging` command provides subcommands for managing the field validator.
185
+ ## CLI reference
158
186
 
159
- ```bash
187
+ ```shell
160
188
  bundle exec labkit-logging <command> [options]
161
189
  ```
162
190
 
163
- ### labkit-logging init
191
+ ### `labkit-logging init`
164
192
 
165
- Creates a new `.labkit_logging_todo.yml` file with `skip_ci_failure: true`.
193
+ Creates `.labkit_logging_todo.yml` with `skip_ci_failure: true`.
166
194
 
167
- ```bash
168
- bundle exec labkit-logging init
169
- ```
170
-
171
- ### labkit-logging fetch
195
+ ### `labkit-logging fetch`
172
196
 
173
197
  Fetches offense logs from a GitLab CI pipeline and updates the todo file.
174
198
 
175
- ```bash
199
+ ```shell
176
200
  bundle exec labkit-logging fetch <project> <pipeline_id>
177
201
  ```
178
202
 
179
- **Arguments:**
180
- - `project` - GitLab project ID or path (e.g., `278964` or `gitlab-org/gitlab`)
181
- - `pipeline_id` - CI pipeline ID number
203
+ - `project` - GitLab project ID or path (for example, `278964` or
204
+ `gitlab-org/gitlab`).
205
+ - `pipeline_id` - CI pipeline ID number.
206
+
207
+ ### Environment variables
182
208
 
183
- **Environment Variables:**
184
- - `GITLAB_TOKEN` - GitLab API token (required)
185
- - `CI_API_V4_URL` - GitLab API URL (default: `https://gitlab.com/api/v4`)
209
+ | Variable | Description |
210
+ |-----------------------------------|-----------------------------------------------------------|
211
+ | `LABKIT_LOGGING_TODO_UPDATE=true` | Update the baseline with new offenses (local development) |
212
+ | `GITLAB_TOKEN` | GitLab API token for `labkit-logging fetch` (required) |
213
+ | `CI_API_V4_URL` | GitLab API URL (default: `https://gitlab.com/api/v4`) |
186
214
 
187
- **Examples:**
215
+ ## Troubleshooting
188
216
 
189
- ```bash
190
- # Using project path
191
- bundle exec labkit-logging fetch gitlab-org/gitlab 12345
217
+ ### New offenses detected
192
218
 
193
- # Using project ID
194
- bundle exec labkit-logging fetch 278964 12345
195
- ```
219
+ The validator raises an error when code introduces a deprecated logging field
220
+ that is not in the baseline.
221
+ This can happen when you:
196
222
 
197
- ## Environment Variables
223
+ - Add a new log call that uses a deprecated field name.
224
+ - Update `labkit-ruby` to a version that deprecates a field your code uses.
198
225
 
199
- | Variable | Description |
200
- |----------|-------------|
201
- | `LABKIT_LOGGING_TODO_UPDATE=true` | Update the baseline with new offenses (local development) |
202
- | `GITLAB_TOKEN` | GitLab API token for fetching CI logs |
203
- | `CI_API_V4_URL` | GitLab API URL (defaults to gitlab.com) |
226
+ To resolve, either [fix the offense](#how-to-fix-an-offense) or
227
+ [add it to the baseline temporarily](#add-an-offense-to-the-baseline-temporarily).
204
228
 
205
- ## Troubleshooting
229
+ ### Offenses not detected
230
+
231
+ - Ensure `.labkit_logging_todo.yml` exists in your project root.
232
+ - Verify you are using `Labkit::Logging::JsonLogger`.
233
+ - Check you are logging with a Hash (not String).
234
+ - Verify the code path is executed during tests.
206
235
 
207
- **"New Offenses Detected" in CI**
208
- - Fix the deprecated fields in your code, or
209
- - Update the baseline locally: `LABKIT_LOGGING_TODO_UPDATE=true bundle exec rspec`
210
- - Commit the updated `.labkit_logging_todo.yml`
236
+ ### Pipeline not found when fetching
211
237
 
212
- **Offenses not detected**
213
- - Ensure `.labkit_logging_todo.yml` exists in your project root
214
- - Verify you're using `Labkit::Logging::JsonLogger`
215
- - Check you're logging with a Hash (not String)
216
- - Verify the code path is executed during tests
238
+ - Verify the project path or ID is correct.
239
+ - Ensure the pipeline has completed (not still running).
240
+ - Check your `GITLAB_TOKEN` has read access to the project.
217
241
 
218
- **Pipeline not found when fetching**
219
- - Verify the project path/ID is correct
220
- - Ensure the pipeline has completed (not still running)
221
- - Check your `GITLAB_TOKEN` has read access to the project
242
+ ### No offenses found in pipeline
222
243
 
223
- **No offenses found in pipeline**
224
- - Ensure `skip_ci_failure: true` was set during the CI run
225
- - Verify the pipeline ran tests that exercise the logging code
226
- - Check job logs are accessible with your token
244
+ - Ensure `skip_ci_failure: true` was set during the CI run.
245
+ - Verify the pipeline ran tests that exercise the logging code.
246
+ - Check job logs are accessible with your token.
227
247
 
228
- ## TODO File Format
248
+ ## TODO file format
229
249
 
230
250
  ```yaml
231
251
  # LabKit Logging Field Standardization TODO
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.bindir = "exe"
20
20
  spec.executables = %w[labkit-logging]
21
21
  spec.require_paths = ["lib"]
22
- spec.required_ruby_version = "~> 3.2"
22
+ spec.required_ruby_version = ">= 3.3", "< 5"
23
23
 
24
24
  # Please maintain alphabetical order for dependencies
25
25
  spec.add_runtime_dependency "actionpack", ">= 5.0.0", "< 8.1.0"
@@ -39,7 +39,7 @@ Gem::Specification.new do |spec|
39
39
 
40
40
  # Please maintain alphabetical order for dev dependencies
41
41
  spec.add_development_dependency "excon", "~> 0.78.1"
42
- spec.add_development_dependency "faraday", "~> 1.10.3"
42
+ spec.add_development_dependency "faraday", "~> 2.13"
43
43
  spec.add_development_dependency "gitlab-dangerfiles", "~> 2.11.0"
44
44
  spec.add_development_dependency "gitlab-styles", "~> 13.1"
45
45
  spec.add_development_dependency "grpc-tools", ">= 1.75"
@@ -66,6 +66,10 @@ module Labkit
66
66
  contexts.last
67
67
  end
68
68
 
69
+ def clear
70
+ Thread.current[:labkit_contexts] = nil
71
+ end
72
+
69
73
  def log_key(key)
70
74
  key = key.to_s
71
75
  return key if RAW_KEYS.include?(key)