diff --git a/packages/grafana-data/src/types/config.ts b/packages/grafana-data/src/types/config.ts index bfc4f26e53b..4a2bc9c5dea 100644 --- a/packages/grafana-data/src/types/config.ts +++ b/packages/grafana-data/src/types/config.ts @@ -49,6 +49,7 @@ export interface FeatureToggles { accesscontrol: boolean; tempoServiceGraph: boolean; tempoSearch: boolean; + tempoBackendSearch: boolean; recordedQueries: boolean; newNavigation: boolean; fullRangeLogsVolume: boolean; diff --git a/packages/grafana-runtime/src/config.ts b/packages/grafana-runtime/src/config.ts index bde25a8b709..dcfd4b97223 100644 --- a/packages/grafana-runtime/src/config.ts +++ b/packages/grafana-runtime/src/config.ts @@ -66,6 +66,7 @@ export class GrafanaBootConfig implements GrafanaConfig { trimDefaults: false, tempoServiceGraph: false, tempoSearch: false, + tempoBackendSearch: false, recordedQueries: false, newNavigation: false, fullRangeLogsVolume: false, diff --git a/public/app/plugins/datasource/tempo/QueryEditor/QueryField.tsx b/public/app/plugins/datasource/tempo/QueryEditor/QueryField.tsx index 11ed19319db..e4ce99fa7f1 100644 --- a/public/app/plugins/datasource/tempo/QueryEditor/QueryField.tsx +++ b/public/app/plugins/datasource/tempo/QueryEditor/QueryField.tsx @@ -136,8 +136,15 @@ class TempoQueryFieldComponent extends React.PureComponent { {query.queryType === 'nativeSearch' && (

-  Tempo search is currently in beta and is designed to return recent traces only. It ignores the time - range picker. We are actively working on full backend search. Look for improvements in the near future! + {config.featureToggles.tempoBackendSearch ? ( + <> Tempo search is currently in beta. + ) : ( + <> +  Tempo search is currently in beta and is designed to return recent traces only. It ignores the + time range picker. We are actively working on full backend search. Look for improvements in the near + future! + + )}

)} {query.queryType === 'search' && ( diff --git a/public/app/plugins/datasource/tempo/datasource.test.ts b/public/app/plugins/datasource/tempo/datasource.test.ts index 7e6ff2ef9a8..cd5193f710f 100644 --- a/public/app/plugins/datasource/tempo/datasource.test.ts +++ b/public/app/plugins/datasource/tempo/datasource.test.ts @@ -169,6 +169,24 @@ describe('Tempo data source', () => { }); }); + it('should include time range if provided', () => { + const ds = new TempoDatasource(defaultSettings); + const tempoQuery: TempoQuery = { + queryType: 'search', + refId: 'A', + query: '', + search: '', + }; + const timeRange = { startTime: 0, endTime: 1000 }; + const builtQuery = ds.buildSearchQuery(tempoQuery, timeRange); + expect(builtQuery).toStrictEqual({ + tags: '', + limit: DEFAULT_LIMIT, + start: timeRange.startTime, + end: timeRange.endTime, + }); + }); + it('formats native search query history correctly', () => { const ds = new TempoDatasource(defaultSettings); const tempoQuery: TempoQuery = { diff --git a/public/app/plugins/datasource/tempo/datasource.ts b/public/app/plugins/datasource/tempo/datasource.ts index d70e58680aa..4e5e18665b8 100644 --- a/public/app/plugins/datasource/tempo/datasource.ts +++ b/public/app/plugins/datasource/tempo/datasource.ts @@ -11,7 +11,7 @@ import { LoadingState, } from '@grafana/data'; import { TraceToLogsOptions } from 'app/core/components/TraceToLogsSettings'; -import { BackendSrvRequest, DataSourceWithBackend, getBackendSrv } from '@grafana/runtime'; +import { config, BackendSrvRequest, DataSourceWithBackend, getBackendSrv } from '@grafana/runtime'; import { serializeParams } from 'app/core/utils/fetch'; import { getDatasourceSrv } from 'app/features/plugins/datasource_srv'; import { identity, pick, pickBy, groupBy, startCase } from 'lodash'; @@ -55,6 +55,15 @@ export type TempoQuery = { serviceMapQuery?: string; } & DataQuery; +interface SearchQueryParams { + minDuration?: string; + maxDuration?: string; + limit?: number; + tags: string; + start?: number; + end?: number; +} + export const DEFAULT_LIMIT = 20; export class TempoDatasource extends DataSourceWithBackend { @@ -116,7 +125,10 @@ export class TempoDatasource extends DataSourceWithBackend { @@ -206,7 +218,7 @@ export class TempoDatasource extends DataSourceWithBackend