Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug 1886810 - Forbid (by lint) non-ping lifetimes for _distribution m… #689

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changelog

- NEW LINT: Forbid (via lint) non-ping lifetimes for `*_distribution` metrics ([bug 1886810](https://bugzilla.mozilla.org/show_bug.cgi?id=1886810))

## 14.0.1

- BUGFIX: Fix missing `ping_arg` in util.py ([#687](https://github.com/mozilla/glean_parser/pull/687))
Expand Down
16 changes: 16 additions & 0 deletions glean_parser/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,21 @@ def check_unknown_ping(
yield nit


def check_distribution_lifetime(
metric: metrics.Metric, parser_config: Dict[str, Any]
) -> LintGenerator:
"""*_distribution metrics should only be ping-lifetime, because otherwise
we will send the same samples more than once."""
if (
metric.type.endswith("_distribution")
and metric.lifetime != metrics.Lifetime.ping
):
yield (
"Distribution metrics ought to have ping lifetime. Otherwise, their"
" samples could be submitted multiple times."
)


# The checks that operate on an entire category of metrics:
# {NAME: (function, is_error)}
CATEGORY_CHECKS: Dict[
Expand Down Expand Up @@ -412,6 +427,7 @@ def check_unknown_ping(
"METRIC_ON_EVENTS_LIFETIME": (check_metric_on_events_lifetime, CheckType.error),
"UNEXPECTED_UNIT": (check_unexpected_unit, CheckType.warning),
"EMPTY_DATAREVIEW": (check_empty_datareview, CheckType.warning),
"DISTRIBUTION_NON_PING_LIFETIME": (check_distribution_lifetime, CheckType.error),
}


Expand Down
4 changes: 0 additions & 4 deletions tests/data/gecko.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ page.perf:
type: timing_distribution
gecko_datapoint: GV_PAGE_LOAD_MS
time_unit: millisecond
lifetime: application
description: >
A sample timing distribution metric exported from Gecko.
bugs:
Expand All @@ -24,7 +23,6 @@ page.perf:
type: timing_distribution
gecko_datapoint: GV_PAGE_RELOAD_MS
time_unit: millisecond
lifetime: application
description: >
Another sample timing distribution metric exported from Gecko.
bugs:
Expand Down Expand Up @@ -62,7 +60,6 @@ gfx.content.checkerboard:
type: timing_distribution
gecko_datapoint: CHECKERBOARD_DURATION
time_unit: millisecond
lifetime: application
description: >
A sample timing distribution metric exported from Gecko.
bugs:
Expand Down Expand Up @@ -121,7 +118,6 @@ non.gecko.metrics:
app_load_time:
type: timing_distribution
time_unit: millisecond
lifetime: application
description: >
A sample timing distribution that is not tied to a Gecko datapoint.
bugs:
Expand Down