From dc44ac7b78b2bf768c5a4adcee0a020a64ddb9d2 Mon Sep 17 00:00:00 2001 From: Andre Pereira Date: Thu, 14 Sep 2023 10:49:18 +0100 Subject: [PATCH] Tempo: Added spss config - spans per span set (#74832) * Added spss config - spans per span set * Set default spss when calling Tempo --- .../dataquery/x/TempoDataQuery_types.gen.ts | 4 ++++ .../kinds/dataquery/types_dataquery_gen.go | 3 +++ .../app/plugins/datasource/tempo/dataquery.cue | 2 ++ .../plugins/datasource/tempo/dataquery.gen.ts | 4 ++++ .../app/plugins/datasource/tempo/datasource.ts | 3 +++ .../app/plugins/datasource/tempo/streaming.ts | 3 ++- .../tempo/traceql/TempoQueryBuilderOptions.tsx | 18 ++++++++++++++++-- 7 files changed, 34 insertions(+), 3 deletions(-) diff --git a/packages/grafana-schema/src/raw/composable/tempo/dataquery/x/TempoDataQuery_types.gen.ts b/packages/grafana-schema/src/raw/composable/tempo/dataquery/x/TempoDataQuery_types.gen.ts index 7a776a66dd0..61024e6773e 100644 --- a/packages/grafana-schema/src/raw/composable/tempo/dataquery/x/TempoDataQuery_types.gen.ts +++ b/packages/grafana-schema/src/raw/composable/tempo/dataquery/x/TempoDataQuery_types.gen.ts @@ -55,6 +55,10 @@ export interface TempoQuery extends common.DataQuery { * @deprecated Query traces by span name */ spanName?: string; + /** + * Defines the maximum number of spans per spanset that are returned from Tempo + */ + spss?: number; } export const defaultTempoQuery: Partial = { diff --git a/pkg/tsdb/tempo/kinds/dataquery/types_dataquery_gen.go b/pkg/tsdb/tempo/kinds/dataquery/types_dataquery_gen.go index 768b4c1c620..570c7bdbca2 100644 --- a/pkg/tsdb/tempo/kinds/dataquery/types_dataquery_gen.go +++ b/pkg/tsdb/tempo/kinds/dataquery/types_dataquery_gen.go @@ -125,6 +125,9 @@ type TempoQuery struct { // @deprecated Query traces by span name SpanName *string `json:"spanName,omitempty"` + + // Defines the maximum number of spans per spanset that are returned from Tempo + Spss *int64 `json:"spss,omitempty"` } // TempoQueryType search = Loki search, nativeSearch = Tempo search for backwards compatibility diff --git a/public/app/plugins/datasource/tempo/dataquery.cue b/public/app/plugins/datasource/tempo/dataquery.cue index 6c6d9021165..d480dfa6fe9 100644 --- a/public/app/plugins/datasource/tempo/dataquery.cue +++ b/public/app/plugins/datasource/tempo/dataquery.cue @@ -44,6 +44,8 @@ composableKinds: DataQuery: { serviceMapIncludeNamespace?: bool // Defines the maximum number of traces that are returned from Tempo limit?: int64 + // Defines the maximum number of spans per spanset that are returned from Tempo + spss?: int64 filters: [...#TraceqlFilter] // Filters that are used to query the metrics summary groupBy?: [...#TraceqlFilter] diff --git a/public/app/plugins/datasource/tempo/dataquery.gen.ts b/public/app/plugins/datasource/tempo/dataquery.gen.ts index 53126ecf11d..49de9e390bf 100644 --- a/public/app/plugins/datasource/tempo/dataquery.gen.ts +++ b/public/app/plugins/datasource/tempo/dataquery.gen.ts @@ -52,6 +52,10 @@ export interface TempoQuery extends common.DataQuery { * @deprecated Query traces by span name */ spanName?: string; + /** + * Defines the maximum number of spans per spanset that are returned from Tempo + */ + spss?: number; } export const defaultTempoQuery: Partial = { diff --git a/public/app/plugins/datasource/tempo/datasource.ts b/public/app/plugins/datasource/tempo/datasource.ts index 3ac0ddded6c..bd4f717d205 100644 --- a/public/app/plugins/datasource/tempo/datasource.ts +++ b/public/app/plugins/datasource/tempo/datasource.ts @@ -68,6 +68,7 @@ import { getErrorMessage } from './utils'; import { TempoVariableSupport } from './variables'; export const DEFAULT_LIMIT = 20; +export const DEFAULT_SPSS = 3; // spans per span set enum FeatureName { streaming = 'streaming', @@ -352,6 +353,7 @@ export class TempoDatasource extends DataSourceWithBackend { @@ -45,6 +45,7 @@ export function doTempoChannelStream( path: `search/${key}`, data: { ...query, + SpansPerSpanSet: query.spss ?? DEFAULT_SPSS, timeRange: { from: range.from.toISOString(), to: range.to.toISOString(), diff --git a/public/app/plugins/datasource/tempo/traceql/TempoQueryBuilderOptions.tsx b/public/app/plugins/datasource/tempo/traceql/TempoQueryBuilderOptions.tsx index c62089cc5de..9e6766e96d7 100644 --- a/public/app/plugins/datasource/tempo/traceql/TempoQueryBuilderOptions.tsx +++ b/public/app/plugins/datasource/tempo/traceql/TempoQueryBuilderOptions.tsx @@ -4,7 +4,7 @@ import { EditorField, EditorRow } from '@grafana/experimental'; import { AutoSizeInput } from '@grafana/ui'; import { QueryOptionGroup } from 'app/plugins/datasource/prometheus/querybuilder/shared/QueryOptionGroup'; -import { DEFAULT_LIMIT } from '../datasource'; +import { DEFAULT_LIMIT, DEFAULT_SPSS } from '../datasource'; import { TempoQuery } from '../types'; interface Props { @@ -20,8 +20,11 @@ export const TempoQueryBuilderOptions = React.memo(({ onChange, query }) const onLimitChange = (e: React.FormEvent) => { onChange({ ...query, limit: parseInt(e.currentTarget.value, 10) }); }; + const onSpssChange = (e: React.FormEvent) => { + onChange({ ...query, spss: parseInt(e.currentTarget.value, 10) }); + }; - const collapsedInfoList = [`Limit: ${query.limit || DEFAULT_LIMIT}`]; + const collapsedInfoList = [`Limit: ${query.limit || DEFAULT_LIMIT}`, `Spans Limit: ${query.spss || DEFAULT_SPSS}`]; return ( <> @@ -38,6 +41,17 @@ export const TempoQueryBuilderOptions = React.memo(({ onChange, query }) value={query.limit} /> + + +