-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cache labels and series results (#3315)
* cache labels and series results Signed-off-by: Ben Ye <[email protected]> * add changelog Signed-off-by: Ben Ye <[email protected]> * fix style Signed-off-by: Ben Ye <[email protected]> * update changelog Signed-off-by: Ben Ye <[email protected]> * rebase Signed-off-by: Ben Ye <[email protected]>
- Loading branch information
Showing
15 changed files
with
696 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) The Thanos Authors. | ||
// Licensed under the Apache License 2.0. | ||
|
||
package queryfrontend | ||
|
||
import ( | ||
"unsafe" | ||
|
||
"github.com/cortexproject/cortex/pkg/querier/queryrange" | ||
) | ||
|
||
// ThanosResponseExtractor helps extracting specific info from Query Response. | ||
type ThanosResponseExtractor struct{} | ||
|
||
// Extract extracts response for specific a range from a response. | ||
// This interface is not used for labels and series responses. | ||
func (ThanosResponseExtractor) Extract(_, _ int64, resp queryrange.Response) queryrange.Response { | ||
return resp | ||
} | ||
|
||
// ResponseWithoutHeaders returns the response without HTTP headers. | ||
func (ThanosResponseExtractor) ResponseWithoutHeaders(resp queryrange.Response) queryrange.Response { | ||
switch tr := resp.(type) { | ||
case *ThanosLabelsResponse: | ||
return &ThanosLabelsResponse{Status: queryrange.StatusSuccess, Data: tr.Data} | ||
case *ThanosSeriesResponse: | ||
return &ThanosSeriesResponse{Status: queryrange.StatusSuccess, Data: tr.Data} | ||
} | ||
return resp | ||
} | ||
|
||
// headersToQueryRangeHeaders convert slice of ResponseHeader to Cortex queryrange.PrometheusResponseHeader in an | ||
// unsafe manner. It reuses the same memory. | ||
func headersToQueryRangeHeaders(headers []*ResponseHeader) []*queryrange.PrometheusResponseHeader { | ||
return *(*[]*queryrange.PrometheusResponseHeader)(unsafe.Pointer(&headers)) | ||
} | ||
|
||
// GetHeaders returns the HTTP headers in the response. | ||
func (m *ThanosLabelsResponse) GetHeaders() []*queryrange.PrometheusResponseHeader { | ||
return headersToQueryRangeHeaders(m.Headers) | ||
} | ||
|
||
// GetHeaders returns the HTTP headers in the response. | ||
func (m *ThanosSeriesResponse) GetHeaders() []*queryrange.PrometheusResponseHeader { | ||
return headersToQueryRangeHeaders(m.Headers) | ||
} |
Oops, something went wrong.