Traces: Feature tracking (#49767) (#51312)

* Feature tracking for traces

* Mock runtime in test

* Update reportInteraction key

(cherry picked from commit dcccac6657)

Co-authored-by: Joey Tawadrous <90795735+joey-grafana@users.noreply.github.com>
This commit is contained in:
Grot (@grafanabot)
2022-06-24 08:15:12 +01:00
committed by GitHub
co-authored by Joey Tawadrous
parent b429aa11fe
commit 7c8cfc0fe5
3 changed files with 32 additions and 2 deletions
@@ -3,7 +3,7 @@ import React from 'react';
import useAsync from 'react-use/lib/useAsync';
import { QueryEditorProps, SelectableValue } from '@grafana/data';
import { config } from '@grafana/runtime';
import { config, reportInteraction } from '@grafana/runtime';
import {
Badge,
FileDropzone,
@@ -67,7 +67,7 @@ class TempoQueryFieldComponent extends React.PureComponent<Props> {
};
render() {
const { query, onChange, datasource } = this.props;
const { query, onChange, datasource, app } = this.props;
const logsDatasourceUid = datasource.getLokiSearchDS();
@@ -104,6 +104,13 @@ class TempoQueryFieldComponent extends React.PureComponent<Props> {
options={queryTypeOptions}
value={query.queryType}
onChange={(v) => {
reportInteraction('grafana_traces_query_type_changed', {
datasourceType: 'tempo',
app: app ?? '',
newQueryType: v,
previousQueryType: query.queryType ?? '',
});
this.onClearResults();
onChange({
@@ -16,6 +16,13 @@ import { BackendDataSourceResponse, FetchResponse, setBackendSrv, setDataSourceS
import { DEFAULT_LIMIT, TempoJsonData, TempoDatasource, TempoQuery } from './datasource';
import mockJson from './mockJsonResponse.json';
jest.mock('@grafana/runtime', () => {
return {
...jest.requireActual('@grafana/runtime'),
reportInteraction: jest.fn(),
};
});
describe('Tempo data source', () => {
// Mock the console error so that running the test suite doesnt throw the error
const origError = console.error;
@@ -18,6 +18,7 @@ import {
BackendSrvRequest,
DataSourceWithBackend,
getBackendSrv,
reportInteraction,
TemplateSrv,
getTemplateSrv,
} from '@grafana/runtime';
@@ -159,6 +160,15 @@ export class TempoDatasource extends DataSourceWithBackend<TempoQuery, TempoJson
if (targets.nativeSearch?.length) {
try {
reportInteraction('grafana_traces_search_queried', {
datasourceType: 'tempo',
app: options.app ?? '',
serviceName: targets.nativeSearch[0].serviceName ?? '',
spanName: targets.nativeSearch[0].spanName ?? '',
limit: targets.nativeSearch[0].limit ?? '',
search: targets.nativeSearch[0].search ?? '',
});
const timeRange = config.featureToggles.tempoBackendSearch
? { startTime: options.range.from.unix(), endTime: options.range.to.unix() }
: undefined;
@@ -199,6 +209,12 @@ export class TempoDatasource extends DataSourceWithBackend<TempoQuery, TempoJson
}
if (targets.traceId?.length > 0) {
reportInteraction('grafana_traces_traceID_queried', {
datasourceType: 'tempo',
app: options.app ?? '',
query: targets.traceId[0].query ?? '',
});
subQueries.push(this.handleTraceIdQuery(options, targets.traceId));
}