Reject undefined properties in metric definitions
Currently, if you add a field like junky_junky_junk
to a metric definition in config/metrics
, the metric will be considered valid against the defined json schema.
- Update
json_schemer
from 0.2.18 to 2.0.0+ [relevant changelog] -
Combine
config/metrics/schema/
into a single schema & validateMetricDefinition
against just that schema - Add
unevaluatedProperties: false
instead [json-schema specification] toconfig/metrics/schema/base.json
EX)
"allOf": [
{ "$ref": "internal_events.json" },
{ "$ref": "redis_hll.json" },
{ "$ref": "redis.json" },
{ "$ref": "status.json" }
],
"unevaluatedProperties": false
Testing
To test whether schema changes are successful:
- Open rails console
- Modify a definition in
config/metrics/
with whatever properties you want to test - Run
Gitlab::Usage::MetricDefinition.definitions.each_value(&:validate!)
- Output should include no errors
Edited by Sarah Yasonik