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;
|
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;
|
||||||
|
panelName?: string;
|
||||||
panelPluginId?: string;
|
panelPluginId?: string;
|
||||||
dashboardUID?: string;
|
dashboardUID?: string;
|
||||||
headers?: Record<string, string>;
|
headers?: Record<string, string>;
|
||||||
|
@ -638,6 +638,7 @@ describe('DashboardScene', () => {
|
|||||||
app: CoreApp.Dashboard,
|
app: CoreApp.Dashboard,
|
||||||
dashboardUID: 'dash-1',
|
dashboardUID: 'dash-1',
|
||||||
panelId: 1,
|
panelId: 1,
|
||||||
|
panelName: 'Panel A',
|
||||||
panelPluginId: 'table',
|
panelPluginId: 'table',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -653,6 +654,7 @@ describe('DashboardScene', () => {
|
|||||||
app: CoreApp.Dashboard,
|
app: CoreApp.Dashboard,
|
||||||
dashboardUID: 'dash-1',
|
dashboardUID: 'dash-1',
|
||||||
panelId: 1,
|
panelId: 1,
|
||||||
|
panelName: 'Panel A',
|
||||||
panelPluginId: 'table',
|
panelPluginId: 'table',
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -620,6 +620,7 @@ export class DashboardScene extends SceneObjectBase<DashboardSceneState> {
|
|||||||
app: CoreApp.Dashboard,
|
app: CoreApp.Dashboard,
|
||||||
dashboardUID: this.state.uid,
|
dashboardUID: this.state.uid,
|
||||||
panelId,
|
panelId,
|
||||||
|
panelName: panel?.state?.title,
|
||||||
panelPluginId: panel?.state.pluginId,
|
panelPluginId: panel?.state.pluginId,
|
||||||
scopes: this._scopesFacade?.value,
|
scopes: this._scopesFacade?.value,
|
||||||
};
|
};
|
||||||
|
@ -380,6 +380,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,
|
||||||
|
panelName: this.title,
|
||||||
panelPluginId: this.type,
|
panelPluginId: this.type,
|
||||||
dashboardUID: dashboardUID,
|
dashboardUID: dashboardUID,
|
||||||
timezone: dashboardTimezone,
|
timezone: dashboardTimezone,
|
||||||
|
@ -160,6 +160,7 @@ function describeQueryRunnerScenario(
|
|||||||
raw: { from: '1d', to: 'now' },
|
raw: { from: '1d', to: 'now' },
|
||||||
},
|
},
|
||||||
panelId: 1,
|
panelId: 1,
|
||||||
|
panelName: 'PanelName',
|
||||||
queries: [{ refId: 'A' }],
|
queries: [{ refId: 'A' }],
|
||||||
} as QueryRunnerOptions;
|
} as QueryRunnerOptions;
|
||||||
|
|
||||||
@ -198,6 +199,11 @@ describe('PanelQueryRunner', () => {
|
|||||||
expect(ctx.queryCalledWith?.scopedVars.__interval!.text).toBe('5m');
|
expect(ctx.queryCalledWith?.scopedVars.__interval!.text).toBe('5m');
|
||||||
expect(ctx.queryCalledWith?.scopedVars.__interval_ms!.text).toBe('300000');
|
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) => {
|
describeQueryRunnerScenario('with maxDataPoints', (ctx) => {
|
||||||
|
@ -50,6 +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;
|
||||||
|
panelName?: string;
|
||||||
panelPluginId?: string;
|
panelPluginId?: string;
|
||||||
dashboardUID?: string;
|
dashboardUID?: string;
|
||||||
timezone: TimeZone;
|
timezone: TimeZone;
|
||||||
@ -258,6 +259,7 @@ export class PanelQueryRunner {
|
|||||||
timezone,
|
timezone,
|
||||||
datasource,
|
datasource,
|
||||||
panelId,
|
panelId,
|
||||||
|
panelName,
|
||||||
panelPluginId,
|
panelPluginId,
|
||||||
dashboardUID,
|
dashboardUID,
|
||||||
timeRange,
|
timeRange,
|
||||||
@ -283,6 +285,7 @@ export class PanelQueryRunner {
|
|||||||
requestId: getNextRequestId(),
|
requestId: getNextRequestId(),
|
||||||
timezone,
|
timezone,
|
||||||
panelId,
|
panelId,
|
||||||
|
panelName,
|
||||||
panelPluginId,
|
panelPluginId,
|
||||||
dashboardUID,
|
dashboardUID,
|
||||||
range: timeRange,
|
range: timeRange,
|
||||||
@ -328,6 +331,9 @@ export class PanelQueryRunner {
|
|||||||
request.intervalMs = norm.intervalMs;
|
request.intervalMs = norm.intervalMs;
|
||||||
request.filters = this.templateSrv.getAdhocFilters(ds.name, true);
|
request.filters = this.templateSrv.getAdhocFilters(ds.name, true);
|
||||||
|
|
||||||
|
request.panelId = panelId;
|
||||||
|
request.panelName = panelName;
|
||||||
|
|
||||||
this.lastRequest = request;
|
this.lastRequest = request;
|
||||||
|
|
||||||
this.pipeToSubject(runRequest(ds, request), panelId, false, addErroDSVariable);
|
this.pipeToSubject(runRequest(ds, request), panelId, false, addErroDSVariable);
|
||||||
|
@ -118,6 +118,7 @@ describe('emitDataRequestEvent', () => {
|
|||||||
it('Should report meta analytics', () => {
|
it('Should report meta analytics', () => {
|
||||||
const data = getTestData({
|
const data = getTestData({
|
||||||
panelId: 2,
|
panelId: 2,
|
||||||
|
panelName: 'Panel Name2',
|
||||||
});
|
});
|
||||||
emitDataRequestEvent(datasource)(data);
|
emitDataRequestEvent(datasource)(data);
|
||||||
|
|
||||||
@ -130,6 +131,7 @@ describe('emitDataRequestEvent', () => {
|
|||||||
datasourceType: datasource.type,
|
datasourceType: datasource.type,
|
||||||
source: CoreApp.Dashboard,
|
source: CoreApp.Dashboard,
|
||||||
panelId: 2,
|
panelId: 2,
|
||||||
|
panelName: 'Panel Name2',
|
||||||
dashboardUid: 'test', // from dashboard srv
|
dashboardUid: 'test', // from dashboard srv
|
||||||
dataSize: 0,
|
dataSize: 0,
|
||||||
duration: 1,
|
duration: 1,
|
||||||
@ -144,6 +146,7 @@ describe('emitDataRequestEvent', () => {
|
|||||||
const data = getTestData(
|
const data = getTestData(
|
||||||
{
|
{
|
||||||
panelId: 2,
|
panelId: 2,
|
||||||
|
panelName: 'Panel Name2',
|
||||||
},
|
},
|
||||||
partiallyCachedSeries
|
partiallyCachedSeries
|
||||||
);
|
);
|
||||||
@ -158,6 +161,7 @@ describe('emitDataRequestEvent', () => {
|
|||||||
datasourceType: datasource.type,
|
datasourceType: datasource.type,
|
||||||
source: CoreApp.Dashboard,
|
source: CoreApp.Dashboard,
|
||||||
panelId: 2,
|
panelId: 2,
|
||||||
|
panelName: 'Panel Name2',
|
||||||
dashboardUid: 'test',
|
dashboardUid: 'test',
|
||||||
dataSize: 2,
|
dataSize: 2,
|
||||||
duration: 1,
|
duration: 1,
|
||||||
@ -172,6 +176,7 @@ describe('emitDataRequestEvent', () => {
|
|||||||
const data = getTestData(
|
const data = getTestData(
|
||||||
{
|
{
|
||||||
panelId: 2,
|
panelId: 2,
|
||||||
|
panelName: 'Panel Name2',
|
||||||
},
|
},
|
||||||
multipleDataframesWithSameRefId
|
multipleDataframesWithSameRefId
|
||||||
);
|
);
|
||||||
@ -186,6 +191,7 @@ describe('emitDataRequestEvent', () => {
|
|||||||
datasourceType: datasource.type,
|
datasourceType: datasource.type,
|
||||||
source: CoreApp.Dashboard,
|
source: CoreApp.Dashboard,
|
||||||
panelId: 2,
|
panelId: 2,
|
||||||
|
panelName: 'Panel Name2',
|
||||||
dashboardUid: 'test', // from dashboard srv
|
dashboardUid: 'test', // from dashboard srv
|
||||||
dataSize: 2,
|
dataSize: 2,
|
||||||
duration: 1,
|
duration: 1,
|
||||||
|
@ -31,6 +31,8 @@ export function emitDataRequestEvent(datasource: DataSourceApi) {
|
|||||||
panelId: 0,
|
panelId: 0,
|
||||||
panelPluginId: data.request?.panelPluginId,
|
panelPluginId: data.request?.panelPluginId,
|
||||||
duration: data.request.endTime! - data.request.startTime,
|
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);
|
enrichWithInfo(eventData, data);
|
||||||
@ -62,9 +64,6 @@ export function emitDataRequestEvent(datasource: DataSourceApi) {
|
|||||||
|
|
||||||
eventData.totalQueries = Object.keys(queryCacheStatus).length;
|
eventData.totalQueries = Object.keys(queryCacheStatus).length;
|
||||||
eventData.cachedQueries = Object.values(queryCacheStatus).filter((val) => val === true).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();
|
const dashboard = getDashboardSrv().getCurrent();
|
||||||
if (dashboard) {
|
if (dashboard) {
|
||||||
|
Loading…
Reference in New Issue
Block a user