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:

  1. Defines standard fields in Labkit::Fields module
  2. Tracks deprecated field mappings showing old field to new field relationships
  3. Validates logging fields automatically during RSpec test runs
  4. Reports violations at the end of test suite execution

Components

1. Standard Fields Definition

  • Extend Labkit::Fields with standard field constants
  • Add Labkit::Fields::Deprecated module with mappings

2. Field Validator

  • Auto-inject into JsonLogger when 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