Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Unreleased

- BREAKING CHANGE: Generate labeled {custom|memory|timing} distribution for mobile ([#857](https://github.com/mozilla/glean_parser/pull/857))
- Allow categories to have subcategories longer than 29 characters ([bug 2062403](https://bugzilla.mozilla.org/show_bug.cgi?id=2062403))

## 20.2.0
- Allow renaming of fields when serializing metrics ([mozilla/glean-dictionary#2309](https://github.com/mozilla/glean-dictionary/issues/2309))
Expand Down
2 changes: 1 addition & 1 deletion glean_parser/schemas/metrics.2-0-0.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ definitions:

dotted_snake_case:
type: string
pattern: "^[a-z_][a-z0-9_]{0,29}(\\.[a-z_][a-z0-9_]{0,29})*$"
pattern: "^[a-z_][a-z0-9_]{1,40}(\\.[a-z_][a-z0-9_]{1,39})*$"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we even need the upper limits here? It's correct I guess, but maybe overly complicated.
The total length is limited due to maxLength.
We want to express that:

  • Needs to start with a lower-case character (or _ for some reason!)
  • A dot is followed by an lower-case alphanumeric character (or _ again!)

Your changed regex btw disallows a previously alowed category of a.b

maxLength: 40

event_extra_key:
Expand Down
14 changes: 14 additions & 0 deletions tests/data/categories.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Any copyright is dedicated to the Public Domain.
# https://creativecommons.org/publicdomain/zero/1.0/

---
$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0

we_used_to_have_subcategory_length:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't have any "subcategory", by which I think you mean dot-separated parts.

Maybe additionally this file should list the edge-cases I mentioned above (a.b), an actual "subcategory" longer than 29 characters, ...

but_we_dont_any_more:
type: counter
expires: never
description: A test metric
bugs: [https://bugzil.la/2062403]
data_reviews: [https://www.example.com]
notification_emails: [glean-team@mozilla.com]
11 changes: 11 additions & 0 deletions tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1593,3 +1593,14 @@ def test_overriden_expire_epoch_must_be_valid(invalid_epoch):
list(all_metrics)

del os.environ["SOURCE_DATE_EPOCH"]


def test_categories():
"""Test the basics of parsing oddly-named-or-structured categories."""
all_metrics = parser.parse_objects(
[ROOT / "data" / "categories.yaml"],
config={"allow_reserved": False},
)

errs = list(all_metrics)
assert len(errs) == 0