diff --git a/pkg/prometheus/config/config.go b/pkg/prometheus/config/config.go new file mode 100644 index 00000000000..494aa7bc2ff --- /dev/null +++ b/pkg/prometheus/config/config.go @@ -0,0 +1,23 @@ +// Copyright (c) 2021 The Jaeger Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package config + +import "time" + +// Configuration describes the options to customize the storage behavior. +type Configuration struct { + HostPort string `validate:"nonzero" mapstructure:"server"` + ConnectTimeout time.Duration `validate:"nonzero" mapstructure:"timeout"` +} diff --git a/pkg/prometheus/config/empty_test.go b/pkg/prometheus/config/empty_test.go new file mode 100644 index 00000000000..e32b13101a4 --- /dev/null +++ b/pkg/prometheus/config/empty_test.go @@ -0,0 +1,15 @@ +// Copyright (c) 2021 The Jaeger Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package config diff --git a/plugin/metrics/factory.go b/plugin/metrics/factory.go new file mode 100644 index 00000000000..73153e78732 --- /dev/null +++ b/plugin/metrics/factory.go @@ -0,0 +1,101 @@ +// Copyright (c) 2021 The Jaeger Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package metrics + +import ( + "flag" + "fmt" + + "github.com/spf13/viper" + "go.uber.org/zap" + + "github.com/jaegertracing/jaeger/plugin" + "github.com/jaegertracing/jaeger/plugin/metrics/prometheus" + "github.com/jaegertracing/jaeger/storage" + "github.com/jaegertracing/jaeger/storage/metricsstore" +) + +const ( + prometheusStorageType = "prometheus" +) + +// AllStorageTypes defines all available storage backends. +var AllStorageTypes = []string{prometheusStorageType} + +// Factory implements storage.Factory interface as a meta-factory for storage components. +type Factory struct { + FactoryConfig + factories map[string]storage.MetricsFactory +} + +// NewFactory creates the meta-factory. +func NewFactory(config FactoryConfig) (*Factory, error) { + f := &Factory{FactoryConfig: config} + uniqueTypes := map[string]struct{}{ + f.MetricsStorageType: {}, + } + f.factories = make(map[string]storage.MetricsFactory) + for t := range uniqueTypes { + ff, err := f.getFactoryOfType(t) + if err != nil { + return nil, err + } + f.factories[t] = ff + } + return f, nil +} + +func (f *Factory) getFactoryOfType(factoryType string) (storage.MetricsFactory, error) { + switch factoryType { + case prometheusStorageType: + return prometheus.NewFactory(), nil + } + return nil, fmt.Errorf("unknown metrics type %q. Valid types are %v", factoryType, AllStorageTypes) +} + +// Initialize implements storage.MetricsFactory. +func (f *Factory) Initialize(logger *zap.Logger) error { + for _, factory := range f.factories { + factory.Initialize(logger) + } + return nil +} + +// CreateMetricsReader implements storage.MetricsFactory. +func (f *Factory) CreateMetricsReader() (metricsstore.Reader, error) { + factory, ok := f.factories[f.MetricsStorageType] + if !ok { + return nil, fmt.Errorf("no %q backend registered for metrics store", f.MetricsStorageType) + } + return factory.CreateMetricsReader() +} + +// AddFlags implements plugin.Configurable. +func (f *Factory) AddFlags(flagSet *flag.FlagSet) { + for _, factory := range f.factories { + if conf, ok := factory.(plugin.Configurable); ok { + conf.AddFlags(flagSet) + } + } +} + +// InitFromViper implements plugin.Configurable. +func (f *Factory) InitFromViper(v *viper.Viper) { + for _, factory := range f.factories { + if conf, ok := factory.(plugin.Configurable); ok { + conf.InitFromViper(v) + } + } +} diff --git a/plugin/metrics/factory_config.go b/plugin/metrics/factory_config.go new file mode 100644 index 00000000000..28411dfccf2 --- /dev/null +++ b/plugin/metrics/factory_config.go @@ -0,0 +1,36 @@ +// Copyright (c) 2021 The Jaeger Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package metrics + +import ( + "os" +) + +const ( + // StorageTypeEnvVar is the name of the env var that defines the type of backend used for metrics storage. + StorageTypeEnvVar = "METRICS_STORAGE_TYPE" +) + +// FactoryConfig tells the Factory which types of backends it needs to create for different storage types. +type FactoryConfig struct { + MetricsStorageType string +} + +// FactoryConfigFromEnv reads the desired types of storage backends from METRICS_STORAGE_TYPE. +func FactoryConfigFromEnv() FactoryConfig { + return FactoryConfig{ + MetricsStorageType: os.Getenv(StorageTypeEnvVar), + } +} diff --git a/plugin/metrics/factory_config_test.go b/plugin/metrics/factory_config_test.go new file mode 100644 index 00000000000..82c9ad6aab1 --- /dev/null +++ b/plugin/metrics/factory_config_test.go @@ -0,0 +1,42 @@ +// Copyright (c) 2021 The Jaeger Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package metrics + +import ( + "os" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func clearEnv(t *testing.T) { + err := os.Setenv(StorageTypeEnvVar, "") + require.NoError(t, err) +} + +func TestFactoryConfigFromEnv(t *testing.T) { + clearEnv(t) + defer clearEnv(t) + + fc := FactoryConfigFromEnv() + assert.Empty(t, fc.MetricsStorageType) + + err := os.Setenv(StorageTypeEnvVar, prometheusStorageType) + require.NoError(t, err) + + fc = FactoryConfigFromEnv() + assert.Equal(t, prometheusStorageType, fc.MetricsStorageType) +} diff --git a/plugin/metrics/factory_test.go b/plugin/metrics/factory_test.go new file mode 100644 index 00000000000..49c770e8320 --- /dev/null +++ b/plugin/metrics/factory_test.go @@ -0,0 +1,108 @@ +// Copyright (c) 2021 The Jaeger Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package metrics + +import ( + "flag" + "testing" + + "github.com/spf13/viper" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.uber.org/zap" + + "github.com/jaegertracing/jaeger/storage" + "github.com/jaegertracing/jaeger/storage/mocks" +) + +var _ storage.MetricsFactory = new(Factory) + +func defaultCfg() FactoryConfig { + return FactoryConfig{ + MetricsStorageType: prometheusStorageType, + } +} + +func TestNewFactory(t *testing.T) { + f, err := NewFactory(defaultCfg()) + require.NoError(t, err) + assert.NotEmpty(t, f.factories) + assert.NotEmpty(t, f.factories[prometheusStorageType]) + assert.Equal(t, prometheusStorageType, f.MetricsStorageType) +} + +func TestUnsupportedMetricsStorageType(t *testing.T) { + f, err := NewFactory(FactoryConfig{MetricsStorageType: "foo"}) + require.Error(t, err) + assert.Nil(t, f) + assert.EqualError(t, err, `unknown metrics type "foo". Valid types are [prometheus]`) +} + +func TestCreateMetricsReader(t *testing.T) { + f, err := NewFactory(defaultCfg()) + require.NoError(t, err) + require.NotNil(t, f) + + require.NoError(t, f.Initialize(zap.NewNop())) + + reader, err := f.CreateMetricsReader() + require.NoError(t, err) + require.NotNil(t, reader) + + f.MetricsStorageType = "foo" + reader, err = f.CreateMetricsReader() + require.Error(t, err) + require.Nil(t, reader) + + assert.EqualError(t, err, `no "foo" backend registered for metrics store`) +} + +type configurable struct { + mocks.MetricsFactory + flagSet *flag.FlagSet + viper *viper.Viper +} + +// AddFlags implements plugin.Configurable. +func (f *configurable) AddFlags(flagSet *flag.FlagSet) { + f.flagSet = flagSet +} + +// InitFromViper implements plugin.Configurable. +func (f *configurable) InitFromViper(v *viper.Viper) { + f.viper = v +} + +func TestConfigurable(t *testing.T) { + clearEnv(t) + defer clearEnv(t) + + f, err := NewFactory(defaultCfg()) + require.NoError(t, err) + assert.NotEmpty(t, f.factories) + assert.NotEmpty(t, f.factories[prometheusStorageType]) + + mock := new(configurable) + f.factories[prometheusStorageType] = mock + + fs := new(flag.FlagSet) + v := viper.New() + + f.AddFlags(fs) + f.InitFromViper(v) + + assert.Equal(t, fs, mock.flagSet) + assert.Equal(t, v, mock.viper) +} diff --git a/plugin/metrics/prometheus/factory.go b/plugin/metrics/prometheus/factory.go new file mode 100644 index 00000000000..8435be82bda --- /dev/null +++ b/plugin/metrics/prometheus/factory.go @@ -0,0 +1,59 @@ +// Copyright (c) 2021 The Jaeger Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package prometheus + +import ( + "flag" + + "github.com/spf13/viper" + "go.uber.org/zap" + + prometheusstore "github.com/jaegertracing/jaeger/plugin/metrics/prometheus/metricsstore" + "github.com/jaegertracing/jaeger/storage/metricsstore" +) + +// Factory implements storage.Factory and creates storage components backed by memory store. +type Factory struct { + options *Options + logger *zap.Logger +} + +// NewFactory creates a new Factory. +func NewFactory() *Factory { + return &Factory{ + options: NewOptions("prometheus"), + } +} + +// AddFlags implements plugin.Configurable. +func (f *Factory) AddFlags(flagSet *flag.FlagSet) { + f.options.AddFlags(flagSet) +} + +// InitFromViper implements plugin.Configurable. +func (f *Factory) InitFromViper(v *viper.Viper) { + f.options.InitFromViper(v) +} + +// Initialize implements storage.MetricsFactory. +func (f *Factory) Initialize(logger *zap.Logger) error { + f.logger = logger + return nil +} + +// CreateMetricsReader implements storage.MetricsFactory. +func (f *Factory) CreateMetricsReader() (metricsstore.Reader, error) { + return prometheusstore.NewMetricsReader(f.logger, f.options.Primary.HostPort, f.options.Primary.ConnectTimeout) +} diff --git a/plugin/metrics/prometheus/factory_test.go b/plugin/metrics/prometheus/factory_test.go new file mode 100644 index 00000000000..bfa801b0220 --- /dev/null +++ b/plugin/metrics/prometheus/factory_test.go @@ -0,0 +1,68 @@ +// Copyright (c) 2021 The Jaeger Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package prometheus + +import ( + "net" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.uber.org/zap" + + "github.com/jaegertracing/jaeger/pkg/config" + "github.com/jaegertracing/jaeger/storage" +) + +var _ storage.MetricsFactory = new(Factory) + +func TestPrometheusFactory(t *testing.T) { + f := NewFactory() + assert.NoError(t, f.Initialize(zap.NewNop())) + assert.NotNil(t, f.logger) + assert.Equal(t, "prometheus", f.options.Primary.namespace) + + listener, err := net.Listen("tcp", "localhost:") + assert.NoError(t, err) + assert.NotNil(t, listener) + defer listener.Close() + + f.options.Primary.HostPort = listener.Addr().String() + reader, err := f.CreateMetricsReader() + + assert.NoError(t, err) + assert.NotNil(t, reader) +} + +func TestWithDefaultConfiguration(t *testing.T) { + f := NewFactory() + assert.Equal(t, f.options.Primary.HostPort, defaultServerHostPort) + assert.Equal(t, f.options.Primary.ConnectTimeout, defaultConnectTimeout) +} + +func TestWithConfiguration(t *testing.T) { + f := NewFactory() + v, command := config.Viperize(f.AddFlags) + err := command.ParseFlags([]string{ + "--prometheus.host-port=localhost:1234", + "--prometheus.connect-timeout=5s", + }) + require.NoError(t, err) + + f.InitFromViper(v) + assert.Equal(t, f.options.Primary.HostPort, "localhost:1234") + assert.Equal(t, f.options.Primary.ConnectTimeout, 5*time.Second) +} diff --git a/plugin/metrics/prometheus/options.go b/plugin/metrics/prometheus/options.go new file mode 100644 index 00000000000..8d346ef6c36 --- /dev/null +++ b/plugin/metrics/prometheus/options.go @@ -0,0 +1,77 @@ +// Copyright (c) 2021 The Jaeger Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package prometheus + +import ( + "flag" + "strings" + "time" + + "github.com/spf13/viper" + + "github.com/jaegertracing/jaeger/pkg/prometheus/config" +) + +const ( + suffixHostPort = ".host-port" + suffixConnectTimeout = ".connect-timeout" + + defaultServerHostPort = "localhost:9090" + defaultConnectTimeout = 30 * time.Second +) + +type namespaceConfig struct { + config.Configuration `mapstructure:",squash"` + namespace string +} + +// Options stores the configuration entries for this storage. +type Options struct { + Primary namespaceConfig `mapstructure:",squash"` +} + +// NewOptions creates a new Options struct. +func NewOptions(primaryNamespace string) *Options { + defaultConfig := config.Configuration{ + HostPort: defaultServerHostPort, + ConnectTimeout: defaultConnectTimeout, + } + + return &Options{ + Primary: namespaceConfig{ + Configuration: defaultConfig, + namespace: primaryNamespace, + }, + } +} + +// AddFlags from this storage to the CLI. +func (opt *Options) AddFlags(flagSet *flag.FlagSet) { + nsConfig := &opt.Primary + flagSet.String(nsConfig.namespace+suffixHostPort, defaultServerHostPort, "The host:port of the Prometheus query service.") + flagSet.Duration(nsConfig.namespace+suffixConnectTimeout, defaultConnectTimeout, "The period to wait for a connection to Prometheus when executing queries.") +} + +// InitFromViper initializes the options struct with values from Viper. +func (opt *Options) InitFromViper(v *viper.Viper) { + cfg := &opt.Primary + cfg.HostPort = stripWhiteSpace(v.GetString(cfg.namespace + suffixHostPort)) + cfg.ConnectTimeout = v.GetDuration(cfg.namespace + suffixConnectTimeout) +} + +// stripWhiteSpace removes all whitespace characters from a string. +func stripWhiteSpace(str string) string { + return strings.Replace(str, " ", "", -1) +} diff --git a/storage/factory.go b/storage/factory.go index c8c2bbd996c..3e69d53d40c 100644 --- a/storage/factory.go +++ b/storage/factory.go @@ -22,6 +22,7 @@ import ( "go.uber.org/zap" "github.com/jaegertracing/jaeger/storage/dependencystore" + metricsstore "github.com/jaegertracing/jaeger/storage/metricsstore" "github.com/jaegertracing/jaeger/storage/spanstore" ) @@ -62,3 +63,18 @@ type ArchiveFactory interface { // CreateArchiveSpanWriter creates a spanstore.Writer. CreateArchiveSpanWriter() (spanstore.Writer, error) } + +// MetricsFactory defines an interface for a factory that can create implementations of different metrics storage components. +// Implementations are also encouraged to implement plugin.Configurable interface. +// +// See also +// +// plugin.Configurable +type MetricsFactory interface { + // Initialize performs internal initialization of the factory, such as opening connections to the backend store. + // It is called after all configuration of the factory itself has been done. + Initialize(logger *zap.Logger) error + + // CreateMetricsReader creates a metricsstore.Reader. + CreateMetricsReader() (metricsstore.Reader, error) +} diff --git a/storage/metricsstore/mocks/Reader.go b/storage/metricsstore/mocks/Reader.go new file mode 100644 index 00000000000..62faa95d36a --- /dev/null +++ b/storage/metricsstore/mocks/Reader.go @@ -0,0 +1,123 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. + +// Copyright (c) 2021 The Jaeger Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + +package mocks + +import ( + context "context" + time "time" + + mock "github.com/stretchr/testify/mock" + + metrics "github.com/jaegertracing/jaeger/proto-gen/api_v2/metrics" + metricsstore "github.com/jaegertracing/jaeger/storage/metricsstore" +) + +// Reader is an autogenerated mock type for the Reader type +type Reader struct { + mock.Mock +} + +// GetCallRates provides a mock function with given fields: ctx, params +func (_m *Reader) GetCallRates(ctx context.Context, params *metricsstore.CallRateQueryParameters) (*metrics.MetricFamily, error) { + ret := _m.Called(ctx, params) + + var r0 *metrics.MetricFamily + if rf, ok := ret.Get(0).(func(context.Context, *metricsstore.CallRateQueryParameters) *metrics.MetricFamily); ok { + r0 = rf(ctx, params) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*metrics.MetricFamily) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, *metricsstore.CallRateQueryParameters) error); ok { + r1 = rf(ctx, params) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetErrorRates provides a mock function with given fields: ctx, params +func (_m *Reader) GetErrorRates(ctx context.Context, params *metricsstore.ErrorRateQueryParameters) (*metrics.MetricFamily, error) { + ret := _m.Called(ctx, params) + + var r0 *metrics.MetricFamily + if rf, ok := ret.Get(0).(func(context.Context, *metricsstore.ErrorRateQueryParameters) *metrics.MetricFamily); ok { + r0 = rf(ctx, params) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*metrics.MetricFamily) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, *metricsstore.ErrorRateQueryParameters) error); ok { + r1 = rf(ctx, params) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetLatencies provides a mock function with given fields: ctx, params +func (_m *Reader) GetLatencies(ctx context.Context, params *metricsstore.LatenciesQueryParameters) (*metrics.MetricFamily, error) { + ret := _m.Called(ctx, params) + + var r0 *metrics.MetricFamily + if rf, ok := ret.Get(0).(func(context.Context, *metricsstore.LatenciesQueryParameters) *metrics.MetricFamily); ok { + r0 = rf(ctx, params) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*metrics.MetricFamily) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, *metricsstore.LatenciesQueryParameters) error); ok { + r1 = rf(ctx, params) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// GetMinStepDuration provides a mock function with given fields: ctx, params +func (_m *Reader) GetMinStepDuration(ctx context.Context, params *metricsstore.MinStepDurationQueryParameters) (time.Duration, error) { + ret := _m.Called(ctx, params) + + var r0 time.Duration + if rf, ok := ret.Get(0).(func(context.Context, *metricsstore.MinStepDurationQueryParameters) time.Duration); ok { + r0 = rf(ctx, params) + } else { + r0 = ret.Get(0).(time.Duration) + } + + var r1 error + if rf, ok := ret.Get(1).(func(context.Context, *metricsstore.MinStepDurationQueryParameters) error); ok { + r1 = rf(ctx, params) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} diff --git a/storage/mocks/MetricsFactory.go b/storage/mocks/MetricsFactory.go new file mode 100644 index 00000000000..2a0c3bee555 --- /dev/null +++ b/storage/mocks/MetricsFactory.go @@ -0,0 +1,66 @@ +// Copyright (c) 2021 The Jaeger Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by mockery v1.0.0. DO NOT EDIT. + +package mocks + +import ( + mock "github.com/stretchr/testify/mock" + zap "go.uber.org/zap" + + metricsstore "github.com/jaegertracing/jaeger/storage/metricsstore" +) + +// MetricsFactory is an autogenerated mock type for the MetricsFactory type +type MetricsFactory struct { + mock.Mock +} + +// CreateMetricsReader provides a mock function with given fields: +func (_m *MetricsFactory) CreateMetricsReader() (metricsstore.Reader, error) { + ret := _m.Called() + + var r0 metricsstore.Reader + if rf, ok := ret.Get(0).(func() metricsstore.Reader); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(metricsstore.Reader) + } + } + + var r1 error + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Initialize provides a mock function with given fields: logger +func (_m *MetricsFactory) Initialize(logger *zap.Logger) error { + ret := _m.Called(logger) + + var r0 error + if rf, ok := ret.Get(0).(func(*zap.Logger) error); ok { + r0 = rf(logger) + } else { + r0 = ret.Error(0) + } + + return r0 +}