mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
UsageInsights: Include panelId and panelName in events when available
This commit is contained in:
parent
ed3eacced9
commit
3af96acc12
@ -557,6 +557,7 @@ export interface DataQueryRequest<TQuery extends DataQuery = DataQuery> {
|
||||
rangeRaw?: RawTimeRange;
|
||||
timeInfo?: string; // The query time description (blue text in the upper right)
|
||||
panelId?: number;
|
||||
panelName?: string;
|
||||
panelPluginId?: string;
|
||||
dashboardUID?: string;
|
||||
headers?: Record<string, string>;
|
||||
|
@ -638,6 +638,7 @@ describe('DashboardScene', () => {
|
||||
app: CoreApp.Dashboard,
|
||||
dashboardUID: 'dash-1',
|
||||
panelId: 1,
|
||||
panelName: 'Panel A',
|
||||
panelPluginId: 'table',
|
||||
});
|
||||
});
|
||||
@ -653,6 +654,7 @@ describe('DashboardScene', () => {
|
||||
app: CoreApp.Dashboard,
|
||||
dashboardUID: 'dash-1',
|
||||
panelId: 1,
|
||||
panelName: 'Panel A',
|
||||
panelPluginId: 'table',
|
||||
});
|
||||
});
|
||||
|
@ -620,6 +620,7 @@ export class DashboardScene extends SceneObjectBase<DashboardSceneState> {
|
||||
app: CoreApp.Dashboard,
|
||||
dashboardUID: this.state.uid,
|
||||
panelId,
|
||||
panelName: panel?.state?.title,
|
||||
panelPluginId: panel?.state.pluginId,
|
||||
scopes: this._scopesFacade?.value,
|
||||
};
|
||||
|
@ -380,6 +380,7 @@ export class PanelModel implements DataConfigSource, IPanelModel {
|
||||
datasource: this.datasource,
|
||||
queries: this.targets,
|
||||
panelId: this.id,
|
||||
panelName: this.title,
|
||||
panelPluginId: this.type,
|
||||
dashboardUID: dashboardUID,
|
||||
timezone: dashboardTimezone,
|
||||
|
@ -160,6 +160,7 @@ function describeQueryRunnerScenario(
|
||||
raw: { from: '1d', to: 'now' },
|
||||
},
|
||||
panelId: 1,
|
||||
panelName: 'PanelName',
|
||||
queries: [{ refId: 'A' }],
|
||||
} as QueryRunnerOptions;
|
||||
|
||||
@ -198,6 +199,11 @@ describe('PanelQueryRunner', () => {
|
||||
expect(ctx.queryCalledWith?.scopedVars.__interval!.text).toBe('5m');
|
||||
expect(ctx.queryCalledWith?.scopedVars.__interval_ms!.text).toBe('300000');
|
||||
});
|
||||
|
||||
it('should pass the panel id and name', async () => {
|
||||
expect(ctx.queryCalledWith?.panelId).toBe(1);
|
||||
expect(ctx.queryCalledWith?.panelName).toBe('PanelName');
|
||||
});
|
||||
});
|
||||
|
||||
describeQueryRunnerScenario('with maxDataPoints', (ctx) => {
|
||||
|
@ -50,6 +50,7 @@ export interface QueryRunnerOptions<
|
||||
datasource: DataSourceRef | DataSourceApi<TQuery, TOptions> | null;
|
||||
queries: TQuery[];
|
||||
panelId?: number;
|
||||
panelName?: string;
|
||||
panelPluginId?: string;
|
||||
dashboardUID?: string;
|
||||
timezone: TimeZone;
|
||||
@ -258,6 +259,7 @@ export class PanelQueryRunner {
|
||||
timezone,
|
||||
datasource,
|
||||
panelId,
|
||||
panelName,
|
||||
panelPluginId,
|
||||
dashboardUID,
|
||||
timeRange,
|
||||
@ -283,6 +285,7 @@ export class PanelQueryRunner {
|
||||
requestId: getNextRequestId(),
|
||||
timezone,
|
||||
panelId,
|
||||
panelName,
|
||||
panelPluginId,
|
||||
dashboardUID,
|
||||
range: timeRange,
|
||||
@ -328,6 +331,9 @@ export class PanelQueryRunner {
|
||||
request.intervalMs = norm.intervalMs;
|
||||
request.filters = this.templateSrv.getAdhocFilters(ds.name, true);
|
||||
|
||||
request.panelId = panelId;
|
||||
request.panelName = panelName;
|
||||
|
||||
this.lastRequest = request;
|
||||
|
||||
this.pipeToSubject(runRequest(ds, request), panelId, false, addErroDSVariable);
|
||||
|
@ -118,6 +118,7 @@ describe('emitDataRequestEvent', () => {
|
||||
it('Should report meta analytics', () => {
|
||||
const data = getTestData({
|
||||
panelId: 2,
|
||||
panelName: 'Panel Name2',
|
||||
});
|
||||
emitDataRequestEvent(datasource)(data);
|
||||
|
||||
@ -130,6 +131,7 @@ describe('emitDataRequestEvent', () => {
|
||||
datasourceType: datasource.type,
|
||||
source: CoreApp.Dashboard,
|
||||
panelId: 2,
|
||||
panelName: 'Panel Name2',
|
||||
dashboardUid: 'test', // from dashboard srv
|
||||
dataSize: 0,
|
||||
duration: 1,
|
||||
@ -144,6 +146,7 @@ describe('emitDataRequestEvent', () => {
|
||||
const data = getTestData(
|
||||
{
|
||||
panelId: 2,
|
||||
panelName: 'Panel Name2',
|
||||
},
|
||||
partiallyCachedSeries
|
||||
);
|
||||
@ -158,6 +161,7 @@ describe('emitDataRequestEvent', () => {
|
||||
datasourceType: datasource.type,
|
||||
source: CoreApp.Dashboard,
|
||||
panelId: 2,
|
||||
panelName: 'Panel Name2',
|
||||
dashboardUid: 'test',
|
||||
dataSize: 2,
|
||||
duration: 1,
|
||||
@ -172,6 +176,7 @@ describe('emitDataRequestEvent', () => {
|
||||
const data = getTestData(
|
||||
{
|
||||
panelId: 2,
|
||||
panelName: 'Panel Name2',
|
||||
},
|
||||
multipleDataframesWithSameRefId
|
||||
);
|
||||
@ -186,6 +191,7 @@ describe('emitDataRequestEvent', () => {
|
||||
datasourceType: datasource.type,
|
||||
source: CoreApp.Dashboard,
|
||||
panelId: 2,
|
||||
panelName: 'Panel Name2',
|
||||
dashboardUid: 'test', // from dashboard srv
|
||||
dataSize: 2,
|
||||
duration: 1,
|
||||
|
@ -31,6 +31,8 @@ export function emitDataRequestEvent(datasource: DataSourceApi) {
|
||||
panelId: 0,
|
||||
panelPluginId: data.request?.panelPluginId,
|
||||
duration: data.request.endTime! - data.request.startTime,
|
||||
...(data?.request?.panelId && Number.isInteger(data.request.panelId) && { panelId: data.request.panelId }),
|
||||
...(data?.request?.panelName && { panelName: data.request.panelName }),
|
||||
};
|
||||
|
||||
enrichWithInfo(eventData, data);
|
||||
@ -62,9 +64,6 @@ export function emitDataRequestEvent(datasource: DataSourceApi) {
|
||||
|
||||
eventData.totalQueries = Object.keys(queryCacheStatus).length;
|
||||
eventData.cachedQueries = Object.values(queryCacheStatus).filter((val) => val === true).length;
|
||||
if (data.request && Number.isInteger(data.request.panelId)) {
|
||||
eventData.panelId = data.request.panelId;
|
||||
}
|
||||
|
||||
const dashboard = getDashboardSrv().getCurrent();
|
||||
if (dashboard) {
|
||||
|
Loading…
Reference in New Issue
Block a user