Skip to content

Commit

Permalink
added WithHeaders method to MetricsQueryRequest interface
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Ángel Ortuño <ortuman@gmail.com>
  • Loading branch information
ortuman committed Jun 14, 2024
1 parent 022c6d5 commit 023f43f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/frontend/querymiddleware/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions pkg/frontend/querymiddleware/model_extra.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 023f43f

Please sign in to comment.