Skip to content

Commit

Permalink
fix: unknown in network view (#3069)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gastón Fournier committed Feb 8, 2023
1 parent 7e46f0f commit 0f78c17
Showing 1 changed file with 10 additions and 3 deletions.
Expand Up @@ -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]),
};
Expand All @@ -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, {});
Expand Down

0 comments on commit 0f78c17

Please sign in to comment.