Enforce that event lifetime is ping

This commit is contained in:
Michael Droettboom 2018-11-13 13:04:30 -05:00
Родитель 527d693af3
Коммит 19b0b62330
2 изменённых файлов: 30 добавлений и 2 удалений

Просмотреть файл

@ -1,4 +1,4 @@
$schema: http://json-schema.org/draft-06/schema#
$schema: http://json-schema.org/draft-07/schema#
title: Metrics
description: |
Schema for the metrics.yaml files for Mozilla's glean telemetry SDK.
@ -284,4 +284,13 @@ additionalProperties:
anyOf:
- $ref: "#/definitions/very_short_id"
additionalProperties:
$ref: "#/definitions/metric"
allOf:
- $ref: "#/definitions/metric"
- if:
properties:
type:
const: event
then:
properties:
lifetime:
const: ping

Просмотреть файл

@ -156,3 +156,22 @@ def test_required_denominator():
errors = list(all_metrics)
assert len(errors) == 1
assert 'denominator is required' in errors[0]
def test_event_must_be_ping_lifetime():
contents = [
{
'category': {
'metric': {
'type': 'event',
'lifetime': 'user'
},
},
},
]
contents = [util.add_required(x) for x in contents]
all_metrics = parser.parse_metrics(contents)
errors = list(all_metrics)
assert len(errors) == 1
assert "On instance['category']['metric']['lifetime']" in errors[0]