Implement field validator in labkit-ruby
Summary
Implement a field validator in labkit-ruby to enforce logging field standards across GitLab services. This will prevent new deprecated or non-standard logging fields from being introduced into the codebase.
Background
GitLab is standardizing observability fields across all services to improve log correlation and analysis. See the Observability Field Standardisation design document for full context.
Proposed Solution
Add a runtime field validator to LabKit that:
-
Defines standard fields in
Labkit::Fieldsmodule - Tracks deprecated field mappings showing old field to new field relationships
- Validates logging fields automatically during RSpec test runs
- Reports violations at the end of test suite execution
Components
1. Standard Fields Definition
- Extend
Labkit::Fieldswith standard field constants - Add
Labkit::Fields::Deprecatedmodule with mappings
2. Field Validator
- Auto-inject into
JsonLoggerwhen RSpec is running - Collect violations during test execution
- Report all violations after test suite completes
- Fail CI if new violations are introduced (out of scope for this issue)
3. Configuration
- Allow list: standard fields in
Labkit::Fields - Any existing violations that acknowledged and version-controlled in a project's repository should also be "allowed", creating a frozen baseline pattern - additional violations found during CI (or local test runs) can then be immediately shown to a developer.
Edited by Doug Barrett