Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
23 changes: 0 additions & 23 deletions pkg/querier/tripperware/custom.go
Original file line number Diff line number Diff line change
@@ -1,28 +1,5 @@
package tripperware

import (
"fmt"

"github.com/gogo/protobuf/types"
)

func (e *Extent) ToResponse() (Response, error) {
msg, err := types.EmptyAny(e.Response)
if err != nil {
return nil, err
}

if err := types.UnmarshalAny(e.Response, msg); err != nil {
return nil, err
}

resp, ok := msg.(Response)
if !ok {
return nil, fmt.Errorf("bad cached type")
}
return resp, nil
}

func (m *Sample) GetTimestampMs() int64 {
if m != nil {
if m.Sample != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/querier/tripperware/instantquery/instant_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (c instantQueryCodec) DecodeRequest(_ context.Context, r *http.Request, for
}

func (instantQueryCodec) DecodeResponse(ctx context.Context, r *http.Response, _ tripperware.Request) (tripperware.Response, error) {
log, ctx := spanlogger.New(ctx, "tripperware.PrometheusResponse") //nolint:ineffassign,staticcheck
log, ctx := spanlogger.New(ctx, "DecodeQueryInstantResponse") //nolint:ineffassign,staticcheck
defer log.Finish()

if err := ctx.Err(); err != nil {
Expand Down
19 changes: 19 additions & 0 deletions pkg/querier/tripperware/queryrange/query_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,20 @@ var (
cacheControlHeader = "Cache-Control"
)

func (resp *PrometheusResponse) HTTPHeaders() map[string][]string {
if resp != nil && resp.GetHeaders() != nil {
r := map[string][]string{}
for _, header := range resp.GetHeaders() {
if header != nil {
r[header.Name] = header.Values
}
}

return r
}
return nil
}

type prometheusCodec struct {
sharded bool
}
Expand All @@ -57,6 +71,11 @@ func (c prometheusCodec) MergeResponse(ctx context.Context, req tripperware.Requ
return tripperware.NewEmptyPrometheusResponse(false), nil
}

// Safety guard in case any response from results cache middleware
// still uses the old queryrange.PrometheusResponse type.
for i, resp := range responses {
responses[i] = convertToTripperwarePrometheusResponse(resp)
}
return tripperware.MergeResponse(ctx, c.sharded, nil, responses...)
}

Expand Down
Loading
Loading