Tempo: TraceQL streaming improvements (#71736)

* Remove unneeded log

* Add elapsed time to streaming progress table

* Use disableTraceQLStreaming toggle to determine default status of streaming
This commit is contained in:
Andre Pereira 2023-07-18 10:45:35 +01:00 committed by GitHub
parent fed3c97dc1
commit 72118e372c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 10 deletions

View File

@ -2,10 +2,6 @@
aliases:
- /docs/grafana/latest/setup-grafana/configure-grafana/feature-toggles/
description: Learn about feature toggles, which you can enable or disable.
labels:
products:
- enterprise
- oss
title: Configure feature toggles
weight: 150
---

View File

@ -59,8 +59,6 @@ func newInstanceSettings(httpClientProvider httpclient.Provider) datasource.Inst
}
func (s *Service) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
s.logger.Info("QueryData called ", "Queries ", req.Queries)
// create response struct
response := backend.NewQueryDataResponse()

View File

@ -37,6 +37,7 @@ export function doTempoChannelStream(
return defer(() => getLiveStreamKey()).pipe(
mergeMap((key) => {
const requestTime = performance.now();
return getGrafanaLiveSrv()
.getStream<MutableDataFrame>({
scope: LiveChannelScope.DataSource,
@ -53,6 +54,8 @@ export function doTempoChannelStream(
.pipe(
map((evt) => {
if ('message' in evt && evt?.message) {
const currentTime = performance.now();
const elapsedTime = currentTime - requestTime;
// Schema should be [traces, metrics, state, error]
const traces = evt.message.data.values[0][0];
const metrics = evt.message.data.values[1][0];
@ -71,7 +74,7 @@ export function doTempoChannelStream(
}
frames = [
metricsDataFrame(metrics, frameState),
metricsDataFrame(metrics, frameState, elapsedTime),
...createTableFrameFromTraceQlQuery(traces, instanceSettings),
];
}
@ -85,7 +88,7 @@ export function doTempoChannelStream(
);
}
function metricsDataFrame(metrics: SearchMetrics, state: SearchStreamingState) {
function metricsDataFrame(metrics: SearchMetrics, state: SearchStreamingState, elapsedTime: number) {
const progressThresholds: ThresholdsConfig = {
steps: [
{
@ -113,6 +116,15 @@ function metricsDataFrame(metrics: SearchMetrics, state: SearchStreamingState) {
displayNameFromDS: 'State',
},
},
{
name: 'elapsedTime',
type: FieldType.number,
values: [elapsedTime],
config: {
unit: 'ms',
displayNameFromDS: 'Elapsed Time',
},
},
{
name: 'totalBlocks',
type: FieldType.number,
@ -144,7 +156,7 @@ function metricsDataFrame(metrics: SearchMetrics, state: SearchStreamingState) {
state === SearchStreamingState.Done ? 100 : ((metrics.completedJobs || 0) / (metrics.totalJobs || 1)) * 100,
],
config: {
displayNameFromDS: 'Total Jobs',
displayNameFromDS: 'Progress',
unit: 'percent',
min: 0,
max: 100,

View File

@ -19,7 +19,7 @@ export const TempoQueryBuilderOptions = React.memo<Props>(({ onChange, query })
}
if (!query.hasOwnProperty('streaming')) {
query.streaming = true;
query.streaming = !config.featureToggles.disableTraceQLStreaming;
}
const onLimitChange = (e: React.FormEvent<HTMLInputElement>) => {