diff --git a/pkg/frontend/querymiddleware/codec.go b/pkg/frontend/querymiddleware/codec.go index f8a0c11da51..2f029cc33f7 100644 --- a/pkg/frontend/querymiddleware/codec.go +++ b/pkg/frontend/querymiddleware/codec.go @@ -124,6 +124,8 @@ type MetricsQueryRequest interface { // WithQuery clones the current request with a different query; returns error if query parse fails. // Implementations must ensure minT and maxT are recalculated when the query changes. WithQuery(string) (MetricsQueryRequest, error) + // WithHeaders clones the current request with different headers. + WithHeaders([]*PrometheusHeader) MetricsQueryRequest // WithExpr clones the current `PrometheusRangeQueryRequest` with a new query expression. // Implementations must ensure minT and maxT are recalculated when the query changes. WithExpr(parser.Expr) MetricsQueryRequest diff --git a/pkg/frontend/querymiddleware/model_extra.go b/pkg/frontend/querymiddleware/model_extra.go index 663879f9dce..3d0c4981153 100644 --- a/pkg/frontend/querymiddleware/model_extra.go +++ b/pkg/frontend/querymiddleware/model_extra.go @@ -184,6 +184,13 @@ func (r *PrometheusRangeQueryRequest) WithQuery(query string) (MetricsQueryReque return &newRequest, nil } +// WithHeaders clones the current `PrometheusRangeQueryRequest` with new headers. +func (r *PrometheusRangeQueryRequest) WithHeaders(headers []*PrometheusHeader) MetricsQueryRequest { + newRequest := *r + newRequest.headers = headers + return &newRequest +} + // WithExpr clones the current `PrometheusRangeQueryRequest` with a new query expression. func (r *PrometheusRangeQueryRequest) WithExpr(queryExpr parser.Expr) MetricsQueryRequest { newRequest := *r @@ -376,6 +383,13 @@ func (r *PrometheusInstantQueryRequest) WithQuery(query string) (MetricsQueryReq return &newRequest, nil } +// WithHeaders clones the current `PrometheusRangeQueryRequest` with new headers. +func (r *PrometheusInstantQueryRequest) WithHeaders(headers []*PrometheusHeader) MetricsQueryRequest { + newRequest := *r + newRequest.headers = headers + return &newRequest +} + // WithExpr clones the current `PrometheusInstantQueryRequest` with a new query expression. func (r *PrometheusInstantQueryRequest) WithExpr(queryExpr parser.Expr) MetricsQueryRequest { newRequest := *r