Skip to content

Commit

Permalink
Run formatter
Browse files Browse the repository at this point in the history
Signed-off-by: Oron Sharabi <[email protected]>
  • Loading branch information
oronsh committed Aug 19, 2022
1 parent c7bbac5 commit c61beea
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
6 changes: 3 additions & 3 deletions pkg/api/query/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewGRPCAPI(now func() time.Time, replicaLabels []string, creator query.Quer
queryableCreate: creator,
queryEngine: queryEngine,
defaultMaxResolutionSeconds: defaultMaxResolutionSeconds,
lookbackDeltaCreate: lookbackDeltaCreate,
lookbackDeltaCreate: lookbackDeltaCreate,
}
}

Expand Down Expand Up @@ -66,7 +66,7 @@ func (g *GRPCAPI) Query(request *querypb.QueryRequest, server querypb.Query_Quer
if request.LookbackDeltaSeconds > 0 {
lookbackDelta = time.Duration(request.LookbackDeltaSeconds) * time.Second
}

storeMatchers, err := querypb.StoreMatchersToLabelMatchers(request.StoreMatchers)
if err != nil {
return err
Expand Down Expand Up @@ -140,7 +140,7 @@ func (g *GRPCAPI) QueryRange(request *querypb.QueryRangeRequest, srv querypb.Que
if request.LookbackDeltaSeconds > 0 {
lookbackDelta = time.Duration(request.LookbackDeltaSeconds) * time.Second
}

storeMatchers, err := querypb.StoreMatchersToLabelMatchers(request.StoreMatchers)
if err != nil {
return err
Expand Down
36 changes: 18 additions & 18 deletions pkg/api/query/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ type QueryAPI struct {
gate gate.Gate
queryableCreate query.QueryableCreator
// queryEngine returns appropriate promql.Engine for a query with a given step.
queryEngine *promql.Engine
lookbackDeltaCreate func(int64) time.Duration
ruleGroups rules.UnaryClient
targets targets.UnaryClient
metadatas metadata.UnaryClient
exemplars exemplars.UnaryClient
queryEngine *promql.Engine
lookbackDeltaCreate func(int64) time.Duration
ruleGroups rules.UnaryClient
targets targets.UnaryClient
metadatas metadata.UnaryClient
exemplars exemplars.UnaryClient

enableAutodownsampling bool
enableQueryPartialResponse bool
Expand Down Expand Up @@ -136,16 +136,16 @@ func NewQueryAPI(
reg *prometheus.Registry,
) *QueryAPI {
return &QueryAPI{
baseAPI: api.NewBaseAPI(logger, disableCORS, flagsMap),
logger: logger,
queryEngine: qe,
queryableCreate: c,
gate: gate,
ruleGroups: ruleGroups,
targets: targets,
metadatas: metadatas,
exemplars: exemplars,
lookbackDeltaCreate: lookbackDeltaCreate,
baseAPI: api.NewBaseAPI(logger, disableCORS, flagsMap),
logger: logger,
queryEngine: qe,
queryableCreate: c,
gate: gate,
ruleGroups: ruleGroups,
targets: targets,
metadatas: metadatas,
exemplars: exemplars,
lookbackDeltaCreate: lookbackDeltaCreate,
enableAutodownsampling: enableAutodownsampling,
enableQueryPartialResponse: enableQueryPartialResponse,
enableRulePartialResponse: enableRulePartialResponse,
Expand Down Expand Up @@ -382,7 +382,7 @@ func (qapi *QueryAPI) query(r *http.Request) (interface{}, []error, *api.ApiErro
}

lookbackDelta := qapi.lookbackDeltaCreate(maxSourceResolution)
// Get custom lookback delta from request.
// Get custom lookback delta from request.
lookbackDeltaFromReq, apiErr := qapi.parseLookbackDeltaParam(r)
if apiErr != nil {
return nil, nil, apiErr, func() {}
Expand Down Expand Up @@ -508,7 +508,7 @@ func (qapi *QueryAPI) queryRange(r *http.Request) (interface{}, []error, *api.Ap
}

lookbackDelta := qapi.lookbackDeltaCreate(maxSourceResolution)
// Get custom lookback delta from request.
// Get custom lookback delta from request.
lookbackDeltaFromReq, apiErr := qapi.parseLookbackDeltaParam(r)
if apiErr != nil {
return nil, nil, apiErr, func() {}
Expand Down
11 changes: 6 additions & 5 deletions pkg/query/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,12 @@ func (s series) Iterator() chunkenc.Iterator {
// To test with real data:
// Collect the expected results from Prometheus or Thanos through "/api/v1/query_range" and save to a file.
// Collect raw data to be used for local storage:
// scripts/insecure_grpcurl_series.sh querierGrpcIP:port '[{"name":"type","value":"current"},{"name":"_id","value":"xxx"}]' 1597823000000 1597824600000 > localStorage.json
// Remove all white space from the file and put each series in a new line.
// When collecting the raw data mint should be Prometheus query time minus the default look back delta(default is 5min or 300000ms)
// For example if the Prometheus query mint is 1597823700000 the grpccurl query mint should be 1597823400000.
// This is because when promql displays data for a given range it looks back 5min before the requested time window.
//
// scripts/insecure_grpcurl_series.sh querierGrpcIP:port '[{"name":"type","value":"current"},{"name":"_id","value":"xxx"}]' 1597823000000 1597824600000 > localStorage.json
// Remove all white space from the file and put each series in a new line.
// When collecting the raw data mint should be Prometheus query time minus the default look back delta(default is 5min or 300000ms)
// For example if the Prometheus query mint is 1597823700000 the grpccurl query mint should be 1597823400000.
// This is because when promql displays data for a given range it looks back 5min before the requested time window.
func TestQuerier_Select_AfterPromQL(t *testing.T) {
logger := log.NewLogfmtLogger(os.Stderr)

Expand Down

0 comments on commit c61beea

Please sign in to comment.