From 8aac3b8cfdb0df3eb307eb0816c951165384eb38 Mon Sep 17 00:00:00 2001 From: yincong Date: Fri, 20 Dec 2024 12:50:34 +0800 Subject: [PATCH] inpector --- src/datasource.test.ts | 30 ++++++++++++++++-------------- src/datasource.tsx | 2 +- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/datasource.test.ts b/src/datasource.test.ts index 07db597d..8f21347e 100644 --- a/src/datasource.test.ts +++ b/src/datasource.test.ts @@ -654,6 +654,7 @@ function getPrepareTargetsContext({ const options = { targets, interval: '1s', + requestId: "request_id", panelId, app, ...queryOptions, @@ -671,6 +672,7 @@ function getPrepareTargetsContext({ start, end, panelId, + options, }; } @@ -680,10 +682,10 @@ describe('prepareTargets', () => { const target: PromQuery = { refId: 'A', expr: 'up', - requestId: '2A', + requestId: 'request_id2A', }; - const { queries, activeTargets, panelId, end, start } = getPrepareTargetsContext({ targets: [target] }); + const { queries, activeTargets, panelId, end, start, options } = getPrepareTargetsContext({ targets: [target] }); expect(queries.length).toBe(1); expect(activeTargets.length).toBe(1); @@ -698,7 +700,7 @@ describe('prepareTargets', () => { hinting: undefined, instant: undefined, refId: target.refId, - requestId: panelId + target.refId, + requestId: options.requestId + panelId + target.refId, start, step: 1, }); @@ -785,7 +787,7 @@ describe('prepareTargets', () => { requestId: '2A', }; - const { queries, activeTargets, panelId, end, start } = getPrepareTargetsContext({ + const { queries, activeTargets, panelId, end, start, options } = getPrepareTargetsContext({ targets: [target], app: CoreApp.Explore, }); @@ -803,7 +805,7 @@ describe('prepareTargets', () => { hinting: undefined, instant: true, refId: target.refId, - requestId: panelId + target.refId + '_instant', + requestId: options.requestId + panelId + target.refId + '_instant', start, step: 1, }); @@ -811,7 +813,7 @@ describe('prepareTargets', () => { ...target, format: 'table', instant: true, - requestId: panelId + target.refId + '_instant', + requestId: options.requestId + panelId + target.refId + '_instant', valueWithRefId: true, }); expect(queries[1]).toEqual({ @@ -825,7 +827,7 @@ describe('prepareTargets', () => { hinting: undefined, instant: false, refId: target.refId, - requestId: panelId + target.refId, + requestId: options.requestId + panelId + target.refId, start, step: 1, }); @@ -833,7 +835,7 @@ describe('prepareTargets', () => { ...target, format: 'time_series', instant: false, - requestId: panelId + target.refId, + requestId: options.requestId + panelId + target.refId, }); }); }); @@ -845,10 +847,10 @@ describe('prepareTargets', () => { expr: 'up', instant: true, range: false, - requestId: '2A', + requestId: 'request_id2A', }; - const { queries, activeTargets, panelId, end, start } = getPrepareTargetsContext({ + const { queries, activeTargets, panelId, end, start, options } = getPrepareTargetsContext({ targets: [target], app: CoreApp.Explore, }); @@ -866,7 +868,7 @@ describe('prepareTargets', () => { hinting: undefined, instant: true, refId: target.refId, - requestId: panelId + target.refId, + requestId: options.requestId + panelId + target.refId, start, step: 1, }); @@ -882,10 +884,10 @@ describe('prepareTargets', () => { expr: 'up', range: true, instant: false, - requestId: '2A', + requestId: 'request_id2A', }; - const { queries, activeTargets, panelId, end, start } = getPrepareTargetsContext({ + const { queries, activeTargets, panelId, end, start, options } = getPrepareTargetsContext({ targets: [target], app: CoreApp.Explore, }); @@ -903,7 +905,7 @@ describe('prepareTargets', () => { hinting: undefined, instant: false, refId: target.refId, - requestId: panelId + target.refId, + requestId: options.requestId + panelId + target.refId, start, step: 1, trace: undefined diff --git a/src/datasource.tsx b/src/datasource.tsx index 9dddabe5..653b8a25 100755 --- a/src/datasource.tsx +++ b/src/datasource.tsx @@ -317,7 +317,7 @@ export class PrometheusDatasource continue; } - target.requestId = options.panelId + target.refId; + target.requestId = options.requestId + options.panelId + target.refId; // const metricName = this.languageProvider.histogramMetrics.find((m) => target.expr.includes(m)); // In Explore, we run both (instant and range) queries if both are true (selected) or both are undefined (legacy Explore queries)