glean-parser 20.0.1__tar.gz → 20.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {glean_parser-20.0.1 → glean_parser-20.2.0}/PKG-INFO +1 -1
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/lint.py +2 -29
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/metrics.py +18 -5
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/util.py +12 -1
- {glean_parser-20.0.1 → glean_parser-20.2.0}/server_telemetry/sdk-metrics-compat.yaml +0 -8
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/conftest.py +0 -1
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test_lint.py +8 -6
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test_parser.py +143 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/.gitignore +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/AUTHORS.md +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/LICENSE +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/README.md +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/__init__.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/__main__.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/data_review.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/go_server.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/javascript.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/javascript_server.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/kotlin.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/markdown.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/parser.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/pings.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/python_server.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/ruby_server.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/rust.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/rust_server.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/rust_sym.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/schemas/metrics.1-0-0.schema.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/schemas/metrics.2-0-0.schema.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/schemas/pings.1-0-0.schema.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/schemas/pings.2-0-0.schema.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/schemas/tags.1-0-0.schema.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/swift.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/tags.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/templates/data_review.jinja2 +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/templates/go_server.jinja2 +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/templates/javascript.buildinfo.jinja2 +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/templates/javascript.jinja2 +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/templates/javascript_server.jinja2 +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/templates/kotlin.buildinfo.jinja2 +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/templates/kotlin.jinja2 +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/templates/markdown.jinja2 +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/templates/python_server.jinja2 +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/templates/qmldir.jinja2 +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/templates/ruby_server.jinja2 +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/templates/rust.jinja2 +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/templates/rust_server.jinja2 +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/templates/rust_sym.jinja2 +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/templates/swift.jinja2 +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/translate.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/translation_options.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/validate_ping.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/pyproject.toml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/server_telemetry/server-side-pings.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/all_metrics.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/all_pings.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/attribution.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/bad_attribution.yamlx +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/bad_ping.yamlx +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/core.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/custom_ping_no_event_metrics.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/custom_ping_no_event_pings.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/dual_labeled.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/dual_labeled_invalid.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/duplicate_labeled.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/duplicate_send_in_ping.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/empty.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/event_key_ordering.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/events_data_sensitivity.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/events_with_types.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/fxa-server-metrics.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/fxa-server-pings.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/go_server_custom_ping_only_metrics.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/go_server_custom_ping_only_pings.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/go_server_events_and_custom_ping_metrics.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/go_server_events_and_custom_ping_pings.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/go_server_events_only_metrics.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/go_server_labeled_boolean_metrics.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/go_server_metrics_unsupported.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/invalid-ping-names.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/invalid.yamlx +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/jwe.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/metric-with-tags.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/mixed-expirations.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/name_too_similar.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/object.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/old_event_api.yamlx +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/ordering.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/pings.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/python_server_metrics_unsupported.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/rate.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/redefined_category.yamlx +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/redefined_metric.yamlx +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/redefined_ping.yamlx +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/reserved_categories.yamlx +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/ruby_server_metrics_unsupported.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/ruby_server_pings_unsupported.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/rust_server_custom_ping_only_metrics.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/rust_server_custom_ping_only_pings.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/rust_server_events_and_custom_ping_metrics.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/rust_server_events_and_custom_ping_pings.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/rust_server_events_only_metrics.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/rust_server_metrics_unsupported.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/same_name_different_category.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/schema-violation.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/send_if_empty_with_metrics.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/server_custom_ping_only_compare.go +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/server_custom_ping_only_compare.rs +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/server_events_and_custom_ping_compare.go +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/server_events_and_custom_ping_compare.rs +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/server_events_compare.rb +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/server_events_only_compare.go +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/server_events_only_compare.rs +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/server_metrics_no_events_no_pings.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/server_metrics_with_event.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/server_pings.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/single_labeled.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/smaller.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/tags.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/telemetry_mirror.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/text.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/text_invalid.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/unknown_ping_used.yaml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/wrong_key.yamlx +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/yaml_nits.yamlx +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/detekt.yml +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test-go/test.go.tmpl +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test-go/test_publisher.go.tmpl +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test-js/package.json +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test-js/test.js.tmpl +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test-py/test.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test-rb/test.rb.tmpl +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test-rs/test.rs.tmpl +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test_cli.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test_go_server.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test_go_server_pubsub.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test_javascript.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test_javascript_server.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test_kotlin.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test_markdown.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test_metrics.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test_pings.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test_python_server.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test_ruby_server.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test_rust.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test_rust_server.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test_rust_sym.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test_swift.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test_tags.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test_translate.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test_utils.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/test_validate_ping.py +0 -0
- {glean_parser-20.0.1 → glean_parser-20.2.0}/tests/util.py +0 -0
|
@@ -84,34 +84,6 @@ def _hamming_distance(str1: str, str2: str) -> int:
|
|
|
84
84
|
return diffs
|
|
85
85
|
|
|
86
86
|
|
|
87
|
-
def check_common_prefix(
|
|
88
|
-
category_name: str, metrics: Iterable[metrics.Metric]
|
|
89
|
-
) -> LintGenerator:
|
|
90
|
-
"""
|
|
91
|
-
Check if all metrics begin with a common prefix.
|
|
92
|
-
"""
|
|
93
|
-
metric_words = sorted([_split_words(metric.name) for metric in metrics])
|
|
94
|
-
|
|
95
|
-
if len(metric_words) < 2:
|
|
96
|
-
return
|
|
97
|
-
|
|
98
|
-
first = metric_words[0]
|
|
99
|
-
last = metric_words[-1]
|
|
100
|
-
|
|
101
|
-
for i in range(min(len(first), len(last))):
|
|
102
|
-
if first[i] != last[i]:
|
|
103
|
-
break
|
|
104
|
-
|
|
105
|
-
if i > 0:
|
|
106
|
-
common_prefix = "_".join(first[:i])
|
|
107
|
-
yield (
|
|
108
|
-
f"Within category '{category_name}', all metrics begin with "
|
|
109
|
-
f"prefix '{common_prefix}'. "
|
|
110
|
-
"Remove the prefixes on the metric names and (possibly) "
|
|
111
|
-
"rename the category."
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
|
|
115
87
|
def check_unit_in_name(
|
|
116
88
|
metric: metrics.Metric, parser_config: Dict[str, Any]
|
|
117
89
|
) -> LintGenerator:
|
|
@@ -465,7 +437,8 @@ def check_name_too_similar(
|
|
|
465
437
|
CATEGORY_CHECKS: Dict[
|
|
466
438
|
str, Tuple[Callable[[str, Iterable[metrics.Metric]], LintGenerator], CheckType]
|
|
467
439
|
] = {
|
|
468
|
-
|
|
440
|
+
# Keeping it to not break when it is listed in `no_lint`
|
|
441
|
+
"COMMON_PREFIX": (noop, CheckType.error),
|
|
469
442
|
"CATEGORY_GENERIC": (check_category_generic, CheckType.error),
|
|
470
443
|
}
|
|
471
444
|
|
|
@@ -165,7 +165,9 @@ class Metric:
|
|
|
165
165
|
**metric_info,
|
|
166
166
|
)
|
|
167
167
|
|
|
168
|
-
def serialize(
|
|
168
|
+
def serialize(
|
|
169
|
+
self, rename_fields: Optional[Dict[str, str]] = None
|
|
170
|
+
) -> Dict[str, util.JSONType]:
|
|
169
171
|
"""
|
|
170
172
|
Serialize the metric back to JSON object model.
|
|
171
173
|
"""
|
|
@@ -178,6 +180,13 @@ class Metric:
|
|
|
178
180
|
d[key] = sorted(list(val))
|
|
179
181
|
if isinstance(val, list) and len(val) and isinstance(val[0], enum.Enum):
|
|
180
182
|
d[key] = [x.name for x in val]
|
|
183
|
+
|
|
184
|
+
if rename_fields is not None:
|
|
185
|
+
for key, val in rename_fields.items():
|
|
186
|
+
if key in d:
|
|
187
|
+
d[val] = d[key]
|
|
188
|
+
del d[key]
|
|
189
|
+
|
|
181
190
|
del d["name"]
|
|
182
191
|
del d["category"]
|
|
183
192
|
if not d["unit"]:
|
|
@@ -399,11 +408,13 @@ class Labeled(Metric):
|
|
|
399
408
|
self.labels = None
|
|
400
409
|
super().__init__(*args, **kwargs)
|
|
401
410
|
|
|
402
|
-
def serialize(
|
|
411
|
+
def serialize(
|
|
412
|
+
self, rename_fields: Optional[Dict[str, str]] = None
|
|
413
|
+
) -> Dict[str, util.JSONType]:
|
|
403
414
|
"""
|
|
404
415
|
Serialize the metric back to JSON object model.
|
|
405
416
|
"""
|
|
406
|
-
d = super().serialize()
|
|
417
|
+
d = super().serialize(rename_fields=rename_fields)
|
|
407
418
|
d["labels"] = self.ordered_labels
|
|
408
419
|
del d["ordered_labels"]
|
|
409
420
|
return d
|
|
@@ -604,11 +615,13 @@ class DualLabeledCounter(Metric):
|
|
|
604
615
|
self.categories = None
|
|
605
616
|
super().__init__(*args, **kwargs)
|
|
606
617
|
|
|
607
|
-
def serialize(
|
|
618
|
+
def serialize(
|
|
619
|
+
self, rename_fields: Optional[Dict[str, str]] = None
|
|
620
|
+
) -> Dict[str, util.JSONType]:
|
|
608
621
|
"""
|
|
609
622
|
Serialize the metric back to JSON object model.
|
|
610
623
|
"""
|
|
611
|
-
d = super().serialize()
|
|
624
|
+
d = super().serialize(rename_fields=rename_fields)
|
|
612
625
|
d["keys"] = self.ordered_keys
|
|
613
626
|
d["categories"] = self.ordered_categories
|
|
614
627
|
del d["ordered_keys"]
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
6
6
|
|
|
7
7
|
import datetime
|
|
8
|
+
import time
|
|
9
|
+
import os
|
|
8
10
|
import functools
|
|
9
11
|
import json
|
|
10
12
|
from pathlib import Path
|
|
@@ -412,6 +414,15 @@ def parse_expiration_version(expires: str) -> int:
|
|
|
412
414
|
)
|
|
413
415
|
|
|
414
416
|
|
|
417
|
+
def now_epoch():
|
|
418
|
+
try:
|
|
419
|
+
epoch_ts = int(os.environ.get("SOURCE_DATE_EPOCH", time.time()))
|
|
420
|
+
except ValueError:
|
|
421
|
+
raise ValueError("Invalid SOURCE_DATE_EPOCH")
|
|
422
|
+
|
|
423
|
+
return datetime.datetime.fromtimestamp(epoch_ts, tz=datetime.timezone.utc)
|
|
424
|
+
|
|
425
|
+
|
|
415
426
|
def is_expired(expires: str, major_version: Optional[int] = None) -> bool:
|
|
416
427
|
"""
|
|
417
428
|
Parses the `expires` field in a metric or ping and returns whether
|
|
@@ -425,7 +436,7 @@ def is_expired(expires: str, major_version: Optional[int] = None) -> bool:
|
|
|
425
436
|
return parse_expiration_version(expires) <= major_version
|
|
426
437
|
else:
|
|
427
438
|
date = parse_expiration_date(expires)
|
|
428
|
-
return date <=
|
|
439
|
+
return date <= now_epoch().date()
|
|
429
440
|
|
|
430
441
|
|
|
431
442
|
def validate_expires(expires: str, major_version: Optional[int] = None) -> None:
|
|
@@ -47,8 +47,6 @@ glean.error:
|
|
|
47
47
|
expires: never
|
|
48
48
|
send_in_pings:
|
|
49
49
|
- events
|
|
50
|
-
no_lint:
|
|
51
|
-
- COMMON_PREFIX
|
|
52
50
|
|
|
53
51
|
invalid_label:
|
|
54
52
|
type: labeled_counter
|
|
@@ -66,8 +64,6 @@ glean.error:
|
|
|
66
64
|
expires: never
|
|
67
65
|
send_in_pings:
|
|
68
66
|
- events
|
|
69
|
-
no_lint:
|
|
70
|
-
- COMMON_PREFIX
|
|
71
67
|
|
|
72
68
|
invalid_state:
|
|
73
69
|
type: labeled_counter
|
|
@@ -85,8 +81,6 @@ glean.error:
|
|
|
85
81
|
expires: never
|
|
86
82
|
send_in_pings:
|
|
87
83
|
- events
|
|
88
|
-
no_lint:
|
|
89
|
-
- COMMON_PREFIX
|
|
90
84
|
|
|
91
85
|
invalid_overflow:
|
|
92
86
|
type: labeled_counter
|
|
@@ -104,5 +98,3 @@ glean.error:
|
|
|
104
98
|
expires: never
|
|
105
99
|
send_in_pings:
|
|
106
100
|
- events
|
|
107
|
-
no_lint:
|
|
108
|
-
- COMMON_PREFIX
|
|
@@ -54,7 +54,6 @@ def pytest_collection_modifyitems(config, items):
|
|
|
54
54
|
subprocess.check_output(["node", "--version"]).decode("utf-8").strip()
|
|
55
55
|
)
|
|
56
56
|
major_version = int(node_version[1:].split(".")[0])
|
|
57
|
-
print(f"jer. {node_version=}, {major_version=}")
|
|
58
57
|
if major_version >= 24:
|
|
59
58
|
skip_node = pytest.mark.skip(reason="Node.js < v24 required")
|
|
60
59
|
for item in items:
|
|
@@ -20,6 +20,11 @@ ROOT = Path(__file__).parent
|
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
def test_common_prefix():
|
|
23
|
+
"""
|
|
24
|
+
The `COMMON_PREFIX` lint has been silenced.
|
|
25
|
+
This ensures we're not breaking anyone that lists it in `no_lint`
|
|
26
|
+
"""
|
|
27
|
+
|
|
23
28
|
contents = [
|
|
24
29
|
{
|
|
25
30
|
"telemetry": {
|
|
@@ -44,8 +49,7 @@ def test_common_prefix():
|
|
|
44
49
|
|
|
45
50
|
nits = lint.lint_metrics(all_metrics.value)
|
|
46
51
|
|
|
47
|
-
assert len(nits) ==
|
|
48
|
-
assert nits[0].check_name == "COMMON_PREFIX"
|
|
52
|
+
assert len(nits) == 0
|
|
49
53
|
|
|
50
54
|
# Now make sure the override works
|
|
51
55
|
contents[0]["no_lint"] = ["COMMON_PREFIX"]
|
|
@@ -149,10 +153,8 @@ def test_combined():
|
|
|
149
153
|
|
|
150
154
|
nits = lint.lint_metrics(all_metrics.value)
|
|
151
155
|
|
|
152
|
-
assert len(nits) ==
|
|
153
|
-
assert set(["
|
|
154
|
-
v.check_name for v in nits
|
|
155
|
-
)
|
|
156
|
+
assert len(nits) == 3
|
|
157
|
+
assert set(["CATEGORY_GENERIC", "UNIT_IN_NAME"]) == set(v.check_name for v in nits)
|
|
156
158
|
|
|
157
159
|
|
|
158
160
|
def test_baseline_restriction():
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
# http://creativecommons.org/publicdomain/zero/1.0/
|
|
5
5
|
|
|
6
6
|
from pathlib import Path
|
|
7
|
+
import datetime
|
|
7
8
|
import json
|
|
9
|
+
import os
|
|
8
10
|
import re
|
|
9
11
|
import textwrap
|
|
10
12
|
|
|
@@ -1134,6 +1136,88 @@ def test_no_lint_sorted():
|
|
|
1134
1136
|
assert all_objects.value["tags"]["tag"].no_lint == ["lint1", "lint2"]
|
|
1135
1137
|
|
|
1136
1138
|
|
|
1139
|
+
def test_allow_renaming_of_fields():
|
|
1140
|
+
results = parser.parse_objects(
|
|
1141
|
+
[
|
|
1142
|
+
util.add_required(
|
|
1143
|
+
{
|
|
1144
|
+
"category": {
|
|
1145
|
+
"metric": {
|
|
1146
|
+
"type": "object",
|
|
1147
|
+
"structure": {
|
|
1148
|
+
"type": "array",
|
|
1149
|
+
"items": {
|
|
1150
|
+
"type": "object",
|
|
1151
|
+
"properties": {
|
|
1152
|
+
"prop_a": {
|
|
1153
|
+
"type": "string",
|
|
1154
|
+
},
|
|
1155
|
+
"prop_b": {
|
|
1156
|
+
"type": "boolean",
|
|
1157
|
+
},
|
|
1158
|
+
},
|
|
1159
|
+
},
|
|
1160
|
+
},
|
|
1161
|
+
},
|
|
1162
|
+
},
|
|
1163
|
+
}
|
|
1164
|
+
),
|
|
1165
|
+
]
|
|
1166
|
+
)
|
|
1167
|
+
errs = list(results)
|
|
1168
|
+
assert len(errs) == 0
|
|
1169
|
+
|
|
1170
|
+
metrics = {
|
|
1171
|
+
metric.identifier(): metric.serialize(
|
|
1172
|
+
rename_fields={"_generate_structure": "structure"}
|
|
1173
|
+
)
|
|
1174
|
+
for category, probes in results.value.items()
|
|
1175
|
+
for probe_name, metric in probes.items()
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
expected = {
|
|
1179
|
+
"category.metric": {
|
|
1180
|
+
"bugs": ["http://bugzilla.mozilla.org/12345678"],
|
|
1181
|
+
"data_reviews": ["https://example.com/review/"],
|
|
1182
|
+
"defined_in": {"line": 3},
|
|
1183
|
+
"description": "DESCRIPTION...",
|
|
1184
|
+
"disabled": False,
|
|
1185
|
+
"expires": "never",
|
|
1186
|
+
"gecko_datapoint": "",
|
|
1187
|
+
"in_session": False,
|
|
1188
|
+
"lifetime": "ping",
|
|
1189
|
+
"metadata": {},
|
|
1190
|
+
"no_lint": [],
|
|
1191
|
+
"notification_emails": ["nobody@example.com"],
|
|
1192
|
+
"send_in_pings": ["metrics"],
|
|
1193
|
+
"type": "object",
|
|
1194
|
+
"version": 0,
|
|
1195
|
+
"structure": {
|
|
1196
|
+
"type": "array",
|
|
1197
|
+
"items": {
|
|
1198
|
+
"type": "object",
|
|
1199
|
+
"properties": {
|
|
1200
|
+
"prop_a": {
|
|
1201
|
+
"type": "string",
|
|
1202
|
+
},
|
|
1203
|
+
"prop_b": {
|
|
1204
|
+
"type": "boolean",
|
|
1205
|
+
},
|
|
1206
|
+
},
|
|
1207
|
+
},
|
|
1208
|
+
},
|
|
1209
|
+
},
|
|
1210
|
+
}
|
|
1211
|
+
expected_json = json.dumps(expected, sort_keys=True, indent=2)
|
|
1212
|
+
|
|
1213
|
+
out_json = json.dumps(
|
|
1214
|
+
metrics,
|
|
1215
|
+
sort_keys=True,
|
|
1216
|
+
indent=2,
|
|
1217
|
+
)
|
|
1218
|
+
assert expected_json == out_json
|
|
1219
|
+
|
|
1220
|
+
|
|
1137
1221
|
def test_no_internal_fields_exposed():
|
|
1138
1222
|
"""
|
|
1139
1223
|
We accidentally exposed fields like `_config` and `_generate_enums` before.
|
|
@@ -1450,3 +1534,62 @@ def test_forbid_non_ext_non_object_attribution_distribution():
|
|
|
1450
1534
|
"Extended attribution/distribution metrics must be of type 'object'"
|
|
1451
1535
|
in errors[1]
|
|
1452
1536
|
)
|
|
1537
|
+
|
|
1538
|
+
|
|
1539
|
+
def test_expire_epoch_can_be_overriden():
|
|
1540
|
+
metrics = [
|
|
1541
|
+
{
|
|
1542
|
+
"category": {
|
|
1543
|
+
"metric": {
|
|
1544
|
+
"type": "boolean",
|
|
1545
|
+
"expires": "2023-12-31", # definitely in the past
|
|
1546
|
+
},
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
]
|
|
1550
|
+
metrics = [util.add_required(x) for x in metrics]
|
|
1551
|
+
|
|
1552
|
+
all_metrics = parser.parse_objects(metrics)
|
|
1553
|
+
errors = list(all_metrics)
|
|
1554
|
+
assert len(errors) == 0
|
|
1555
|
+
assert all_metrics.value["category"]["metric"].disabled is True
|
|
1556
|
+
|
|
1557
|
+
# A date definitely before the above expiry.
|
|
1558
|
+
dt = datetime.datetime.strptime("2020-01-01", "%Y-%m-%d")
|
|
1559
|
+
os.environ["SOURCE_DATE_EPOCH"] = str(int(dt.timestamp()))
|
|
1560
|
+
|
|
1561
|
+
all_metrics = parser.parse_objects(metrics)
|
|
1562
|
+
errors = list(all_metrics)
|
|
1563
|
+
assert len(errors) == 0
|
|
1564
|
+
assert all_metrics.value["category"]["metric"].disabled is False
|
|
1565
|
+
|
|
1566
|
+
del os.environ["SOURCE_DATE_EPOCH"]
|
|
1567
|
+
|
|
1568
|
+
|
|
1569
|
+
@pytest.mark.parametrize(
|
|
1570
|
+
"invalid_epoch",
|
|
1571
|
+
[
|
|
1572
|
+
"not-a-date",
|
|
1573
|
+
"2020-01-01",
|
|
1574
|
+
"",
|
|
1575
|
+
],
|
|
1576
|
+
)
|
|
1577
|
+
def test_overriden_expire_epoch_must_be_valid(invalid_epoch):
|
|
1578
|
+
metrics = [
|
|
1579
|
+
{
|
|
1580
|
+
"category": {
|
|
1581
|
+
"metric": {
|
|
1582
|
+
"type": "boolean",
|
|
1583
|
+
"expires": "2023-12-31", # definitely in the past
|
|
1584
|
+
},
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
]
|
|
1588
|
+
metrics = [util.add_required(x) for x in metrics]
|
|
1589
|
+
|
|
1590
|
+
with pytest.raises(ValueError, match="Invalid SOURCE_DATE_EPOCH"):
|
|
1591
|
+
os.environ["SOURCE_DATE_EPOCH"] = invalid_epoch
|
|
1592
|
+
all_metrics = parser.parse_objects(metrics)
|
|
1593
|
+
list(all_metrics)
|
|
1594
|
+
|
|
1595
|
+
del os.environ["SOURCE_DATE_EPOCH"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{glean_parser-20.0.1 → glean_parser-20.2.0}/glean_parser/templates/javascript.buildinfo.jinja2
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/go_server_custom_ping_only_metrics.yaml
RENAMED
|
File without changes
|
{glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/go_server_custom_ping_only_pings.yaml
RENAMED
|
File without changes
|
{glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/go_server_events_and_custom_ping_metrics.yaml
RENAMED
|
File without changes
|
{glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/go_server_events_and_custom_ping_pings.yaml
RENAMED
|
File without changes
|
|
File without changes
|
{glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/go_server_labeled_boolean_metrics.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/python_server_metrics_unsupported.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/rust_server_custom_ping_only_metrics.yaml
RENAMED
|
File without changes
|
{glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/rust_server_custom_ping_only_pings.yaml
RENAMED
|
File without changes
|
|
File without changes
|
{glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/rust_server_events_and_custom_ping_pings.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/server_events_and_custom_ping_compare.go
RENAMED
|
File without changes
|
{glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/server_events_and_custom_ping_compare.rs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{glean_parser-20.0.1 → glean_parser-20.2.0}/tests/data/server_metrics_no_events_no_pings.yaml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|