fix: optimize config UI for related trace and metrics (#195)

This commit is contained in:
Fine0830 2022-11-29 14:24:15 +08:00 committed by GitHub
parent 5be106fc4f
commit d4dde7e73b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 46 additions and 18 deletions

View File

@ -162,7 +162,8 @@ const msg = {
viewTrace: "View Related Traces",
relatedTraceOptions: "Related Trace Options",
setLatencyDuration: "Latency Related Metrics",
queryOrder: "Query Order",
queryOrder: "Query By Duration",
setOrder: "Query Order",
latency: "Latency",
metricValues: "Metric Values",
queryConditions: "Query Conditions",

View File

@ -159,7 +159,8 @@ const msg = {
postgreSQL: "PostgreSQL",
endpointTips: "Aquí, la tabla muestra hasta 20 punto final.",
apisix: "APISIX",
queryOrder: "Orden de consulta",
queryOrder: "Consulta por duración",
setOrder: "Orden de consulta",
latency: "Retraso",
metricValues: "Valor métrico",
legendValues: "Valor de la leyenda",

View File

@ -159,7 +159,8 @@ const msg = {
viewTrace: "查看相关Trace",
relatedTraceOptions: "相关的Trace选项",
setLatencyDuration: "延迟相关指标",
queryOrder: "查询顺序",
queryOrder: "按持续时间查询",
setOrder: "查询顺序",
latency: "延迟",
metricValues: "指标值",
enableRelatedTrace: "启用相关Trace",

View File

@ -46,7 +46,7 @@ limitations under the License. -->
/>
</div>
<div class="item">
<span class="label">{{ t("queryOrder") }}</span>
<span class="label">{{ t("setOrder") }}</span>
<Selector
size="small"
:value="queryOrder"
@ -71,8 +71,17 @@ limitations under the License. -->
import { ref } from "vue";
import { useI18n } from "vue-i18n";
import { useDashboardStore } from "@/store/modules/dashboard";
import { Status, QueryOrders, RefIdTypes } from "../../data";
import { RefIdTypes } from "../../data";
const QueryOrders = [
{ label: "None", value: "BY_START_TIME" },
{ label: "Duration", value: "BY_DURATION" },
];
const Status = [
{ label: "None", value: "ALL" },
{ label: "Success", value: "SUCCESS" },
{ label: "Error", value: "ERROR" },
];
const { t } = useI18n();
const dashboardStore = useDashboardStore();
const { graph, relatedTrace } = dashboardStore.selectedGrid;

View File

@ -60,7 +60,10 @@ limitations under the License. -->
/>
</el-popover>
<span
v-show="states.isList || states.metricTypes[0] === 'readMetricsValues'"
v-show="
states.isList ||
states.metricTypes[0] === ProtocolTypes.ReadMetricsValues
"
>
<Icon
class="cp mr-5"
@ -106,6 +109,7 @@ import {
ChartTypes,
PodsChartTypes,
MetricsType,
ProtocolTypes,
} from "../../../data";
import { ElMessage } from "element-plus";
import Icon from "@/components/Icon.vue";
@ -425,13 +429,7 @@ function setMetricTypeList(type: string) {
return MetricTypes[type];
}
if (states.isList || graph.value.type === "Table") {
return [
{ label: "read all values in the duration", value: "readMetricsValues" },
{
label: "read the single value in the duration",
value: "readMetricsValue",
},
];
return [MetricTypes.REGULAR_VALUE[0], MetricTypes.REGULAR_VALUE[1]];
}
return MetricTypes[type];
}

View File

@ -97,7 +97,7 @@ import { useI18n } from "vue-i18n";
import { SortOrder, CalculationOpts } from "../../../data";
import { useDashboardStore } from "@/store/modules/dashboard";
import { MetricConfigOpt } from "@/types/dashboard";
import { ListChartTypes } from "../../../data";
import { ListChartTypes, ProtocolTypes } from "../../../data";
/*global defineEmits, defineProps */
const props = defineProps({
@ -122,11 +122,18 @@ const hasLabel = computed(() => {
const graph = dashboardStore.selectedGrid.graph || {};
return (
ListChartTypes.includes(graph.type) ||
["readLabeledMetricsValues", "readMetricsValues"].includes(metricType.value)
[
ProtocolTypes.ReadLabeledMetricsValues,
ProtocolTypes.ReadMetricsValues,
].includes(metricType.value)
);
});
const isTopn = computed(() =>
["sortMetrics", "readSampledRecords"].includes(metricTypes[props.index])
[
ProtocolTypes.SortMetrics,
ProtocolTypes.ReadSampledRecords,
ProtocolTypes.ReadRecords,
].includes(metricTypes[props.index])
);
function updateConfig(index: number, param: { [key: string]: string }) {
const key = Object.keys(param)[0];

View File

@ -47,6 +47,15 @@ export const MetricChartType: any = {
readSampledRecords: [{ label: "Top List", value: "TopList" }],
readRecords: [{ label: "Top List", value: "TopList" }],
};
export enum ProtocolTypes {
ReadRecords = "readRecords",
ReadSampledRecords = "readSampledRecords",
SortMetrics = "sortMetrics",
ReadLabeledMetricsValues = "readLabeledMetricsValues",
ReadHeatMap = "readHeatMap",
ReadMetricsValues = "readMetricsValues",
ReadMetricsValue = "readMetricsValue",
}
export const DefaultGraphConfig: { [key: string]: any } = {
Bar: {
type: "Bar",

View File

@ -138,8 +138,10 @@ init();
async function init() {
for (const d of Object.keys(filters)) {
if (
["queryOrder"].includes(d) ||
(d === "status" && filters[d] && filters[d] !== "ALL") ||
(d === "queryOrder" &&
filters[d] &&
filters[d] === QueryOrders[1].value) ||
(d === "status" && filters[d] && filters[d] !== Status[0].value) ||
(filters[d] && d === "latency")
) {
items.value.push({ label: d, value: FiltersKeys[d] });