set latency range

This commit is contained in:
Fine 2022-10-21 17:03:01 +08:00
parent 1ead82bc12
commit 63837d1ed1
2 changed files with 51 additions and 11 deletions

View File

@ -95,12 +95,27 @@ export default function associateProcessor(props: any) {
const relatedTrace = props.relatedTrace || {}; const relatedTrace = props.relatedTrace || {};
const status = relatedTrace.status; const status = relatedTrace.status;
const queryOrder = relatedTrace.queryOrder; const queryOrder = relatedTrace.queryOrder;
const { latency } = relatedTrace; const latency = relatedTrace.latency;
let latencyList = undefined; let latencyList = undefined;
if (latency && props.option.series) { const series = props.option.series;
latencyList = props.option.series.map( // console.log(series);
(d: { name: string; data: number[][] }) => { if (latency && series) {
return { [d.name]: d.data[currentParams.dataIndex] }; latencyList = series.map(
(d: { name: string; data: number[][] }, index: number) => {
const data = [
d.data[currentParams.dataIndex][1],
series[index + 1]
? series[index + 1].data[currentParams.dataIndex][1]
: Infinity,
];
return {
label:
d.name +
"--" +
(series[index + 1] ? series[index + 1].name : "Infinity"),
value: String(index),
data,
};
} }
); );
} }

View File

@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. --> limitations under the License. -->
<template> <template>
<div class="conditions" v-if="!filters.id"> <div class="conditions flex-h" v-if="!filters.id">
<el-radio-group v-model="conditions" @change="changeCondition"> <el-radio-group v-model="conditions" @change="changeCondition">
<el-radio-button <el-radio-button
v-for="(item, index) in items" v-for="(item, index) in items"
@ -24,6 +24,14 @@ limitations under the License. -->
{{ item.key }} {{ item.key }}
</el-radio-button> </el-radio-button>
</el-radio-group> </el-radio-group>
<Selector
v-if="conditions === 'latency'"
:value="filters.latency[0].value"
:options="filters.latency"
placeholder="Select a option"
@change="changeLatency"
class="ml-10"
/>
</div> </div>
<div class="flex-h"> <div class="flex-h">
<ConditionTags :type="'TRACE'" @update="updateTags" /> <ConditionTags :type="'TRACE'" @update="updateTags" />
@ -83,10 +91,14 @@ const state = reactive<Recordable>({
}); });
const conditions = ref<string>(""); const conditions = ref<string>("");
const items = ref<{ key: string; value: string }[]>([]); const items = ref<{ key: string; value: string }[]>([]);
const currentLatency = ref<number[]>(
filters.latency ? filters.latency[0].data : []
);
init(); init();
async function init() { async function init() {
// console.log(filters);
if (!filters.id) { if (!filters.id) {
for (const d of Object.keys(filters)) { for (const d of Object.keys(filters)) {
if (filters[d] && d !== "duration") { if (filters[d] && d !== "duration") {
@ -116,9 +128,18 @@ async function init() {
} }
await queryTraces(); await queryTraces();
} }
async function changeCondition() { function changeCondition() {
if (conditions.value === "latency") {
currentLatency.value = filters.latency ? filters.latency[0].data : [];
}
queryTraces(); queryTraces();
} }
function changeLatency(options: any[]) {
currentLatency.value = options[0].data;
queryTraces();
}
async function getService() { async function getService() {
const resp = await traceStore.getService(filters.id); const resp = await traceStore.getService(filters.id);
if (resp.errors) { if (resp.errors) {
@ -148,8 +169,12 @@ function setCondition() {
traceState: Status[0].value, traceState: Status[0].value,
queryOrder: QueryOrders[0].value, queryOrder: QueryOrders[0].value,
queryDuration: appStore.durationTime, queryDuration: appStore.durationTime,
minTraceDuration: undefined, minTraceDuration: isNaN(currentLatency.value[0])
maxTraceDuration: undefined, ? undefined
: currentLatency.value[0],
maxTraceDuration: isNaN(currentLatency.value[1])
? undefined
: currentLatency.value[0],
tags: tagsMap.value.length ? tagsMap.value : undefined, tags: tagsMap.value.length ? tagsMap.value : undefined,
paging: { pageNum: 1, pageSize: 20 }, paging: { pageNum: 1, pageSize: 20 },
serviceId: state.service || undefined, serviceId: state.service || undefined,
@ -159,7 +184,7 @@ function setCondition() {
// echarts // echarts
if (!filters.id) { if (!filters.id) {
for (const k of items.value) { for (const k of items.value) {
if (k.key === conditions.value && filters[k.key]) { if (k.key === conditions.value && FiltersKeys[k.key]) {
params[k.value] = filters[k.key]; params[k.value] = filters[k.key];
} }
} }
@ -189,7 +214,7 @@ onUnmounted(() => {
.search-btn { .search-btn {
cursor: pointer; cursor: pointer;
width: 120px; width: 80px;
position: absolute; position: absolute;
top: 0; top: 0;
right: 10px; right: 10px;