in glean/src/core/metrics/database.ts [372:399]
private processLabeledMetric(
snapshot: Metrics,
metricType: string,
metricId: string,
metricData: JSONValue
) {
const newType = `labeled_${metricType}`;
const idLabelSplit = metricId.split("/", 2);
const newId = idLabelSplit[0];
const label = idLabelSplit[1];
if (newType in snapshot && newId in snapshot[newType]) {
// Other labels were found for this metric. Do not throw them away.
const existingData = snapshot[newType][newId];
snapshot[newType][newId] = {
...(existingData as JSONObject),
[label]: metricData
};
} else {
// This is the first label for this metric.
snapshot[newType] = {
...snapshot[newType],
[newId]: {
[label]: metricData
}
};
}
}