mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
DataQuery: Track panel plugin id not type (#83091)
This commit is contained in:
parent
0bd009fb53
commit
64e0a4282e
@ -555,7 +555,7 @@ export interface DataQueryRequest<TQuery extends DataQuery = DataQuery> {
|
|||||||
rangeRaw?: RawTimeRange;
|
rangeRaw?: RawTimeRange;
|
||||||
timeInfo?: string; // The query time description (blue text in the upper right)
|
timeInfo?: string; // The query time description (blue text in the upper right)
|
||||||
panelId?: number;
|
panelId?: number;
|
||||||
panelPluginType?: string;
|
panelPluginId?: string;
|
||||||
dashboardUID?: string;
|
dashboardUID?: string;
|
||||||
|
|
||||||
/** Filters to dynamically apply to all queries */
|
/** Filters to dynamically apply to all queries */
|
||||||
|
@ -29,7 +29,7 @@ export interface DataRequestInfo extends Partial<DashboardInfo> {
|
|||||||
datasourceUid: string;
|
datasourceUid: string;
|
||||||
datasourceType: string;
|
datasourceType: string;
|
||||||
panelId?: number;
|
panelId?: number;
|
||||||
panelPluginType?: string;
|
panelPluginId?: string;
|
||||||
panelName?: string;
|
panelName?: string;
|
||||||
duration: number;
|
duration: number;
|
||||||
error?: string;
|
error?: string;
|
||||||
|
@ -80,7 +80,7 @@ enum PluginRequestHeaders {
|
|||||||
DatasourceUID = 'X-Datasource-Uid', // can be used for routing/ load balancing
|
DatasourceUID = 'X-Datasource-Uid', // can be used for routing/ load balancing
|
||||||
DashboardUID = 'X-Dashboard-Uid', // mainly useful for debugging slow queries
|
DashboardUID = 'X-Dashboard-Uid', // mainly useful for debugging slow queries
|
||||||
PanelID = 'X-Panel-Id', // mainly useful for debugging slow queries
|
PanelID = 'X-Panel-Id', // mainly useful for debugging slow queries
|
||||||
PanelPluginType = 'X-Panel-Plugin-Type',
|
PanelPluginId = 'X-Panel-Plugin-Id',
|
||||||
QueryGroupID = 'X-Query-Group-Id', // mainly useful to find related queries with query splitting
|
QueryGroupID = 'X-Query-Group-Id', // mainly useful to find related queries with query splitting
|
||||||
FromExpression = 'X-Grafana-From-Expr', // used by datasources to identify expression queries
|
FromExpression = 'X-Grafana-From-Expr', // used by datasources to identify expression queries
|
||||||
SkipQueryCache = 'X-Cache-Skip', // used by datasources to skip the query cache
|
SkipQueryCache = 'X-Cache-Skip', // used by datasources to skip the query cache
|
||||||
@ -227,8 +227,8 @@ class DataSourceWithBackend<
|
|||||||
if (request.panelId) {
|
if (request.panelId) {
|
||||||
headers[PluginRequestHeaders.PanelID] = `${request.panelId}`;
|
headers[PluginRequestHeaders.PanelID] = `${request.panelId}`;
|
||||||
}
|
}
|
||||||
if (request.panelPluginType) {
|
if (request.panelPluginId) {
|
||||||
headers[PluginRequestHeaders.PanelPluginType] = `${request.panelPluginType}`;
|
headers[PluginRequestHeaders.PanelPluginId] = `${request.panelPluginId}`;
|
||||||
}
|
}
|
||||||
if (request.queryGroupId) {
|
if (request.queryGroupId) {
|
||||||
headers[PluginRequestHeaders.QueryGroupID] = `${request.queryGroupId}`;
|
headers[PluginRequestHeaders.QueryGroupID] = `${request.queryGroupId}`;
|
||||||
|
@ -344,7 +344,7 @@ func (proxy *DataSourceProxy) logRequest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
panelPluginType := proxy.ctx.Req.Header.Get("X-Panel-Plugin-Type")
|
panelPluginId := proxy.ctx.Req.Header.Get("X-Panel-Plugin-Id")
|
||||||
|
|
||||||
ctxLogger := logger.FromContext(proxy.ctx.Req.Context())
|
ctxLogger := logger.FromContext(proxy.ctx.Req.Context())
|
||||||
ctxLogger.Info("Proxying incoming request",
|
ctxLogger.Info("Proxying incoming request",
|
||||||
@ -354,7 +354,7 @@ func (proxy *DataSourceProxy) logRequest() {
|
|||||||
"datasource", proxy.ds.Type,
|
"datasource", proxy.ds.Type,
|
||||||
"uri", proxy.ctx.Req.RequestURI,
|
"uri", proxy.ctx.Req.RequestURI,
|
||||||
"method", proxy.ctx.Req.Method,
|
"method", proxy.ctx.Req.Method,
|
||||||
"panelPluginType", panelPluginType,
|
"panelPluginId", panelPluginId,
|
||||||
"body", body)
|
"body", body)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ func (m *TracingHeaderMiddleware) applyHeaders(ctx context.Context, req backend.
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var headersList = []string{query.HeaderQueryGroupID, query.HeaderPanelID, query.HeaderDashboardUID, query.HeaderDatasourceUID, query.HeaderFromExpression, `X-Grafana-Org-Id`, query.HeaderPanelPluginType}
|
var headersList = []string{query.HeaderQueryGroupID, query.HeaderPanelID, query.HeaderDashboardUID, query.HeaderDatasourceUID, query.HeaderFromExpression, `X-Grafana-Org-Id`, query.HeaderPanelPluginId}
|
||||||
|
|
||||||
for _, headerName := range headersList {
|
for _, headerName := range headersList {
|
||||||
gotVal := reqCtx.Req.Header.Get(headerName)
|
gotVal := reqCtx.Req.Header.Get(headerName)
|
||||||
|
@ -32,7 +32,7 @@ const (
|
|||||||
HeaderDatasourceUID = "X-Datasource-Uid" // can be used for routing/ load balancing
|
HeaderDatasourceUID = "X-Datasource-Uid" // can be used for routing/ load balancing
|
||||||
HeaderDashboardUID = "X-Dashboard-Uid" // mainly useful for debugging slow queries
|
HeaderDashboardUID = "X-Dashboard-Uid" // mainly useful for debugging slow queries
|
||||||
HeaderPanelID = "X-Panel-Id" // mainly useful for debugging slow queries
|
HeaderPanelID = "X-Panel-Id" // mainly useful for debugging slow queries
|
||||||
HeaderPanelPluginType = "X-Panel-Plugin-Type"
|
HeaderPanelPluginId = "X-Panel-Plugin-Id"
|
||||||
HeaderQueryGroupID = "X-Query-Group-Id" // mainly useful for finding related queries with query chunking
|
HeaderQueryGroupID = "X-Query-Group-Id" // mainly useful for finding related queries with query chunking
|
||||||
HeaderFromExpression = "X-Grafana-From-Expr" // used by datasources to identify expression queries
|
HeaderFromExpression = "X-Grafana-From-Expr" // used by datasources to identify expression queries
|
||||||
)
|
)
|
||||||
|
@ -123,13 +123,13 @@ describe('DashboardScene', () => {
|
|||||||
scene.onEnterEditMode();
|
scene.onEnterEditMode();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should add app, uid, panelId and panelPluginType', () => {
|
it('Should add app, uid, panelId and panelPluginId', () => {
|
||||||
const queryRunner = sceneGraph.findObject(scene, (o) => o.state.key === 'data-query-runner')!;
|
const queryRunner = sceneGraph.findObject(scene, (o) => o.state.key === 'data-query-runner')!;
|
||||||
expect(scene.enrichDataRequest(queryRunner)).toEqual({
|
expect(scene.enrichDataRequest(queryRunner)).toEqual({
|
||||||
app: CoreApp.Dashboard,
|
app: CoreApp.Dashboard,
|
||||||
dashboardUID: 'dash-1',
|
dashboardUID: 'dash-1',
|
||||||
panelId: 1,
|
panelId: 1,
|
||||||
panelPluginType: 'table',
|
panelPluginId: 'table',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -555,7 +555,7 @@ export class DashboardScene extends SceneObjectBase<DashboardSceneState> {
|
|||||||
app: CoreApp.Dashboard,
|
app: CoreApp.Dashboard,
|
||||||
dashboardUID: this.state.uid,
|
dashboardUID: this.state.uid,
|
||||||
panelId,
|
panelId,
|
||||||
panelPluginType: panel?.state.pluginId,
|
panelPluginId: panel?.state.pluginId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@ export class PanelModel implements DataConfigSource, IPanelModel {
|
|||||||
datasource: this.datasource,
|
datasource: this.datasource,
|
||||||
queries: this.targets,
|
queries: this.targets,
|
||||||
panelId: this.id,
|
panelId: this.id,
|
||||||
panelPluginType: this.type,
|
panelPluginId: this.type,
|
||||||
dashboardUID: dashboardUID,
|
dashboardUID: dashboardUID,
|
||||||
timezone: dashboardTimezone,
|
timezone: dashboardTimezone,
|
||||||
timeRange: timeData.timeRange,
|
timeRange: timeData.timeRange,
|
||||||
|
@ -50,7 +50,7 @@ export interface QueryRunnerOptions<
|
|||||||
datasource: DataSourceRef | DataSourceApi<TQuery, TOptions> | null;
|
datasource: DataSourceRef | DataSourceApi<TQuery, TOptions> | null;
|
||||||
queries: TQuery[];
|
queries: TQuery[];
|
||||||
panelId?: number;
|
panelId?: number;
|
||||||
panelPluginType?: string;
|
panelPluginId?: string;
|
||||||
dashboardUID?: string;
|
dashboardUID?: string;
|
||||||
timezone: TimeZone;
|
timezone: TimeZone;
|
||||||
timeRange: TimeRange;
|
timeRange: TimeRange;
|
||||||
@ -258,7 +258,7 @@ export class PanelQueryRunner {
|
|||||||
timezone,
|
timezone,
|
||||||
datasource,
|
datasource,
|
||||||
panelId,
|
panelId,
|
||||||
panelPluginType,
|
panelPluginId,
|
||||||
dashboardUID,
|
dashboardUID,
|
||||||
timeRange,
|
timeRange,
|
||||||
timeInfo,
|
timeInfo,
|
||||||
@ -280,7 +280,7 @@ export class PanelQueryRunner {
|
|||||||
requestId: getNextRequestId(),
|
requestId: getNextRequestId(),
|
||||||
timezone,
|
timezone,
|
||||||
panelId,
|
panelId,
|
||||||
panelPluginType,
|
panelPluginId,
|
||||||
dashboardUID,
|
dashboardUID,
|
||||||
range: timeRange,
|
range: timeRange,
|
||||||
timeInfo,
|
timeInfo,
|
||||||
|
@ -103,7 +103,7 @@ function getTestData(
|
|||||||
scopedVars: {},
|
scopedVars: {},
|
||||||
targets: [],
|
targets: [],
|
||||||
timezone: 'utc',
|
timezone: 'utc',
|
||||||
panelPluginType: 'timeseries',
|
panelPluginId: 'timeseries',
|
||||||
...overrides,
|
...overrides,
|
||||||
},
|
},
|
||||||
series: series || [],
|
series: series || [],
|
||||||
@ -135,7 +135,7 @@ describe('emitDataRequestEvent', () => {
|
|||||||
duration: 1,
|
duration: 1,
|
||||||
totalQueries: 0,
|
totalQueries: 0,
|
||||||
cachedQueries: 0,
|
cachedQueries: 0,
|
||||||
panelPluginType: 'timeseries',
|
panelPluginId: 'timeseries',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -163,7 +163,7 @@ describe('emitDataRequestEvent', () => {
|
|||||||
duration: 1,
|
duration: 1,
|
||||||
totalQueries: 2,
|
totalQueries: 2,
|
||||||
cachedQueries: 1,
|
cachedQueries: 1,
|
||||||
panelPluginType: 'timeseries',
|
panelPluginId: 'timeseries',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -191,7 +191,7 @@ describe('emitDataRequestEvent', () => {
|
|||||||
duration: 1,
|
duration: 1,
|
||||||
totalQueries: 1,
|
totalQueries: 1,
|
||||||
cachedQueries: 1,
|
cachedQueries: 1,
|
||||||
panelPluginType: 'timeseries',
|
panelPluginId: 'timeseries',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -238,7 +238,7 @@ describe('emitDataRequestEvent', () => {
|
|||||||
dataSize: 0,
|
dataSize: 0,
|
||||||
duration: 1,
|
duration: 1,
|
||||||
totalQueries: 0,
|
totalQueries: 0,
|
||||||
panelPluginType: 'timeseries',
|
panelPluginId: 'timeseries',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -275,7 +275,7 @@ describe('emitDataRequestEvent', () => {
|
|||||||
dataSize: 0,
|
dataSize: 0,
|
||||||
duration: 1,
|
duration: 1,
|
||||||
totalQueries: 0,
|
totalQueries: 0,
|
||||||
panelPluginType: 'timeseries',
|
panelPluginId: 'timeseries',
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -29,7 +29,7 @@ export function emitDataRequestEvent(datasource: DataSourceApi) {
|
|||||||
datasourceType: datasource.type,
|
datasourceType: datasource.type,
|
||||||
dataSize: 0,
|
dataSize: 0,
|
||||||
panelId: 0,
|
panelId: 0,
|
||||||
panelPluginType: data.request?.panelPluginType,
|
panelPluginId: data.request?.panelPluginId,
|
||||||
duration: data.request.endTime! - data.request.startTime,
|
duration: data.request.endTime! - data.request.startTime,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ export class GraphiteDatasource
|
|||||||
|
|
||||||
addTracingHeaders(
|
addTracingHeaders(
|
||||||
httpOptions: { headers: any },
|
httpOptions: { headers: any },
|
||||||
options: { dashboardId?: number; panelId?: number; panelPluginType?: string }
|
options: { dashboardId?: number; panelId?: number; panelPluginId?: string }
|
||||||
) {
|
) {
|
||||||
const proxyMode = !this.url.match(/^http/);
|
const proxyMode = !this.url.match(/^http/);
|
||||||
if (proxyMode) {
|
if (proxyMode) {
|
||||||
@ -258,8 +258,8 @@ export class GraphiteDatasource
|
|||||||
if (options.panelId) {
|
if (options.panelId) {
|
||||||
httpOptions.headers['X-Panel-Id'] = options.panelId;
|
httpOptions.headers['X-Panel-Id'] = options.panelId;
|
||||||
}
|
}
|
||||||
if (options.panelPluginType) {
|
if (options.panelPluginId) {
|
||||||
httpOptions.headers['X-Panel-Plugin-Id'] = options.panelPluginType;
|
httpOptions.headers['X-Panel-Plugin-Id'] = options.panelPluginId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user