From b78af0b0f03bafcb66daecf8ac4fdd2c1a6371fa Mon Sep 17 00:00:00 2001 From: Andre Pereira Date: Thu, 2 Feb 2023 15:43:28 +0000 Subject: [PATCH] Tempo: Inject status and status.code for tags autocomplete (#62794) * Tempo: Inject status for v2 and status.code for v1 in the tags list for autocomplete * Small comment fix --- .../datasource/tempo/QueryEditor/TagsField/TagsField.tsx | 5 +++++ .../app/plugins/datasource/tempo/traceql/TraceQLEditor.tsx | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/public/app/plugins/datasource/tempo/QueryEditor/TagsField/TagsField.tsx b/public/app/plugins/datasource/tempo/QueryEditor/TagsField/TagsField.tsx index 8737c4e811c..1c8f80ada5e 100644 --- a/public/app/plugins/datasource/tempo/QueryEditor/TagsField/TagsField.tsx +++ b/public/app/plugins/datasource/tempo/QueryEditor/TagsField/TagsField.tsx @@ -121,6 +121,11 @@ function useAutocomplete(datasource: TempoDatasource) { const tags = datasource.languageProvider.getTags(); if (tags) { + // This is needed because the /api/search/tag/${tag}/values API expects "status.code" and the v2 API expects "status" + // so Tempo doesn't send anything and we inject it here for the autocomplete + if (!tags.find((t) => t === 'status.code')) { + tags.push('status.code'); + } providerRef.current.setTags(tags); } } catch (error) { diff --git a/public/app/plugins/datasource/tempo/traceql/TraceQLEditor.tsx b/public/app/plugins/datasource/tempo/traceql/TraceQLEditor.tsx index 4d705462c1a..1b398141b94 100644 --- a/public/app/plugins/datasource/tempo/traceql/TraceQLEditor.tsx +++ b/public/app/plugins/datasource/tempo/traceql/TraceQLEditor.tsx @@ -148,6 +148,11 @@ function useAutocomplete(datasource: TempoDatasource) { const tags = datasource.languageProvider.getTags(); if (tags) { + // This is needed because the /api/v2/search/tag/${tag}/values API expects "status" and the v1 API expects "status.code" + // so Tempo doesn't send anything and we inject it here for the autocomplete + if (!tags.find((t) => t === 'status')) { + tags.push('status'); + } providerRef.current.setTags(tags); } } catch (error) {