Tempo: Added spss config - spans per span set (#74832)

* Added spss config - spans per span set

* Set default spss when calling Tempo
This commit is contained in:
Andre Pereira 2023-09-14 10:49:18 +01:00 committed by GitHub
parent c4bc90ff5b
commit dc44ac7b78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 3 deletions

View File

@ -55,6 +55,10 @@ export interface TempoQuery extends common.DataQuery {
* @deprecated Query traces by span name * @deprecated Query traces by span name
*/ */
spanName?: string; spanName?: string;
/**
* Defines the maximum number of spans per spanset that are returned from Tempo
*/
spss?: number;
} }
export const defaultTempoQuery: Partial<TempoQuery> = { export const defaultTempoQuery: Partial<TempoQuery> = {

View File

@ -125,6 +125,9 @@ type TempoQuery struct {
// @deprecated Query traces by span name // @deprecated Query traces by span name
SpanName *string `json:"spanName,omitempty"` 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 // TempoQueryType search = Loki search, nativeSearch = Tempo search for backwards compatibility

View File

@ -44,6 +44,8 @@ composableKinds: DataQuery: {
serviceMapIncludeNamespace?: bool serviceMapIncludeNamespace?: bool
// Defines the maximum number of traces that are returned from Tempo // Defines the maximum number of traces that are returned from Tempo
limit?: int64 limit?: int64
// Defines the maximum number of spans per spanset that are returned from Tempo
spss?: int64
filters: [...#TraceqlFilter] filters: [...#TraceqlFilter]
// Filters that are used to query the metrics summary // Filters that are used to query the metrics summary
groupBy?: [...#TraceqlFilter] groupBy?: [...#TraceqlFilter]

View File

@ -52,6 +52,10 @@ export interface TempoQuery extends common.DataQuery {
* @deprecated Query traces by span name * @deprecated Query traces by span name
*/ */
spanName?: string; spanName?: string;
/**
* Defines the maximum number of spans per spanset that are returned from Tempo
*/
spss?: number;
} }
export const defaultTempoQuery: Partial<TempoQuery> = { export const defaultTempoQuery: Partial<TempoQuery> = {

View File

@ -68,6 +68,7 @@ import { getErrorMessage } from './utils';
import { TempoVariableSupport } from './variables'; import { TempoVariableSupport } from './variables';
export const DEFAULT_LIMIT = 20; export const DEFAULT_LIMIT = 20;
export const DEFAULT_SPSS = 3; // spans per span set
enum FeatureName { enum FeatureName {
streaming = 'streaming', streaming = 'streaming',
@ -352,6 +353,7 @@ export class TempoDatasource extends DataSourceWithBackend<TempoQuery, TempoJson
this._request('/api/search', { this._request('/api/search', {
q: queryValue, q: queryValue,
limit: options.targets[0].limit ?? DEFAULT_LIMIT, limit: options.targets[0].limit ?? DEFAULT_LIMIT,
spss: options.targets[0].spss ?? DEFAULT_SPSS,
start: options.range.from.unix(), start: options.range.from.unix(),
end: options.range.to.unix(), end: options.range.to.unix(),
}).pipe( }).pipe(
@ -405,6 +407,7 @@ export class TempoDatasource extends DataSourceWithBackend<TempoQuery, TempoJson
this._request('/api/search', { this._request('/api/search', {
q: queryValue, q: queryValue,
limit: options.targets[0].limit ?? DEFAULT_LIMIT, limit: options.targets[0].limit ?? DEFAULT_LIMIT,
spss: options.targets[0].spss ?? DEFAULT_SPSS,
start: options.range.from.unix(), start: options.range.from.unix(),
end: options.range.to.unix(), end: options.range.to.unix(),
}).pipe( }).pipe(

View File

@ -17,7 +17,7 @@ import {
import { getGrafanaLiveSrv } from '@grafana/runtime'; import { getGrafanaLiveSrv } from '@grafana/runtime';
import { SearchStreamingState } from './dataquery.gen'; import { SearchStreamingState } from './dataquery.gen';
import { TempoDatasource } from './datasource'; import { DEFAULT_SPSS, TempoDatasource } from './datasource';
import { createTableFrameFromTraceQlQuery } from './resultTransformer'; import { createTableFrameFromTraceQlQuery } from './resultTransformer';
import { SearchMetrics, TempoJsonData, TempoQuery } from './types'; import { SearchMetrics, TempoJsonData, TempoQuery } from './types';
export async function getLiveStreamKey(): Promise<string> { export async function getLiveStreamKey(): Promise<string> {
@ -45,6 +45,7 @@ export function doTempoChannelStream(
path: `search/${key}`, path: `search/${key}`,
data: { data: {
...query, ...query,
SpansPerSpanSet: query.spss ?? DEFAULT_SPSS,
timeRange: { timeRange: {
from: range.from.toISOString(), from: range.from.toISOString(),
to: range.to.toISOString(), to: range.to.toISOString(),

View File

@ -4,7 +4,7 @@ import { EditorField, EditorRow } from '@grafana/experimental';
import { AutoSizeInput } from '@grafana/ui'; import { AutoSizeInput } from '@grafana/ui';
import { QueryOptionGroup } from 'app/plugins/datasource/prometheus/querybuilder/shared/QueryOptionGroup'; 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'; import { TempoQuery } from '../types';
interface Props { interface Props {
@ -20,8 +20,11 @@ export const TempoQueryBuilderOptions = React.memo<Props>(({ onChange, query })
const onLimitChange = (e: React.FormEvent<HTMLInputElement>) => { const onLimitChange = (e: React.FormEvent<HTMLInputElement>) => {
onChange({ ...query, limit: parseInt(e.currentTarget.value, 10) }); onChange({ ...query, limit: parseInt(e.currentTarget.value, 10) });
}; };
const onSpssChange = (e: React.FormEvent<HTMLInputElement>) => {
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 ( return (
<> <>
@ -38,6 +41,17 @@ export const TempoQueryBuilderOptions = React.memo<Props>(({ onChange, query })
value={query.limit} value={query.limit}
/> />
</EditorField> </EditorField>
<EditorField label="Span Limit" tooltip="Maximum number of spans to return for each span set.">
<AutoSizeInput
className="width-4"
placeholder="auto"
type="number"
min={1}
defaultValue={query.spss || DEFAULT_SPSS}
onCommitChange={onSpssChange}
value={query.spss}
/>
</EditorField>
</QueryOptionGroup> </QueryOptionGroup>
</EditorRow> </EditorRow>
</> </>