Skip to content

Commit 64a9726

Browse files
committed
bug 1685406 - Add telemetry_mirror optional field to metrics schema
1 parent c4fb43b commit 64a9726

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

glean_parser/metrics.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def __init__(
5757
no_lint: Optional[List[str]] = None,
5858
data_sensitivity: Optional[List[str]] = None,
5959
defined_in: Optional[Dict] = None,
60+
telemetry_mirror: Optional[str] = None,
6061
_config: Dict[str, Any] = None,
6162
_validated: bool = False,
6263
):
@@ -90,6 +91,8 @@ def __init__(
9091
getattr(DataSensitivity, x) for x in data_sensitivity
9192
]
9293
self.defined_in = defined_in
94+
if telemetry_mirror is not None:
95+
self.telemetry_mirror = telemetry_mirror
9396

9497
# _validated indicates whether this metric has already been jsonschema
9598
# validated (but not any of the Python-level validation).

glean_parser/schemas/metrics.2-0-0.schema.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,18 @@ definitions:
467467
minLength: 1
468468
uniqueItems: true
469469

470+
telemetry_mirror:
471+
title: Which probe in Telemetry to mirror this metric's value to.
472+
description: |
473+
The C++ enum form of the Scalar, Event, or Histogram to which we
474+
should mirror values.
475+
Use is limited to Firefox Desktop only.
476+
Has no effect when used with non-FOG outputters.
477+
See FOG's documentation on mirroring for details -
478+
https://firefox-source-docs.mozilla.org/toolkit/components/glean/mirroring.html
479+
type: string
480+
minLength: 6
481+
470482
required:
471483
- type
472484
- bugs

tests/data/telemetry_mirror.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Any copyright is dedicated to the Public Domain.
2+
# https://creativecommons.org/publicdomain/zero/1.0/
3+
4+
---
5+
$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0
6+
7+
telemetry.mirrored:
8+
parses_fine:
9+
type: string
10+
lifetime: application
11+
description: >
12+
Test metric to ensure telemetry_mirror properties parse.
13+
bugs:
14+
- https://bugzilla.mozilla.org/show_bug.cgi?id=1685406
15+
data_reviews:
16+
- https://bugzilla.mozilla.org/show_bug.cgi?id=1685406#c1
17+
notification_emails:
18+
- CHANGE-ME@example.com
19+
expires: never
20+
telemetry_mirror: telemetry.test.string_kind

tests/test_parser.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,3 +628,22 @@ def test_historical_versions():
628628

629629
errors = list(all_metrics)
630630
assert len(errors) == 1
631+
632+
633+
def test_telemetry_mirror():
634+
"""
635+
Ensure that telemetry_mirror makes it into the parsed metric definition.
636+
"""
637+
638+
all_metrics = parser.parse_objects(
639+
[ROOT / "data" / "telemetry_mirror.yaml"],
640+
config={"allow_reserved": False},
641+
)
642+
643+
errs = list(all_metrics)
644+
assert len(errs) == 0
645+
646+
assert (
647+
all_metrics.value["telemetry.mirrored"]["parses_fine"].telemetry_mirror
648+
== "telemetry.test.string_kind"
649+
)

0 commit comments

Comments
 (0)