mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-02 22:13:12 +00:00
feat: add cpm4d + avg calculations (#241)
This commit is contained in:
parent
5cc913a332
commit
1be572a95f
@ -39,6 +39,7 @@ export enum Calculations {
|
|||||||
SecondToDay = "secondToDay",
|
SecondToDay = "secondToDay",
|
||||||
NanosecondToMillisecond = "nanosecondToMillisecond",
|
NanosecondToMillisecond = "nanosecondToMillisecond",
|
||||||
CPM5D = "cpm5d",
|
CPM5D = "cpm5d",
|
||||||
|
CPM5DAvg = "cpm5dAvg",
|
||||||
}
|
}
|
||||||
export enum sizeEnum {
|
export enum sizeEnum {
|
||||||
XS = "XS",
|
XS = "XS",
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
import { MetricQueryTypes, Calculations } from "./data";
|
import { MetricQueryTypes, Calculations } from "./data";
|
||||||
export function useListConfig(config: any, index: string) {
|
export function useListConfig(config: any, index: string) {
|
||||||
const i = Number(index);
|
const i = Number(index);
|
||||||
const types = [Calculations.Average, Calculations.ApdexAvg, Calculations.PercentageAvg];
|
const types = [Calculations.Average, Calculations.ApdexAvg, Calculations.PercentageAvg, Calculations.CPM5DAvg];
|
||||||
const calculation = config.metricConfig && config.metricConfig[i] && config.metricConfig[i].calculation;
|
const calculation = config.metricConfig && config.metricConfig[i] && config.metricConfig[i].calculation;
|
||||||
const isLinear =
|
const isLinear =
|
||||||
[MetricQueryTypes.ReadMetricsValues, MetricQueryTypes.ReadLabeledMetricsValues].includes(config.metricTypes[i]) &&
|
[MetricQueryTypes.ReadMetricsValues, MetricQueryTypes.ReadLabeledMetricsValues].includes(config.metricTypes[i]) &&
|
||||||
|
@ -290,7 +290,11 @@ export function usePodsSource(
|
|||||||
}
|
}
|
||||||
if (config.metricTypes[index] === MetricQueryTypes.ReadMetricsValues) {
|
if (config.metricTypes[index] === MetricQueryTypes.ReadMetricsValues) {
|
||||||
d[name] = {};
|
d[name] = {};
|
||||||
if ([Calculations.Average, Calculations.ApdexAvg, Calculations.PercentageAvg].includes(c.calculation)) {
|
if (
|
||||||
|
[Calculations.Average, Calculations.ApdexAvg, Calculations.PercentageAvg, Calculations.CPM5DAvg].includes(
|
||||||
|
c.calculation,
|
||||||
|
)
|
||||||
|
) {
|
||||||
d[name]["avg"] = calculateExp(resp.data[key].values.values, c);
|
d[name]["avg"] = calculateExp(resp.data[key].values.values, c);
|
||||||
}
|
}
|
||||||
d[name]["values"] = resp.data[key].values.values.map((val: { value: number }) => aggregation(val.value, c));
|
d[name]["values"] = resp.data[key].values.values.map((val: { value: number }) => aggregation(val.value, c));
|
||||||
@ -315,7 +319,11 @@ export function usePodsSource(
|
|||||||
if (!d[key]) {
|
if (!d[key]) {
|
||||||
d[key] = {};
|
d[key] = {};
|
||||||
}
|
}
|
||||||
if ([Calculations.Average, Calculations.ApdexAvg, Calculations.PercentageAvg].includes(c.calculation)) {
|
if (
|
||||||
|
[Calculations.Average, Calculations.ApdexAvg, Calculations.PercentageAvg, Calculations.CPM5DAvg].includes(
|
||||||
|
c.calculation,
|
||||||
|
)
|
||||||
|
) {
|
||||||
d[key]["avg"] = calculateExp(item.values.values, c);
|
d[key]["avg"] = calculateExp(item.values.values, c);
|
||||||
}
|
}
|
||||||
d[key]["values"] = values;
|
d[key]["values"] = values;
|
||||||
@ -369,6 +377,13 @@ function calculateExp(arr: { value: number }[], config: { calculation?: string }
|
|||||||
case Calculations.ApdexAvg:
|
case Calculations.ApdexAvg:
|
||||||
data = [(sum / arr.length / 10000).toFixed(2)];
|
data = [(sum / arr.length / 10000).toFixed(2)];
|
||||||
break;
|
break;
|
||||||
|
case Calculations.CPM5DAvg:
|
||||||
|
data = [
|
||||||
|
sum / arr.length / 100000 < 1 && sum / arr.length / 100000 !== 0
|
||||||
|
? (sum / arr.length / 100000).toFixed(5)
|
||||||
|
: (sum / arr.length / 100000).toFixed(2),
|
||||||
|
];
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
data = arr.map((d) => aggregation(d.value, config));
|
data = arr.map((d) => aggregation(d.value, config));
|
||||||
break;
|
break;
|
||||||
@ -416,6 +431,12 @@ export function aggregation(val: number, config: { calculation?: string }): numb
|
|||||||
case Calculations.NanosecondToMillisecond:
|
case Calculations.NanosecondToMillisecond:
|
||||||
data = (val / 1000 / 1000).toFixed(2);
|
data = (val / 1000 / 1000).toFixed(2);
|
||||||
break;
|
break;
|
||||||
|
case Calculations.ApdexAvg:
|
||||||
|
data = (val / 10000).toFixed(2);
|
||||||
|
break;
|
||||||
|
case Calculations.CPM5DAvg:
|
||||||
|
data = val / 100000 < 1 && val / 100000 !== 0 ? (val / 100000).toFixed(5) : (val / 100000).toFixed(2);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
data;
|
data;
|
||||||
break;
|
break;
|
||||||
|
@ -300,6 +300,7 @@ export const CalculationOpts = [
|
|||||||
{ label: "Apdex", value: "apdex" },
|
{ label: "Apdex", value: "apdex" },
|
||||||
{ label: "Avg-preview", value: "average" },
|
{ label: "Avg-preview", value: "average" },
|
||||||
{ label: "Percentage + Avg-preview", value: "percentageAvg" },
|
{ label: "Percentage + Avg-preview", value: "percentageAvg" },
|
||||||
|
{ label: "CPM5D + Avg-preview", value: "cpm5dAvg" },
|
||||||
{ label: "Apdex + Avg-preview", value: "apdexAvg" },
|
{ label: "Apdex + Avg-preview", value: "apdexAvg" },
|
||||||
{ label: "Byte to KB", value: "byteToKB" },
|
{ label: "Byte to KB", value: "byteToKB" },
|
||||||
{ label: "Byte to MB", value: "byteToMB" },
|
{ label: "Byte to MB", value: "byteToMB" },
|
||||||
|
Loading…
Reference in New Issue
Block a user