1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

fix: unknown in network view (#3069)

This commit is contained in:
Gastón Fournier 2023-02-08 16:50:42 +01:00 committed by GitHub
parent 7e46f0fb7a
commit 0f78c17adc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -32,12 +32,14 @@ interface INetworkApp {
type: string;
}
const asNetworkAppData = (result: RequestsPerSecondSchemaDataResultItem) => {
const asNetworkAppData = (
result: RequestsPerSecondSchemaDataResultItem & { label: string }
) => {
const values = (result.values || []) as ResultValue[];
const data = values.filter(value => isRecent(value));
const reqs = data.length ? parseFloat(data[data.length - 1][1]) : 0;
return {
label: unknownify(result.metric?.appName),
label: result.label,
reqs,
type: unknownify(result.metric?.endpoint?.split('/')[2]),
};
@ -59,7 +61,12 @@ const summingReqsByLabelAndType = (
const toGraphData = (metrics?: RequestsPerSecondSchema) => {
const results =
metrics?.data?.result?.filter(result => result?.metric?.appName) || [];
metrics?.data?.result
?.map(result => ({
...result,
label: unknownify(result.metric?.appName),
}))
.filter(result => result.label !== 'unknown') || [];
const aggregated = results
.map(asNetworkAppData)
.reduce(summingReqsByLabelAndType, {});