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/).
The LabKit Field Validator detects deprecated logging field names and helps
migrate them to standardized fields.
It supports the [Observability Field Standardisation initiative](https://handbook.gitlab.com/handbook/engineering/architecture/design-documents/observability_field_standardisation/).
**Goal:** Standardize logging field names across GitLab so logs are queryable and actionable across all systems.
The validator intercepts logging calls in non-production environments, detects
deprecated fields, and compares them against a frozen baseline stored in
`.labkit_logging_todo.yml`.
New offenses raise an error. Known offenses are allowed.
**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.
For the architectural decision and rationale, see [ADR: Dynamic Runtime Linting](./architecture/decisions/001_field_standardization_dynamic_runtime_linting.md).
## Key concepts
## Key Concepts
Offense
: A unique combination of file path, deprecated field, and logger class.
Multiple log calls in the same file using the same deprecated field count as
one offense.
An offense exists until the deprecated field is entirely removed from the
file.
**Offense**
- A unique combination of [File Path] + [Deprecated Field] + [Logger Class]
- Multiple log calls in the same file using the same deprecated field = 1 offense
- Offenses exist until the deprecated field is entirely removed from the file
TODO Baseline
: The list of known offenses in `.labkit_logging_todo.yml`.
The baseline prevents regression while allowing incremental cleanup.
**TODO Baseline**
- A list of known offenses tracked in `.labkit_logging_todo.yml`
- Existing offenses in this baseline are allowed
- Any new offenses detected during development raise an error
- Prevents regression while allowing incremental cleanup
## Quick start
## Quick Start
1. Initialize the todo file:
### First-Time Setup
1.**Initialize the todo file:**
```bash
```shell
bundle exec labkit-logging init
```
This creates `.labkit_logging_todo.yml` with `skip_ci_failure: true`, which allows CI to pass while collecting the initial baseline.
This creates `.labkit_logging_todo.yml` with `skip_ci_failure: true`, which
allows CI to pass while outputting found offenses.
These are later collected to create the baseline.
2.**Commit and push:**
1. Commit and push:
```bash
```shell
git add .labkit_logging_todo.yml
git commit -m"Add LabKit logging todo baseline"
git push
```
3.**Wait for CI to complete**, then fetch the baseline:
1. Wait for CI to complete, then fetch the baseline:
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:
```bash
LABKIT_LOGGING_TODO_UPDATE=true bundle exec rspec
git add .labkit_logging_todo.yml
git commit -m "Remove fixed logging offenses from baseline"
See https://gitlab.com/gitlab-org/ruby/gems/labkit-ruby/-/blob/master/doc/FIELD_STANDARDIZATION.md#new-offenses-detected