-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hook up MetricsQueryService to main funcs #3079
Changes from 9 commits
29cc2da
b68914e
3756c35
188c1a1
f562a1f
99ea523
53a486b
c81a23c
2eaa9c3
64fa935
a8a420f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,7 +52,7 @@ type Server struct { | |
} | ||
|
||
// NewServer creates and initializes Server | ||
func NewServer(logger *zap.Logger, querySvc *querysvc.QueryService, options *QueryOptions, tracer opentracing.Tracer) (*Server, error) { | ||
func NewServer(logger *zap.Logger, querySvc *querysvc.QueryService, metricsQuerySvc *querysvc.MetricsQueryService, options *QueryOptions, tracer opentracing.Tracer) (*Server, error) { | ||
|
||
_, httpPort, err := net.SplitHostPort(options.HTTPHostPort) | ||
if err != nil { | ||
|
@@ -67,12 +67,12 @@ func NewServer(logger *zap.Logger, querySvc *querysvc.QueryService, options *Que | |
return nil, errors.New("server with TLS enabled can not use same host ports for gRPC and HTTP. Use dedicated HTTP and gRPC host ports instead") | ||
} | ||
|
||
grpcServer, err := createGRPCServer(querySvc, options, logger, tracer) | ||
grpcServer, err := createGRPCServer(querySvc, metricsQuerySvc, options, logger, tracer) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
httpServer, err := createHTTPServer(querySvc, options, tracer, logger) | ||
httpServer, err := createHTTPServer(querySvc, metricsQuerySvc, options, tracer, logger) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
@@ -94,7 +94,7 @@ func (s Server) HealthCheckStatus() chan healthcheck.Status { | |
return s.unavailableChannel | ||
} | ||
|
||
func createGRPCServer(querySvc *querysvc.QueryService, options *QueryOptions, logger *zap.Logger, tracer opentracing.Tracer) (*grpc.Server, error) { | ||
func createGRPCServer(querySvc *querysvc.QueryService, metricsQuerySvc *querysvc.MetricsQueryService, options *QueryOptions, logger *zap.Logger, tracer opentracing.Tracer) (*grpc.Server, error) { | ||
var grpcOpts []grpc.ServerOption | ||
|
||
if options.TLSGRPC.Enabled { | ||
|
@@ -111,11 +111,15 @@ func createGRPCServer(querySvc *querysvc.QueryService, options *QueryOptions, lo | |
server := grpc.NewServer(grpcOpts...) | ||
|
||
handler := NewGRPCHandler(querySvc, logger, tracer) | ||
|
||
// TODO: Register MetricsQueryService | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will be addressed in a follow-up PR implementing MetricsQuery support for the gRPC handler. |
||
api_v2.RegisterQueryServiceServer(server, handler) | ||
|
||
return server, nil | ||
} | ||
|
||
func createHTTPServer(querySvc *querysvc.QueryService, queryOpts *QueryOptions, tracer opentracing.Tracer, logger *zap.Logger) (*http.Server, error) { | ||
func createHTTPServer(querySvc *querysvc.QueryService, metricsQuerySvc *querysvc.MetricsQueryService, queryOpts *QueryOptions, tracer opentracing.Tracer, logger *zap.Logger) (*http.Server, error) { | ||
// TODO: Add HandlerOptions.MetricsQueryService | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will be addressed in a follow-up PR implementing MetricsQuery support for the HTTP handler. |
||
apiHandlerOptions := []HandlerOption{ | ||
HandlerOptions.Logger(logger), | ||
HandlerOptions.Tracer(tracer), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is
MetricsQueryService
supposed to add on top ofmetricsstore.Reader
?Note that we used to have HTTP handler use SpanReader directly, but then refactored it into QueryService because we needed to share it with GRPC Handler and the query service was an abstraction on top of two span readers: primary and archive. In your case there doesn't seem to be any additional abstraction needed, you just proxy all calls into the reader directly. Not a huge issue to leave as is, but just curious if there's any thinking that a layer of abstraction would be needed in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed
MetricsQueryService
adds little on top ofmetricsstore.Reader
. It has exactly the same function signature as the Reader and yes, it simply forwards the call. I also don't see a need for multiple metrics readers at runtime, for now at least.It was added to follow the same design as span/dependency querying to avoid confusing/surprising those following the code and seeing a
QueryService
being used by handlers to query spans/dependencies, then aReader
used to query metrics; when they may expect the handlers to refer to "QueryService" abstractions for querying spans, dependencies and metrics.One possibility to avoid confusion, yet minimizing unnecessary code, is to make
MetricsQueryService
an interface, embeddingmetricsstore.Reader
, meaning we can remove theMetricsQueryService
struct and its proxy functions altogether and simply give the handlers ametricsstore.Reader
instance. That way, handlers still refer to the "MetricsQueryService" alias for metrics, but instead using a Reader implementation. Something like: