-
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.
Querier/Sidecar/StoreGW: Implement Info service and add
--endpoint
…
…flag in Querier (#4282) * Add Info server in Sidecar and StoreGW Signed-off-by: Hitanshu Mehta <[email protected]> * Add `--endpoint` in querier Signed-off-by: Hitanshu Mehta <[email protected]> * Add E2E test for Info API Signed-off-by: Hitanshu Mehta <[email protected]> * Make min/max times global vaiables and some other minor changes Signed-off-by: Hitanshu Mehta <[email protected]> * Enhance e2e test Signed-off-by: Hitanshu Mehta <[email protected]> * Rename `InfoRequest` and `InfoResponse` to `InfoReq` and `InfoResp` Signed-off-by: Hitanshu Mehta <[email protected]> * Minor fixes and change package name for proto file for info service Signed-off-by: Hitanshu Mehta <[email protected]> * resolve merge conflicts Signed-off-by: Hitanshu Mehta <[email protected]> * add deprecation warning in description of old flags Signed-off-by: Hitanshu Mehta <[email protected]> * fix typo Signed-off-by: Hitanshu Mehta <[email protected]> * export new Timestamps method Signed-off-by: Hitanshu Mehta <[email protected]> * add functional options in intializer of info server Signed-off-by: Hitanshu Mehta <[email protected]> * change e2e tests to use efficientgo/e2e Signed-off-by: Hitanshu Mehta <[email protected]> * nits in info api e2e tests Signed-off-by: Hitanshu Mehta <[email protected]> * minor nits Signed-off-by: Hitanshu Mehta <[email protected]> * fix docs Signed-off-by: Hitanshu Mehta <[email protected]>
- Loading branch information
1 parent
0ef2fda
commit ac2cc26
Showing
9 changed files
with
454 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
// Copyright (c) The Thanos Authors. | ||
// Licensed under the Apache License 2.0. | ||
|
||
package info | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/thanos-io/thanos/pkg/info/infopb" | ||
"github.com/thanos-io/thanos/pkg/store/labelpb" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
type InfoServer struct { | ||
infopb.UnimplementedInfoServer | ||
|
||
component string | ||
|
||
getLabelSet func() []labelpb.ZLabelSet | ||
getStoreInfo func() *infopb.StoreInfo | ||
getExemplarsInfo func() *infopb.ExemplarsInfo | ||
getRulesInfo func() *infopb.RulesInfo | ||
getTargetsInfo func() *infopb.TargetsInfo | ||
getMetricMetadataInfo func() *infopb.MetricMetadataInfo | ||
} | ||
|
||
func NewInfoServer( | ||
component string, | ||
options ...func(*InfoServer), | ||
) *InfoServer { | ||
srv := &InfoServer{ | ||
component: component, | ||
} | ||
|
||
for _, o := range options { | ||
o(srv) | ||
} | ||
|
||
return srv | ||
} | ||
|
||
func WithLabelSet(getLabelSet func() []labelpb.ZLabelSet) func(*InfoServer) { | ||
return func(s *InfoServer) { | ||
s.getLabelSet = getLabelSet | ||
} | ||
} | ||
|
||
func WithStoreInfo(getStoreInfo func() *infopb.StoreInfo) func(*InfoServer) { | ||
return func(s *InfoServer) { | ||
s.getStoreInfo = getStoreInfo | ||
} | ||
} | ||
|
||
func WithRulesInfo(getRulesInfo func() *infopb.RulesInfo) func(*InfoServer) { | ||
return func(s *InfoServer) { | ||
s.getRulesInfo = getRulesInfo | ||
} | ||
} | ||
|
||
func WithExemplarsInfo(getExemplarsInfo func() *infopb.ExemplarsInfo) func(*InfoServer) { | ||
return func(s *InfoServer) { | ||
s.getExemplarsInfo = getExemplarsInfo | ||
} | ||
} | ||
|
||
func WithTargetInfo(getTargetsInfo func() *infopb.TargetsInfo) func(*InfoServer) { | ||
return func(s *InfoServer) { | ||
s.getTargetsInfo = getTargetsInfo | ||
} | ||
} | ||
|
||
func WithMetricMetadataInfo(getMetricMetadataInfo func() *infopb.MetricMetadataInfo) func(*InfoServer) { | ||
return func(s *InfoServer) { | ||
s.getMetricMetadataInfo = getMetricMetadataInfo | ||
} | ||
} | ||
|
||
// RegisterInfoServer register info server. | ||
func RegisterInfoServer(infoSrv infopb.InfoServer) func(*grpc.Server) { | ||
return func(s *grpc.Server) { | ||
infopb.RegisterInfoServer(s, infoSrv) | ||
} | ||
} | ||
|
||
func (srv *InfoServer) Info(ctx context.Context, req *infopb.InfoRequest) (*infopb.InfoResponse, error) { | ||
|
||
if srv.getLabelSet == nil { | ||
srv.getLabelSet = func() []labelpb.ZLabelSet { return nil } | ||
} | ||
|
||
if srv.getStoreInfo == nil { | ||
srv.getStoreInfo = func() *infopb.StoreInfo { return nil } | ||
} | ||
|
||
if srv.getExemplarsInfo == nil { | ||
srv.getExemplarsInfo = func() *infopb.ExemplarsInfo { return nil } | ||
} | ||
|
||
if srv.getRulesInfo == nil { | ||
srv.getRulesInfo = func() *infopb.RulesInfo { return nil } | ||
} | ||
|
||
if srv.getTargetsInfo == nil { | ||
srv.getTargetsInfo = func() *infopb.TargetsInfo { return nil } | ||
} | ||
|
||
if srv.getMetricMetadataInfo == nil { | ||
srv.getMetricMetadataInfo = func() *infopb.MetricMetadataInfo { return nil } | ||
} | ||
|
||
resp := &infopb.InfoResponse{ | ||
LabelSets: srv.getLabelSet(), | ||
ComponentType: srv.component, | ||
Store: srv.getStoreInfo(), | ||
Exemplars: srv.getExemplarsInfo(), | ||
Rules: srv.getRulesInfo(), | ||
Targets: srv.getTargetsInfo(), | ||
MetricMetadata: srv.getMetricMetadataInfo(), | ||
} | ||
|
||
return resp, nil | ||
} |
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
Oops, something went wrong.