Skip to content

Commit

Permalink
Allow using the quantityt metric type outside of Gecko
Browse files Browse the repository at this point in the history
  • Loading branch information
brizental committed Sep 7, 2020
1 parent ea85216 commit c620233
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Unreleased
* The `SUPERFLUOUS_NO_LINT` warning has been removed from the glinter. It likely did more harm than good, and makes it hard to make `metrics.yaml` files that pass across different versions of `glean_parser`.
* Expired metrics will now produce a linter warning, `EXPIRED_METRIC`.
* Expiry dates that are more than 730 days (~2 years) in the future will produce a linter warning, `EXPIRATION_DATE_TOO_FAR`.
* Allow using the Quantity metric type outside of Gecko.

1.28.3 (2020-07-28)
-------------------
Expand Down
3 changes: 3 additions & 0 deletions glean_parser/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ def extra_info(obj: Union[metrics.Metric, pings.Ping]) -> List[Tuple[str, str]]:
if isinstance(obj, metrics.Jwe):
extra_info.append(("decrypted_name", obj.decrypted_name))

if isinstance(obj, metrics.Quantity):
extra_info.append(("unit", obj.unit))

return extra_info


Expand Down
6 changes: 2 additions & 4 deletions glean_parser/schemas/metrics.1-0-0.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ definitions:
- `counter`: A numeric value that can only be incremented.
- `quantity`: A numeric value that is set directly. Only allowed for
metrics coming from GeckoView.
- `quantity`: A numeric value that is set directly.
- `timespan`: Represents a time interval. Additional properties:
`time_unit`.
Expand Down Expand Up @@ -548,12 +547,11 @@ additionalProperties:
type:
enum:
- custom_distribution
- quantity
then:
required:
- gecko_datapoint
description: |
`custom_distribution` and `quantity` is only allowed for Gecko
`custom_distribution` is only allowed for Gecko
metrics.
-
if:
Expand Down
3 changes: 1 addition & 2 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,11 +575,10 @@ def test_quantity():
contents = [util.add_required(x) for x in contents]
all_metrics = parser.parse_objects(contents)
errors = list(all_metrics)
assert len(errors) == 2
assert len(errors) == 1
assert any(
"`quantity` is missing required parameter `unit`" in err for err in errors
)
assert any("is only allowed for Gecko" in err for err in errors)

# Test that quantity works
contents = [
Expand Down

0 comments on commit c620233

Please sign in to comment.