mirror of
https://github.com/grafana/grafana.git
synced 2025-01-18 04:23:33 -06:00
Traces: Feature tracking (#49767)
* Feature tracking for traces * Mock runtime in test * Update reportInteraction key
This commit is contained in:
parent
82e9f4e7e7
commit
dcccac6657
@ -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));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user