Skip to content

Commit

Permalink
[7.9] [UI Metrics] Support multi-colon keys (elastic#76913) (elastic#…
Browse files Browse the repository at this point in the history
  • Loading branch information
afharo authored Sep 9, 2020
1 parent e36d2ca commit 69b3ba6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ describe('telemetry_ui_metric', () => {
{ id: 'testAppName:testKeyName1', attributes: { count: 3 } },
{ id: 'testAppName:testKeyName2', attributes: { count: 5 } },
{ id: 'testAppName2:testKeyName3', attributes: { count: 1 } },
{
id:
'kibana-user_agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:80.0) Gecko/20100101 Firefox/80.0',
attributes: { count: 1 },
},
],
total: 3,
} as any;
Expand All @@ -86,6 +91,12 @@ describe('telemetry_ui_metric', () => {
{ key: 'testKeyName2', value: 5 },
],
testAppName2: [{ key: 'testKeyName3', value: 1 }],
'kibana-user_agent': [
{
key: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:80.0) Gecko/20100101 Firefox/80.0',
value: 1,
},
],
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ export function registerUiMetricUsageCollector(
attributes: { count },
} = rawUiMetric;

const [appName, metricType] = id.split(':');
const [appName, ...metricType] = id.split(':');

const pair = { key: metricType, value: count };
const pair = { key: metricType.join(':'), value: count };
return {
...accum,
[appName]: [...(accum[appName] || []), pair],
Expand Down

0 comments on commit 69b3ba6

Please sign in to comment.