Skip to content

Commit 6e109c8

Browse files
committed
Remove Geckoview Streaming helper code
This is not in use anymore. Last use removed in https://bugzilla.mozilla.org/show_bug.cgi?id=1877836 We don't remove support for _parsing_ `gecko_datapoint` to stay compatible with already existing old definition files.
1 parent 98fbc26 commit 6e109c8

File tree

5 files changed

+1
-456
lines changed

5 files changed

+1
-456
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Unreleased
44

55
- **Breaking change:** Updating Kotlin template import statement as part of removing `service-glean` from Android Components. ([bug 1906941](https://bugzilla.mozilla.org/show_bug.cgi?id=1906941))
6+
- **Breaking change:** Do not generate Geckoview Streaming helper code ([#743](https://github.com/mozilla/glean_parser/pull/743))
67

78
## 14.5.2
89

glean_parser/kotlin.py

Lines changed: 0 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
Outputter to generate Kotlin code for metrics.
99
"""
1010

11-
from collections import OrderedDict
1211
import enum
1312
import json
1413
from pathlib import Path
@@ -17,9 +16,7 @@
1716
from . import __version__
1817
from . import metrics
1918
from . import pings
20-
from . import tags
2119
from . import util
22-
from .util import DictWrapper
2320

2421

2522
def kotlin_datatypes_filter(value: util.JSONType) -> str:
@@ -179,105 +176,6 @@ def generate_build_date(date: Optional[str]) -> str:
179176
return f'Calendar.getInstance(TimeZone.getTimeZone("GMT+0")).also {{ cal -> cal.set({components}) }}' # noqa
180177

181178

182-
def output_gecko_lookup(
183-
objs: metrics.ObjectTree, output_dir: Path, options: Optional[Dict[str, Any]] = None
184-
) -> None:
185-
"""
186-
Given a tree of objects, generate a Kotlin map between Gecko histograms and
187-
Glean SDK metric types.
188-
189-
:param objects: A tree of objects (metrics and pings) as returned from
190-
`parser.parse_objects`.
191-
:param output_dir: Path to an output directory to write to.
192-
:param options: options dictionary, with the following optional keys:
193-
194-
- `namespace`: The package namespace to declare at the top of the
195-
generated files. Defaults to `GleanMetrics`.
196-
- `glean_namespace`: The package namespace of the glean library itself.
197-
This is where glean objects will be imported from in the generated
198-
code.
199-
"""
200-
if options is None:
201-
options = {}
202-
203-
template = util.get_jinja2_template(
204-
"kotlin.geckoview.jinja2",
205-
filters=(
206-
("kotlin", kotlin_datatypes_filter),
207-
("type_name", type_name),
208-
("class_name", class_name),
209-
),
210-
)
211-
212-
namespace = options.get("namespace", "GleanMetrics")
213-
glean_namespace = options.get("glean_namespace", "mozilla.components.service.glean")
214-
215-
# Build a dictionary that contains data for metrics that are
216-
# histogram-like/scalar-like and contain a gecko_datapoint, with this format:
217-
#
218-
# {
219-
# "histograms": {
220-
# "category": [
221-
# {"gecko_datapoint": "the-datapoint", "name": "the-metric-name"},
222-
# ...
223-
# ],
224-
# ...
225-
# },
226-
# "other-type": {}
227-
# }
228-
gecko_metrics: Dict[str, Dict[str, List[Dict[str, str]]]] = DictWrapper()
229-
230-
# Define scalar-like types.
231-
SCALAR_LIKE_TYPES = ["boolean", "string", "quantity"]
232-
233-
for category_key, category_val in objs.items():
234-
# Support exfiltration of Gecko metrics from products using both the
235-
# Glean SDK and GeckoView. See bug 1566356 for more context.
236-
for metric in category_val.values():
237-
# This is not a Gecko metric, skip it.
238-
if (
239-
isinstance(metric, pings.Ping)
240-
or isinstance(metric, tags.Tag)
241-
or not getattr(metric, "gecko_datapoint", False)
242-
):
243-
continue
244-
245-
# Put scalars in their own categories, histogram-like in "histograms" and
246-
# categorical histograms in "categoricals".
247-
type_category = "histograms"
248-
if metric.type in SCALAR_LIKE_TYPES:
249-
type_category = metric.type
250-
elif metric.type == "labeled_counter":
251-
# Labeled counters with a 'gecko_datapoint' property
252-
# are categorical histograms.
253-
type_category = "categoricals"
254-
255-
gecko_metrics.setdefault(type_category, OrderedDict())
256-
gecko_metrics[type_category].setdefault(category_key, [])
257-
258-
gecko_metrics[type_category][category_key].append(
259-
{"gecko_datapoint": metric.gecko_datapoint, "name": metric.name}
260-
)
261-
262-
if not gecko_metrics:
263-
# Bail out and don't create a file if no gecko metrics
264-
# are found.
265-
return
266-
267-
filepath = output_dir / "GleanGeckoMetricsMapping.kt"
268-
with filepath.open("w", encoding="utf-8") as fd:
269-
fd.write(
270-
template.render(
271-
parser_version=__version__,
272-
gecko_metrics=gecko_metrics,
273-
namespace=namespace,
274-
glean_namespace=glean_namespace,
275-
)
276-
)
277-
# Jinja2 squashes the final newline, so we explicitly add it
278-
fd.write("\n")
279-
280-
281179
def output_kotlin(
282180
objs: metrics.ObjectTree, output_dir: Path, options: Optional[Dict[str, Any]] = None
283181
) -> None:
@@ -376,6 +274,3 @@ def output_kotlin(
376274
)
377275
# Jinja2 squashes the final newline, so we explicitly add it
378276
fd.write("\n")
379-
380-
# TODO: Maybe this should just be a separate outputter?
381-
output_gecko_lookup(objs, output_dir, options)

glean_parser/templates/kotlin.geckoview.jinja2

Lines changed: 0 additions & 124 deletions
This file was deleted.

tests/data/gecko.yaml

Lines changed: 0 additions & 133 deletions
This file was deleted.

0 commit comments

Comments
 (0)