Bug 1648696 - Look for metrics in send_if_empty pings (#197)
This commit is contained in:
Родитель
14e65c8163
Коммит
3c8de75d28
|
@ -5,6 +5,8 @@ History
|
|||
Unreleased
|
||||
----------
|
||||
|
||||
* BUGFIX: look for metrics in send_if_empty pings. Metrics for these kinds of pings were being ignored.
|
||||
|
||||
1.23.0 (2020-06-27)
|
||||
-------------------
|
||||
|
||||
|
|
2
Makefile
2
Makefile
|
@ -21,7 +21,7 @@ clean-build: ## remove build artifacts
|
|||
rm -fr dist/
|
||||
rm -fr .eggs/
|
||||
find . -name '*.egg-info' -exec rm -fr {} +
|
||||
find . -name '*.egg' -exec rm -f {} +
|
||||
find . -name '*.egg' -exec rm -fr {} +
|
||||
|
||||
clean-pyc: ## remove Python file artifacts
|
||||
find . -name '*.pyc' -exec rm -f {} +
|
||||
|
|
|
@ -168,13 +168,15 @@ def output_markdown(
|
|||
# the description
|
||||
if isinstance(obj, pings.Ping):
|
||||
custom_pings_cache[obj.name] = obj
|
||||
if obj.send_if_empty:
|
||||
# Pings that have `send_if_empty` set to true,
|
||||
# might not have any metrics. They need to at least have an
|
||||
# empty array of metrics to show up on the template.
|
||||
if obj.send_if_empty and not metrics_by_pings[obj.name]:
|
||||
metrics_by_pings[obj.name] = []
|
||||
elif obj.is_internal_metric():
|
||||
# This is an internal Glean metric, and we don't
|
||||
# want docs for it.
|
||||
continue
|
||||
else:
|
||||
|
||||
# If this is an internal Glean metric, and we don't
|
||||
# want docs for it.
|
||||
if isinstance(obj, metrics.Metric) and not obj.is_internal_metric():
|
||||
# If we get here, obj is definitely a metric we want
|
||||
# docs for.
|
||||
for ping_name in obj.send_in_pings:
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
# Any copyright is dedicated to the Public Domain.
|
||||
# https://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
---
|
||||
$schema: moz://mozilla.org/schemas/glean/metrics/1-0-0
|
||||
|
||||
telemetry:
|
||||
some_metric:
|
||||
type: uuid
|
||||
lifetime: ping
|
||||
description: >
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/1137353
|
||||
data_reviews:
|
||||
- http://example.com/reviews
|
||||
notification_emails:
|
||||
- CHANGE-ME@example.com
|
||||
send_in_pings:
|
||||
- custom-ping-might-be-empty
|
||||
expires: 2100-01-01
|
|
@ -181,3 +181,24 @@ def test_event_extra_keys_in_correct_order(tmpdir):
|
|||
r"<li>bob: three</li>"
|
||||
r"<li>charlie: one</li></ul>" in content
|
||||
)
|
||||
|
||||
|
||||
def test_send_if_empty_metrics(tmpdir):
|
||||
tmpdir = Path(str(tmpdir))
|
||||
|
||||
translate.translate(
|
||||
[
|
||||
ROOT / "data" / "send_if_empty_with_metrics.yaml",
|
||||
ROOT / "data" / "pings.yaml",
|
||||
],
|
||||
"markdown",
|
||||
tmpdir,
|
||||
{"namespace": "Foo"},
|
||||
)
|
||||
|
||||
assert set(x.name for x in tmpdir.iterdir()) == set(["metrics.md"])
|
||||
|
||||
# Make sure descriptions made it in
|
||||
with (tmpdir / "metrics.md").open("r", encoding="utf-8") as fd:
|
||||
content = fd.read()
|
||||
assert "Lorem ipsum dolor sit amet, consectetur adipiscing elit." in content
|
||||
|
|
Загрузка…
Ссылка в новой задаче