From c57ff8beede4ef569b6a78a68577efbef223ccf1 Mon Sep 17 00:00:00 2001 From: Connor Lindsey Date: Thu, 16 Sep 2021 08:04:15 -0600 Subject: [PATCH] Tempo: Format tempo search query history text (#39250) * Format tempo search query history text --- .../datasource/tempo/datasource.test.ts | 19 +++++++++++++++++++ .../plugins/datasource/tempo/datasource.ts | 11 ++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/tempo/datasource.test.ts b/public/app/plugins/datasource/tempo/datasource.test.ts index d7ff615fa98..58f9e3be4f9 100644 --- a/public/app/plugins/datasource/tempo/datasource.test.ts +++ b/public/app/plugins/datasource/tempo/datasource.test.ts @@ -168,6 +168,25 @@ describe('Tempo data source', () => { 'root.http.status_code': '500', }); }); + + it('formats native search query history correctly', () => { + const ds = new TempoDatasource(defaultSettings); + const tempoQuery: TempoQuery = { + queryType: 'nativeSearch', + refId: 'A', + query: '', + serviceName: 'frontend', + spanName: '/config', + search: 'root.http.status_code=500', + minDuration: '1ms', + maxDuration: '100s', + limit: 10, + }; + const result = ds.getQueryDisplayText(tempoQuery); + expect(result).toBe( + 'Service Name: frontend, Span Name: /config, Search: root.http.status_code=500, Min Duration: 1ms, Max Duration: 100s, Limit: 10' + ); + }); }); const backendSrvWithPrometheus = { diff --git a/public/app/plugins/datasource/tempo/datasource.ts b/public/app/plugins/datasource/tempo/datasource.ts index f501fae2849..67341f709e0 100644 --- a/public/app/plugins/datasource/tempo/datasource.ts +++ b/public/app/plugins/datasource/tempo/datasource.ts @@ -13,7 +13,7 @@ import { TraceToLogsOptions } from 'app/core/components/TraceToLogsSettings'; import { 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 } from 'lodash'; +import { identity, pick, pickBy, groupBy, startCase } from 'lodash'; import Prism from 'prismjs'; import { LokiOptions, LokiQuery } from '../loki/types'; import { PrometheusDatasource } from '../prometheus/datasource'; @@ -174,6 +174,15 @@ export class TempoDatasource extends DataSourceWithBackend