mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-20 00:08:02 +01:00
fix: fix variant metrics (#3947)
This commit is contained in:
parent
dbb95ceed4
commit
ea21c753bd
@ -108,3 +108,54 @@ test('collapseHourlyMetrics', () => {
|
|||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('collapseHourlyMetrics variants', () => {
|
||||||
|
const timestamp = startOfHour(new Date());
|
||||||
|
|
||||||
|
const metricsWithoutVariant: IClientMetricsEnv = {
|
||||||
|
featureName: 'a',
|
||||||
|
appName: 'x',
|
||||||
|
environment: 'x',
|
||||||
|
timestamp: addMinutes(timestamp, 1),
|
||||||
|
yes: 1,
|
||||||
|
no: 11,
|
||||||
|
};
|
||||||
|
|
||||||
|
const metricsWithVariant1: IClientMetricsEnv = {
|
||||||
|
featureName: 'a',
|
||||||
|
appName: 'x',
|
||||||
|
environment: 'x',
|
||||||
|
timestamp: addMinutes(timestamp, 2),
|
||||||
|
yes: 2,
|
||||||
|
no: 12,
|
||||||
|
variants: { disabled: 3, red: 2 },
|
||||||
|
};
|
||||||
|
|
||||||
|
const metricsWithVariant2: IClientMetricsEnv = {
|
||||||
|
featureName: 'a',
|
||||||
|
appName: 'x',
|
||||||
|
environment: 'x',
|
||||||
|
timestamp: addMinutes(timestamp, 2),
|
||||||
|
yes: 2,
|
||||||
|
no: 12,
|
||||||
|
variants: { disabled: 1, red: 3 },
|
||||||
|
};
|
||||||
|
|
||||||
|
expect(
|
||||||
|
collapseHourlyMetrics([
|
||||||
|
metricsWithoutVariant,
|
||||||
|
metricsWithVariant1,
|
||||||
|
metricsWithVariant2,
|
||||||
|
]),
|
||||||
|
).toEqual([
|
||||||
|
{
|
||||||
|
featureName: 'a',
|
||||||
|
appName: 'x',
|
||||||
|
environment: 'x',
|
||||||
|
timestamp,
|
||||||
|
yes: 5,
|
||||||
|
no: 35,
|
||||||
|
variants: { disabled: 4, red: 5 },
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
@ -51,7 +51,7 @@ export const collapseHourlyMetrics = (
|
|||||||
if (metric.variants) {
|
if (metric.variants) {
|
||||||
grouped[key].variants = mergeRecords(
|
grouped[key].variants = mergeRecords(
|
||||||
metric.variants,
|
metric.variants,
|
||||||
grouped[key].variants,
|
grouped[key].variants ?? {},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user