-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[metrics][storage] Move metrics reader decorator to metrics storage factory #6287
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
Changes from 5 commits
a5cfa58
b7c9f59
449f08a
e7eb7cd
1144fe4
aa0323d
f2f6714
0d0921f
4842837
df0de70
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 |
---|---|---|
|
@@ -9,6 +9,7 @@ import ( | |
"github.com/spf13/viper" | ||
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.
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. @yurishkuro I can do that in a follow-up PR 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. we can also rename storage/metricsstore to storage/metricstore (single |
||
"go.uber.org/zap" | ||
|
||
"github.com/jaegertracing/jaeger/pkg/metrics" | ||
"github.com/jaegertracing/jaeger/plugin" | ||
"github.com/jaegertracing/jaeger/storage/metricsstore" | ||
) | ||
|
@@ -30,7 +31,7 @@ func (*Factory) AddFlags(_ *flag.FlagSet) {} | |
func (*Factory) InitFromViper(_ *viper.Viper, _ *zap.Logger) {} | ||
|
||
// Initialize implements storage.MetricsFactory. | ||
func (*Factory) Initialize(_ *zap.Logger) error { | ||
func (*Factory) Initialize(_ metrics.Factory, _ *zap.Logger) error { | ||
return nil | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -11,19 +11,22 @@ | |||||
"go.opentelemetry.io/otel/trace" | ||||||
"go.uber.org/zap" | ||||||
|
||||||
"github.com/jaegertracing/jaeger/pkg/metrics" | ||||||
"github.com/jaegertracing/jaeger/pkg/prometheus/config" | ||||||
"github.com/jaegertracing/jaeger/plugin" | ||||||
prometheusstore "github.com/jaegertracing/jaeger/plugin/metrics/prometheus/metricsstore" | ||||||
"github.com/jaegertracing/jaeger/storage/metricsstore" | ||||||
"github.com/jaegertracing/jaeger/storage/metricsstore/metricstoremetrics" | ||||||
) | ||||||
|
||||||
var _ plugin.Configurable = (*Factory)(nil) | ||||||
|
||||||
// Factory implements storage.Factory and creates storage components backed by memory store. | ||||||
type Factory struct { | ||||||
options *Options | ||||||
logger *zap.Logger | ||||||
tracer trace.TracerProvider | ||||||
options *Options | ||||||
logger *zap.Logger | ||||||
tracer trace.TracerProvider | ||||||
metricsFactory metrics.Factory | ||||||
} | ||||||
|
||||||
// NewFactory creates a new Factory. | ||||||
|
@@ -47,18 +50,23 @@ | |||||
} | ||||||
|
||||||
// Initialize implements storage.MetricsFactory. | ||||||
func (f *Factory) Initialize(logger *zap.Logger) error { | ||||||
f.logger = logger | ||||||
func (f *Factory) Initialize(metricsFactory metrics.Factory, logger *zap.Logger) error { | ||||||
f.metricsFactory, f.logger = metricsFactory, logger | ||||||
return nil | ||||||
} | ||||||
|
||||||
// CreateMetricsReader implements storage.MetricsFactory. | ||||||
func (f *Factory) CreateMetricsReader() (metricsstore.Reader, error) { | ||||||
return prometheusstore.NewMetricsReader(f.options.Configuration, f.logger, f.tracer) | ||||||
mr, err := prometheusstore.NewMetricsReader(f.options.Configuration, f.logger, f.tracer) | ||||||
if err != nil { | ||||||
return mr, err | ||||||
|
return mr, err | |
return nil, err |
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.
can we add a test?
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.
@yurishkuro We'll need to dip into the implementation of prometheusstore.NewMetricsReader
to force an error here. Is that fine? Also, since we're just decorating the reader, do we want to force returning a nil if there is an error? My thinking was that we just pass along whatever it is we get without decorating the reader.
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.
You can simulate the error easily by passing a TLS config with "foobar" for some of the certificates.
It is convention to return nil, err
in case of errors. It's probably what you would get from the factory already, but when you return mr, err
you are returning a typed nil, so the nil check may actually fail in the caller.
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.
@yurishkuro sounds good! i'll also go back and do the same for the other factories in a follow-up PR
mahadzaryab1 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.