mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-01 22:39:48 +00:00
update topology processor
This commit is contained in:
parent
69a1b5cb60
commit
64c541a15c
@ -17,6 +17,7 @@
|
|||||||
import { RespFields, MaximumEntities, MaxQueryLength } from "./data";
|
import { RespFields, MaximumEntities, MaxQueryLength } from "./data";
|
||||||
import { EntityType, ExpressionResultType } from "@/views/dashboard/data";
|
import { EntityType, ExpressionResultType } from "@/views/dashboard/data";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
|
import { useTopologyStore } from "@/store/modules/topology";
|
||||||
import { useDashboardStore } from "@/store/modules/dashboard";
|
import { useDashboardStore } from "@/store/modules/dashboard";
|
||||||
import { useSelectorStore } from "@/store/modules/selectors";
|
import { useSelectorStore } from "@/store/modules/selectors";
|
||||||
import { useAppStoreWithOut } from "@/store/modules/app";
|
import { useAppStoreWithOut } from "@/store/modules/app";
|
||||||
@ -391,11 +392,11 @@ export async function useExpressionsQueryPodsMetrics(
|
|||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function useQueryTopologyExpressionsProcessor(metrics: string[], instances: (Call | Node)[]) {
|
export function useQueryTopologyExpressionsProcessor(metrics: string[], instances: (Call | Node)[]) {
|
||||||
const appStore = useAppStoreWithOut();
|
const appStore = useAppStoreWithOut();
|
||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
|
|
||||||
function getExpressionQuery(partMetrics: string[]) {
|
function getExpressionQuery(partMetrics?: string[]) {
|
||||||
const conditions: { [key: string]: unknown } = {
|
const conditions: { [key: string]: unknown } = {
|
||||||
duration: appStore.durationTime,
|
duration: appStore.durationTime,
|
||||||
};
|
};
|
||||||
@ -449,7 +450,7 @@ export async function useQueryTopologyExpressionsProcessor(metrics: string[], in
|
|||||||
};
|
};
|
||||||
variables.push(`$entity${index}: Entity!`);
|
variables.push(`$entity${index}: Entity!`);
|
||||||
conditions[`entity${index}`] = entity;
|
conditions[`entity${index}`] = entity;
|
||||||
const f = partMetrics.map((name: string, idx: number) => {
|
const f = (partMetrics || metrics).map((name: string, idx: number) => {
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
variables.push(`$expression${idx}: String!`);
|
variables.push(`$expression${idx}: String!`);
|
||||||
conditions[`expression${idx}`] = name;
|
conditions[`expression${idx}`] = name;
|
||||||
@ -483,19 +484,31 @@ export async function useQueryTopologyExpressionsProcessor(metrics: string[], in
|
|||||||
}
|
}
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
async function fetchMetrics(partMetrics: string[]) {
|
||||||
const count = Math.floor(MaxQueryLength / instances.length);
|
const topologyStore = useTopologyStore();
|
||||||
const metricsArr = chunkArray(metrics, count);
|
const param = getExpressionQuery(partMetrics);
|
||||||
const promiseArr = metricsArr.map((d: Array<string>) => getExpressionQuery(d));
|
const res = await topologyStore.getTopologyExpressionValue(param);
|
||||||
const responseList = await Promise.all(promiseArr);
|
if (res.errors) {
|
||||||
|
ElMessage.error(res.errors);
|
||||||
let resp = {};
|
return;
|
||||||
for (const item of responseList) {
|
}
|
||||||
resp = {
|
return handleExpressionValues(res.data);
|
||||||
...resp,
|
|
||||||
...item,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { getExpressionQuery, handleExpressionValues };
|
async function getMetrics() {
|
||||||
|
const count = Math.floor(MaxQueryLength / instances.length);
|
||||||
|
const metricsArr = chunkArray(metrics, count);
|
||||||
|
const promiseArr = metricsArr.map((d: string[]) => fetchMetrics(d));
|
||||||
|
const responseList = await Promise.all(promiseArr);
|
||||||
|
let resp = {};
|
||||||
|
for (const item of responseList) {
|
||||||
|
resp = {
|
||||||
|
...resp,
|
||||||
|
...item,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return resp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return { getMetrics, getExpressionQuery };
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@ import { useAppStoreWithOut } from "@/store/modules/app";
|
|||||||
import type { AxiosResponse } from "axios";
|
import type { AxiosResponse } from "axios";
|
||||||
import query from "@/graphql/fetch";
|
import query from "@/graphql/fetch";
|
||||||
import { useQueryTopologyExpressionsProcessor } from "@/hooks/useExpressionsProcessor";
|
import { useQueryTopologyExpressionsProcessor } from "@/hooks/useExpressionsProcessor";
|
||||||
import { ElMessage } from "element-plus";
|
|
||||||
|
|
||||||
interface MetricVal {
|
interface MetricVal {
|
||||||
[key: string]: { values: { id: string; value: unknown }[] };
|
[key: string]: { values: { id: string; value: unknown }[] };
|
||||||
@ -443,7 +442,7 @@ export const topologyStore = defineStore({
|
|||||||
|
|
||||||
return { calls, nodes };
|
return { calls, nodes };
|
||||||
},
|
},
|
||||||
async getNodeExpressionValue(param: { queryStr: string; conditions: { [key: string]: unknown } }) {
|
async getTopologyExpressionValue(param: { queryStr: string; conditions: { [key: string]: unknown } }) {
|
||||||
const res: AxiosResponse = await query(param);
|
const res: AxiosResponse = await query(param);
|
||||||
|
|
||||||
if (res.data.errors) {
|
if (res.data.errors) {
|
||||||
@ -461,14 +460,8 @@ export const topologyStore = defineStore({
|
|||||||
if (!calls.length) {
|
if (!calls.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { getExpressionQuery, handleExpressionValues } = useQueryTopologyExpressionsProcessor(expressions, calls);
|
const { getMetrics } = useQueryTopologyExpressionsProcessor(expressions, calls);
|
||||||
const param = getExpressionQuery();
|
const metrics = await getMetrics();
|
||||||
const res = await this.getNodeExpressionValue(param);
|
|
||||||
if (res.errors) {
|
|
||||||
ElMessage.error(res.errors);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const metrics = handleExpressionValues(res.data);
|
|
||||||
if (type === "SERVER") {
|
if (type === "SERVER") {
|
||||||
this.setLinkServerMetrics(metrics);
|
this.setLinkServerMetrics(metrics);
|
||||||
} else {
|
} else {
|
||||||
@ -484,17 +477,11 @@ export const topologyStore = defineStore({
|
|||||||
this.setNodeMetricValue({});
|
this.setNodeMetricValue({});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { getExpressionQuery, handleExpressionValues } = useQueryTopologyExpressionsProcessor(
|
const { getMetrics } = useQueryTopologyExpressionsProcessor(
|
||||||
expressions,
|
expressions,
|
||||||
this.nodes.filter((d: Node) => d.isReal),
|
this.nodes.filter((d: Node) => d.isReal),
|
||||||
);
|
);
|
||||||
const param = getExpressionQuery();
|
const metrics = await getMetrics();
|
||||||
const res = await this.getNodeExpressionValue(param);
|
|
||||||
if (res.errors) {
|
|
||||||
ElMessage.error(res.errors);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const metrics = handleExpressionValues(res.data);
|
|
||||||
this.setNodeMetricValue(metrics);
|
this.setNodeMetricValue(metrics);
|
||||||
},
|
},
|
||||||
async getHierarchyServiceTopology() {
|
async getHierarchyServiceTopology() {
|
||||||
@ -550,17 +537,6 @@ export const topologyStore = defineStore({
|
|||||||
this.setHierarchyInstanceTopology(res.data.data.hierarchyInstanceTopology || {}, levels);
|
this.setHierarchyInstanceTopology(res.data.data.hierarchyInstanceTopology || {}, levels);
|
||||||
return res.data;
|
return res.data;
|
||||||
},
|
},
|
||||||
async queryHierarchyExpressions(expressions: string[], nodes: Node[]) {
|
|
||||||
const { getExpressionQuery, handleExpressionValues } = useQueryTopologyExpressionsProcessor(expressions, nodes);
|
|
||||||
const param = getExpressionQuery();
|
|
||||||
const res = await this.getNodeExpressionValue(param);
|
|
||||||
if (res.errors) {
|
|
||||||
ElMessage.error(res.errors);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const metrics = handleExpressionValues(res.data);
|
|
||||||
return metrics;
|
|
||||||
},
|
|
||||||
async queryHierarchyNodeExpressions(expressions: string[], layer: string) {
|
async queryHierarchyNodeExpressions(expressions: string[], layer: string) {
|
||||||
const nodes = this.hierarchyServiceNodes.filter((n: HierarchyNode) => n.layer === layer);
|
const nodes = this.hierarchyServiceNodes.filter((n: HierarchyNode) => n.layer === layer);
|
||||||
if (!nodes.length) {
|
if (!nodes.length) {
|
||||||
@ -571,7 +547,8 @@ export const topologyStore = defineStore({
|
|||||||
this.setHierarchyNodeMetricValue({}, layer);
|
this.setHierarchyNodeMetricValue({}, layer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const metrics = await this.queryHierarchyExpressions(expressions, nodes);
|
const { getMetrics } = useQueryTopologyExpressionsProcessor(expressions, nodes);
|
||||||
|
const metrics = await getMetrics();
|
||||||
this.setHierarchyNodeMetricValue(metrics, layer);
|
this.setHierarchyNodeMetricValue(metrics, layer);
|
||||||
},
|
},
|
||||||
async queryHierarchyInstanceNodeExpressions(expressions: string[], layer: string) {
|
async queryHierarchyInstanceNodeExpressions(expressions: string[], layer: string) {
|
||||||
@ -585,7 +562,8 @@ export const topologyStore = defineStore({
|
|||||||
this.setHierarchyInstanceNodeMetricValue({}, layer);
|
this.setHierarchyInstanceNodeMetricValue({}, layer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const metrics = await this.queryHierarchyExpressions(expressions, nodes);
|
const { getMetrics } = useQueryTopologyExpressionsProcessor(expressions, nodes);
|
||||||
|
const metrics = await getMetrics();
|
||||||
this.setHierarchyInstanceNodeMetricValue(metrics, layer);
|
this.setHierarchyInstanceNodeMetricValue(metrics, layer);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -244,12 +244,12 @@ limitations under the License. -->
|
|||||||
async function setLegend() {
|
async function setLegend() {
|
||||||
updateSettings();
|
updateSettings();
|
||||||
const expression = dashboardStore.selectedGrid.legendMQE && dashboardStore.selectedGrid.legendMQE.expression;
|
const expression = dashboardStore.selectedGrid.legendMQE && dashboardStore.selectedGrid.legendMQE.expression;
|
||||||
const { getExpressionQuery } = useQueryTopologyExpressionsProcessor(
|
const { getExpressionQuery } = await useQueryTopologyExpressionsProcessor(
|
||||||
[expression],
|
[expression],
|
||||||
topologyStore.nodes.filter((d: Node) => d.isReal),
|
topologyStore.nodes.filter((d: Node) => d.isReal),
|
||||||
);
|
);
|
||||||
const param = getExpressionQuery();
|
const param = getExpressionQuery();
|
||||||
const res = await topologyStore.getNodeExpressionValue(param);
|
const res = await topologyStore.getTopologyExpressionValue(param);
|
||||||
if (res.errors) {
|
if (res.errors) {
|
||||||
ElMessage.error(res.errors);
|
ElMessage.error(res.errors);
|
||||||
} else {
|
} else {
|
||||||
|
@ -285,12 +285,12 @@ limitations under the License. -->
|
|||||||
if (!expression) {
|
if (!expression) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { getExpressionQuery } = useQueryTopologyExpressionsProcessor(
|
const { getExpressionQuery } = await useQueryTopologyExpressionsProcessor(
|
||||||
[expression],
|
[expression],
|
||||||
topologyStore.nodes.filter((d: Node) => d.isReal),
|
topologyStore.nodes.filter((d: Node) => d.isReal),
|
||||||
);
|
);
|
||||||
const param = getExpressionQuery();
|
const param = getExpressionQuery();
|
||||||
const res = await topologyStore.getNodeExpressionValue(param);
|
const res = await topologyStore.getTopologyExpressionValue(param);
|
||||||
if (res.errors) {
|
if (res.errors) {
|
||||||
ElMessage.error(res.errors);
|
ElMessage.error(res.errors);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user