-
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
[metrics][storage] Move metrics reader decorator to metrics storage factory #6287
Changes from 9 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 | ||||
---|---|---|---|---|---|---|
|
@@ -7,29 +7,29 @@ | |||||
"flag" | ||||||
|
||||||
"github.com/spf13/viper" | ||||||
"go.opentelemetry.io/otel" | ||||||
"go.opentelemetry.io/otel/trace" | ||||||
"go.uber.org/zap" | ||||||
|
||||||
"github.com/jaegertracing/jaeger/pkg/prometheus/config" | ||||||
"github.com/jaegertracing/jaeger/pkg/telemetry" | ||||||
"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 | ||||||
telset telemetry.Settings | ||||||
} | ||||||
|
||||||
// NewFactory creates a new Factory. | ||||||
func NewFactory() *Factory { | ||||||
telset := telemetry.NoopSettings() | ||||||
return &Factory{ | ||||||
tracer: otel.GetTracerProvider(), | ||||||
yurishkuro marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
telset: telset, | ||||||
options: NewOptions(), | ||||||
} | ||||||
} | ||||||
|
@@ -47,19 +47,23 @@ | |||||
} | ||||||
|
||||||
// Initialize implements storage.MetricsFactory. | ||||||
func (f *Factory) Initialize(logger *zap.Logger) error { | ||||||
f.logger = logger | ||||||
func (f *Factory) Initialize(telset telemetry.Settings) error { | ||||||
f.telset = telset | ||||||
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.telset.Logger, f.telset.TracerProvider) | ||||||
if err != nil { | ||||||
return mr, err | ||||||
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.
Suggested change
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. can we add a test? 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 We'll need to dip into the implementation of 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. You can simulate the error easily by passing a TLS config with "foobar" for some of the certificates. It is convention to return 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 sounds good! i'll also go back and do the same for the other factories in a follow-up PR |
||||||
} | ||||||
return metricstoremetrics.NewReaderDecorator(mr, f.telset.Metrics), nil | ||||||
} | ||||||
|
||||||
func NewFactoryWithConfig( | ||||||
cfg config.Configuration, | ||||||
logger *zap.Logger, | ||||||
telset telemetry.Settings, | ||||||
) (*Factory, error) { | ||||||
if err := cfg.Validate(); err != nil { | ||||||
return nil, err | ||||||
|
@@ -68,6 +72,6 @@ | |||||
f.options = &Options{ | ||||||
Configuration: cfg, | ||||||
} | ||||||
f.Initialize(logger) | ||||||
f.Initialize(telset) | ||||||
return f, nil | ||||||
} |
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.
plugin/metrics
is a bad name, we should rename it toplugin/metricstore
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 I can do that in a follow-up PR
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.
we can also rename storage/metricsstore to storage/metricstore (single
s
)