mirror of
https://github.com/grafana/grafana.git
synced 2025-01-18 20:43:26 -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 useAsync from 'react-use/lib/useAsync';
|
||||||
|
|
||||||
import { QueryEditorProps, SelectableValue } from '@grafana/data';
|
import { QueryEditorProps, SelectableValue } from '@grafana/data';
|
||||||
import { config } from '@grafana/runtime';
|
import { config, reportInteraction } from '@grafana/runtime';
|
||||||
import {
|
import {
|
||||||
Badge,
|
Badge,
|
||||||
FileDropzone,
|
FileDropzone,
|
||||||
@ -67,7 +67,7 @@ class TempoQueryFieldComponent extends React.PureComponent<Props> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { query, onChange, datasource } = this.props;
|
const { query, onChange, datasource, app } = this.props;
|
||||||
|
|
||||||
const logsDatasourceUid = datasource.getLokiSearchDS();
|
const logsDatasourceUid = datasource.getLokiSearchDS();
|
||||||
|
|
||||||
@ -104,6 +104,13 @@ class TempoQueryFieldComponent extends React.PureComponent<Props> {
|
|||||||
options={queryTypeOptions}
|
options={queryTypeOptions}
|
||||||
value={query.queryType}
|
value={query.queryType}
|
||||||
onChange={(v) => {
|
onChange={(v) => {
|
||||||
|
reportInteraction('grafana_traces_query_type_changed', {
|
||||||
|
datasourceType: 'tempo',
|
||||||
|
app: app ?? '',
|
||||||
|
newQueryType: v,
|
||||||
|
previousQueryType: query.queryType ?? '',
|
||||||
|
});
|
||||||
|
|
||||||
this.onClearResults();
|
this.onClearResults();
|
||||||
|
|
||||||
onChange({
|
onChange({
|
||||||
|
@ -16,6 +16,13 @@ import { BackendDataSourceResponse, FetchResponse, setBackendSrv, setDataSourceS
|
|||||||
import { DEFAULT_LIMIT, TempoJsonData, TempoDatasource, TempoQuery } from './datasource';
|
import { DEFAULT_LIMIT, TempoJsonData, TempoDatasource, TempoQuery } from './datasource';
|
||||||
import mockJson from './mockJsonResponse.json';
|
import mockJson from './mockJsonResponse.json';
|
||||||
|
|
||||||
|
jest.mock('@grafana/runtime', () => {
|
||||||
|
return {
|
||||||
|
...jest.requireActual('@grafana/runtime'),
|
||||||
|
reportInteraction: jest.fn(),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
describe('Tempo data source', () => {
|
describe('Tempo data source', () => {
|
||||||
// Mock the console error so that running the test suite doesnt throw the error
|
// Mock the console error so that running the test suite doesnt throw the error
|
||||||
const origError = console.error;
|
const origError = console.error;
|
||||||
|
@ -18,6 +18,7 @@ import {
|
|||||||
BackendSrvRequest,
|
BackendSrvRequest,
|
||||||
DataSourceWithBackend,
|
DataSourceWithBackend,
|
||||||
getBackendSrv,
|
getBackendSrv,
|
||||||
|
reportInteraction,
|
||||||
TemplateSrv,
|
TemplateSrv,
|
||||||
getTemplateSrv,
|
getTemplateSrv,
|
||||||
} from '@grafana/runtime';
|
} from '@grafana/runtime';
|
||||||
@ -159,6 +160,15 @@ export class TempoDatasource extends DataSourceWithBackend<TempoQuery, TempoJson
|
|||||||
|
|
||||||
if (targets.nativeSearch?.length) {
|
if (targets.nativeSearch?.length) {
|
||||||
try {
|
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
|
const timeRange = config.featureToggles.tempoBackendSearch
|
||||||
? { startTime: options.range.from.unix(), endTime: options.range.to.unix() }
|
? { startTime: options.range.from.unix(), endTime: options.range.to.unix() }
|
||||||
: undefined;
|
: undefined;
|
||||||
@ -199,6 +209,12 @@ export class TempoDatasource extends DataSourceWithBackend<TempoQuery, TempoJson
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (targets.traceId?.length > 0) {
|
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));
|
subQueries.push(this.handleTraceIdQuery(options, targets.traceId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user