Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Default step for gRPC streaming query range queries #4546

Merged
merged 6 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## main / unreleased

* [BUGFIX] Choose a default step for a gRPC streaming query range request if none is provided. [#4546](https://github.com/grafana/tempo/pull/4546) (@joe-elliott)
Fix an issue where the tempo-cli was not correctly dumping exemplar results.

# v2.7.0

* [CHANGE] Disable gRPC compression in the querier and distributor for performance reasons [#4429](https://github.com/grafana/tempo/pull/4429) (@carles-grafana)
Expand Down
1 change: 0 additions & 1 deletion cmd/tempo-cli/cmd-query-metrics-query-range.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ func (cmd *metricsQueryCmd) Run(_ *globalOptions) error {
Query: cmd.TraceQL,
Start: uint64(start),
End: uint64(end),
Step: uint64(5 * time.Second),
}

if cmd.UseGRPC {
Expand Down
9 changes: 6 additions & 3 deletions cmd/tempo-cli/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package main

import (
"context"
"encoding/json"
"errors"
"fmt"
"sort"
"strconv"
"time"

"github.com/gogo/protobuf/jsonpb"
"github.com/gogo/protobuf/proto"
"github.com/google/uuid"
"github.com/grafana/tempo/pkg/boundedwaitgroup"
"github.com/grafana/tempo/tempodb/backend"
Expand Down Expand Up @@ -124,8 +125,10 @@ func loadBlock(r backend.Reader, c backend.Compactor, tenantID string, id backen
}, nil
}

func printAsJSON[T any](value T) error {
traceJSON, err := json.Marshal(value)
func printAsJSON(value proto.Message) error {
m := jsonpb.Marshaler{}

traceJSON, err := m.MarshalToString(value)
if err != nil {
return err
}
Expand Down
8 changes: 7 additions & 1 deletion pkg/api/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,16 @@ func BuildQueryRangeRequest(req *http.Request, searchReq *tempopb.QueryRangeRequ
return req
}

// 0 is an invalid step, so we need to calculate it if it's not provided
step := searchReq.Step
if step == 0 {
step = uint64(traceql.DefaultQueryRangeStep(searchReq.Start, searchReq.End))
}

qb := newQueryBuilder("")
qb.addParam(urlParamStart, strconv.FormatUint(searchReq.Start, 10))
qb.addParam(urlParamEnd, strconv.FormatUint(searchReq.End, 10))
qb.addParam(urlParamStep, time.Duration(searchReq.Step).String())
qb.addParam(urlParamStep, time.Duration(step).String())
qb.addParam(QueryModeKey, searchReq.QueryMode)
// New RF1 params
qb.addParam(urlParamBlockID, searchReq.BlockID)
Expand Down
4 changes: 3 additions & 1 deletion pkg/api/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,9 @@ func TestQueryRangeRoundtrip(t *testing.T) {
}{
{
name: "empty",
req: &tempopb.QueryRangeRequest{},
req: &tempopb.QueryRangeRequest{
Step: uint64(time.Second), // you can't actually roundtrip an empty query b/c Build/Parse will force a default step
},
},
{
name: "not empty!",
Expand Down
Loading