|
|
|
@ -377,9 +377,12 @@ export class TempoDatasource extends DataSourceWithBackend<TempoQuery, TempoJson |
|
|
|
|
if (targets.traceqlSearch?.length) { |
|
|
|
|
try { |
|
|
|
|
if (config.featureToggles.metricsSummary) { |
|
|
|
|
const groupBy = targets.traceqlSearch.find((t) => this.hasGroupBy(t)); |
|
|
|
|
if (groupBy) { |
|
|
|
|
subQueries.push(this.handleMetricsSummary(groupBy, generateQueryFromFilters(groupBy.filters), options)); |
|
|
|
|
const target = targets.traceqlSearch.find((t) => this.hasGroupBy(t)); |
|
|
|
|
if (target) { |
|
|
|
|
const appliedQuery = this.applyVariables(target, options.scopedVars); |
|
|
|
|
subQueries.push( |
|
|
|
|
this.handleMetricsSummary(appliedQuery, generateQueryFromFilters(appliedQuery.filters), options) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -387,25 +390,23 @@ export class TempoDatasource extends DataSourceWithBackend<TempoQuery, TempoJson |
|
|
|
|
? targets.traceqlSearch.filter((t) => !this.hasGroupBy(t)) |
|
|
|
|
: targets.traceqlSearch; |
|
|
|
|
if (traceqlSearchTargets.length > 0) { |
|
|
|
|
const queryValueFromFilters = generateQueryFromFilters(traceqlSearchTargets[0].filters); |
|
|
|
|
|
|
|
|
|
// We want to support template variables also in Search for consistency with other data sources
|
|
|
|
|
const queryValue = this.templateSrv.replace(queryValueFromFilters, options.scopedVars); |
|
|
|
|
const appliedQuery = this.applyVariables(traceqlSearchTargets[0], options.scopedVars); |
|
|
|
|
const queryValueFromFilters = generateQueryFromFilters(appliedQuery.filters); |
|
|
|
|
|
|
|
|
|
reportInteraction('grafana_traces_traceql_search_queried', { |
|
|
|
|
datasourceType: 'tempo', |
|
|
|
|
app: options.app ?? '', |
|
|
|
|
grafana_version: config.buildInfo.version, |
|
|
|
|
query: queryValue ?? '', |
|
|
|
|
query: queryValueFromFilters ?? '', |
|
|
|
|
streaming: config.featureToggles.traceQLStreaming, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if (config.featureToggles.traceQLStreaming && this.isFeatureAvailable(FeatureName.streaming)) { |
|
|
|
|
subQueries.push(this.handleStreamingSearch(options, traceqlSearchTargets, queryValue)); |
|
|
|
|
subQueries.push(this.handleStreamingSearch(options, traceqlSearchTargets, queryValueFromFilters)); |
|
|
|
|
} else { |
|
|
|
|
subQueries.push( |
|
|
|
|
this._request('/api/search', { |
|
|
|
|
q: queryValue, |
|
|
|
|
q: queryValueFromFilters, |
|
|
|
|
limit: options.targets[0].limit ?? DEFAULT_LIMIT, |
|
|
|
|
spss: options.targets[0].spss ?? DEFAULT_SPSS, |
|
|
|
|
start: options.range.from.unix(), |
|
|
|
@ -522,6 +523,24 @@ export class TempoDatasource extends DataSourceWithBackend<TempoQuery, TempoJson |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (query.filters) { |
|
|
|
|
expandedQuery.filters = query.filters.map((filter) => { |
|
|
|
|
const updatedFilter = { |
|
|
|
|
...filter, |
|
|
|
|
tag: this.templateSrv.replace(filter.tag ?? '', scopedVars), |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
if (filter.value) { |
|
|
|
|
updatedFilter.value = |
|
|
|
|
typeof filter.value === 'string' |
|
|
|
|
? this.templateSrv.replace(filter.value ?? '', scopedVars, VariableFormatID.Pipe) |
|
|
|
|
: filter.value.map((v) => this.templateSrv.replace(v ?? '', scopedVars, VariableFormatID.Pipe)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return updatedFilter; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
...expandedQuery, |
|
|
|
|
query: this.templateSrv.replace(query.query ?? '', scopedVars, VariableFormatID.Pipe), |
|
|
|
|