From 44839a1bdd64219fa6fde92a17343760cd66d22b Mon Sep 17 00:00:00 2001 From: Fabrizio <135109076+fabrizio-grafana@users.noreply.github.com> Date: Mon, 30 Oct 2023 14:05:14 +0100 Subject: [PATCH] Tempo: Add new intrinsics (#77146) --- .../tempo/SearchTraceQLEditor/utils.test.ts | 62 +++++++++++++++++-- .../datasource/tempo/traceql/traceql.ts | 11 +++- 2 files changed, 67 insertions(+), 6 deletions(-) diff --git a/public/app/plugins/datasource/tempo/SearchTraceQLEditor/utils.test.ts b/public/app/plugins/datasource/tempo/SearchTraceQLEditor/utils.test.ts index 1355094e33e..01744a1de7d 100644 --- a/public/app/plugins/datasource/tempo/SearchTraceQLEditor/utils.test.ts +++ b/public/app/plugins/datasource/tempo/SearchTraceQLEditor/utils.test.ts @@ -106,27 +106,79 @@ describe('generateQueryFromFilters generates the correct query for', () => { describe('gets correct tags', () => { it('for filtered tags when no tags supplied', () => { const tags = getFilteredTags(emptyTags, []); - expect(tags).toEqual(['duration', 'kind', 'name', 'status']); + expect(tags).toEqual([ + 'duration', + 'kind', + 'name', + 'rootName', + 'rootServiceName', + 'status', + 'statusMessage', + 'traceDuration', + ]); }); it('for filtered tags when API v1 tags supplied', () => { const tags = getFilteredTags(v1Tags, []); - expect(tags).toEqual(['duration', 'kind', 'name', 'status', 'bar', 'foo']); + expect(tags).toEqual([ + 'duration', + 'kind', + 'name', + 'rootName', + 'rootServiceName', + 'status', + 'statusMessage', + 'traceDuration', + 'bar', + 'foo', + ]); }); it('for filtered tags when API v1 tags supplied with tags to filter out', () => { const tags = getFilteredTags(v1Tags, ['duration']); - expect(tags).toEqual(['kind', 'name', 'status', 'bar', 'foo']); + expect(tags).toEqual([ + 'kind', + 'name', + 'rootName', + 'rootServiceName', + 'status', + 'statusMessage', + 'traceDuration', + 'bar', + 'foo', + ]); }); it('for filtered tags when API v2 tags supplied', () => { const tags = getFilteredTags(uniq(getUnscopedTags(v2Tags)), []); - expect(tags).toEqual(['duration', 'kind', 'name', 'status', 'cluster', 'container', 'db']); + expect(tags).toEqual([ + 'duration', + 'kind', + 'name', + 'rootName', + 'rootServiceName', + 'status', + 'statusMessage', + 'traceDuration', + 'cluster', + 'container', + 'db', + ]); }); it('for filtered tags when API v2 tags supplied with tags to filter out', () => { const tags = getFilteredTags(getUnscopedTags(v2Tags), ['duration', 'cluster']); - expect(tags).toEqual(['kind', 'name', 'status', 'container', 'db']); + expect(tags).toEqual([ + 'kind', + 'name', + 'rootName', + 'rootServiceName', + 'status', + 'statusMessage', + 'traceDuration', + 'container', + 'db', + ]); }); it('for unscoped tags', () => { diff --git a/public/app/plugins/datasource/tempo/traceql/traceql.ts b/public/app/plugins/datasource/tempo/traceql/traceql.ts index 72bf3d0304e..b8a717106d3 100644 --- a/public/app/plugins/datasource/tempo/traceql/traceql.ts +++ b/public/app/plugins/datasource/tempo/traceql/traceql.ts @@ -27,7 +27,16 @@ export const operators = ['=', '!=', '>', '<', '>=', '<=', '=~', '!~']; export const stringOperators = ['=', '!=', '=~', '!~']; export const numberOperators = ['=', '!=', '>', '<', '>=', '<=']; -export const intrinsics = ['duration', 'kind', 'name', 'status']; +export const intrinsics = [ + 'duration', + 'kind', + 'name', + 'rootName', + 'rootServiceName', + 'status', + 'statusMessage', + 'traceDuration', +]; export const scopes: string[] = ['resource', 'span']; export const functions = ['avg', 'min', 'max', 'sum', 'count', 'by'];