diff --git a/cmd/query/main.go b/cmd/query/main.go index 7d9e40d12e6..770381109d0 100644 --- a/cmd/query/main.go +++ b/cmd/query/main.go @@ -169,16 +169,23 @@ func main() { } func archiveOptions(storageFactory istorage.Factory, logger *zap.Logger) []app.HandlerOption { - reader, err := storageFactory.CreateSpanReader() + archiveFactory, ok := storageFactory.(istorage.ArchiveFactory) + if !ok { + logger.Info("Archive storage not supported by the factory") + return nil + } + reader, err := archiveFactory.CreateArchiveSpanReader() if err == istorage.ErrArchiveStorageNotConfigured || err == istorage.ErrArchiveStorageNotSupported { + logger.Info("Archive storage not created", zap.String("reason", err.Error())) return nil } if err != nil { logger.Error("Cannot init archive storage reader", zap.Error(err)) return nil } - writer, err := storageFactory.CreateSpanWriter() + writer, err := archiveFactory.CreateArchiveSpanWriter() if err == istorage.ErrArchiveStorageNotConfigured || err == istorage.ErrArchiveStorageNotSupported { + logger.Info("Archive storage not created", zap.String("reason", err.Error())) return nil } if err != nil { diff --git a/examples/hotrod/cmd/root.go b/examples/hotrod/cmd/root.go index e87f4552068..07eb368749c 100644 --- a/examples/hotrod/cmd/root.go +++ b/examples/hotrod/cmd/root.go @@ -21,8 +21,7 @@ import ( "github.com/spf13/cobra" "github.com/uber/jaeger-lib/metrics" - "github.com/uber/jaeger-lib/metrics/go-kit" - "github.com/uber/jaeger-lib/metrics/go-kit/expvar" + jexpvar "github.com/uber/jaeger-lib/metrics/expvar" jprom "github.com/uber/jaeger-lib/metrics/prometheus" "go.uber.org/zap" ) @@ -61,7 +60,7 @@ func init() { // initMetrics is called before the command is executed. func initMetrics() { if metricsBackend == "expvar" { - metricsFactory = xkit.Wrap("", expvar.NewFactory(10)) // 10 buckets for histograms + metricsFactory = jexpvar.NewFactory(10) // 10 buckets for histograms logger.Info("Using expvar as metrics backend") } else if metricsBackend == "prometheus" { metricsFactory = jprom.New() diff --git a/glide.lock b/glide.lock index 147488d7acd..77f390d3579 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ -hash: a471ba65985cd8da353da17ba52ea1ce163fde53e469d02f053bde78f647d779 -updated: 2018-02-22T17:30:31.965001235+01:00 +hash: b40b5983c6baf2db7a7b72dfc9fe4a7168a7eef31292840999544ad9862db3e5 +updated: 2018-03-05T17:31:52.001803-05:00 imports: - name: github.com/apache/thrift version: 53dd39833a08ce33582e5ff31fa18bb4735d6731 @@ -19,7 +19,7 @@ imports: - assert - require - name: github.com/davecgh/go-spew - version: 8991bc29aa16c548c550c7ff78260e27b9ab7c73 + version: ecdeabc65495df2dec95d7c4a4c3e021903035e5 subpackages: - spew - name: github.com/fsnotify/fsnotify @@ -192,9 +192,11 @@ imports: - transport/zipkin - utils - name: github.com/uber/jaeger-lib - version: 7f95f4f7e80028096410abddaae2556e4c61b59f + version: 4267858c0679cd4e47cefed8d7f70fd386cfb567 subpackages: - metrics + - metrics/adapters + - metrics/expvar - metrics/go-kit - metrics/go-kit/expvar - metrics/prometheus @@ -228,7 +230,7 @@ imports: - zapcore - zaptest - name: golang.org/x/net - version: cbe0f9307d0156177f9dd5dc85da1a31abc5f2fb + version: 5ccada7d0a7ba9aeb5d3aca8d3501b4c2a509fec subpackages: - context - context/ctxhttp diff --git a/glide.yaml b/glide.yaml index 77689311203..0c734b06bc2 100644 --- a/glide.yaml +++ b/glide.yaml @@ -17,7 +17,7 @@ import: subpackages: - transport - package: github.com/uber/jaeger-lib - version: ^1.2.1 + version: ^1.4.0 - package: github.com/uber/tchannel-go version: v1.1.0 subpackages: diff --git a/pkg/metrics/builder.go b/pkg/metrics/builder.go index b083f6f466d..f64bbea3016 100644 --- a/pkg/metrics/builder.go +++ b/pkg/metrics/builder.go @@ -23,8 +23,7 @@ import ( "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/spf13/viper" "github.com/uber/jaeger-lib/metrics" - xkit "github.com/uber/jaeger-lib/metrics/go-kit" - kitexpvar "github.com/uber/jaeger-lib/metrics/go-kit/expvar" + jexpvar "github.com/uber/jaeger-lib/metrics/expvar" jprom "github.com/uber/jaeger-lib/metrics/prometheus" ) @@ -73,7 +72,7 @@ func (b *Builder) CreateMetricsFactory(namespace string) (metrics.Factory, error return metricsFactory, nil } if b.Backend == "expvar" { - metricsFactory := xkit.Wrap(namespace, kitexpvar.NewFactory(10)) + metricsFactory := jexpvar.NewFactory(10).Namespace(namespace, nil) b.handler = expvar.Handler() return metricsFactory, nil } diff --git a/plugin/storage/cassandra/factory.go b/plugin/storage/cassandra/factory.go index 1f19c787a12..b92802b66c0 100644 --- a/plugin/storage/cassandra/factory.go +++ b/plugin/storage/cassandra/factory.go @@ -39,8 +39,9 @@ const ( type Factory struct { Options *Options - metricsFactory metrics.Factory - logger *zap.Logger + primaryMetricsFactory metrics.Factory + archiveMetricsFactory metrics.Factory + logger *zap.Logger primaryConfig config.SessionBuilder primarySession cassandra.Session @@ -71,7 +72,9 @@ func (f *Factory) InitFromViper(v *viper.Viper) { // Initialize implements storage.Factory func (f *Factory) Initialize(metricsFactory metrics.Factory, logger *zap.Logger) error { - f.metricsFactory, f.logger = metricsFactory, logger + f.primaryMetricsFactory = metricsFactory.Namespace("cassandra", nil) + f.archiveMetricsFactory = metricsFactory.Namespace("cassandra-archive", nil) + f.logger = logger primarySession, err := f.primaryConfig.NewSession() if err != nil { @@ -85,23 +88,25 @@ func (f *Factory) Initialize(metricsFactory metrics.Factory, logger *zap.Logger) } else { return err } + } else { + logger.Info("Cassandra archive storage configuration is empty, skipping") } return nil } // CreateSpanReader implements storage.Factory func (f *Factory) CreateSpanReader() (spanstore.Reader, error) { - return cSpanStore.NewSpanReader(f.primarySession, f.metricsFactory, f.logger), nil + return cSpanStore.NewSpanReader(f.primarySession, f.primaryMetricsFactory, f.logger), nil } // CreateSpanWriter implements storage.Factory func (f *Factory) CreateSpanWriter() (spanstore.Writer, error) { - return cSpanStore.NewSpanWriter(f.primarySession, f.Options.SpanStoreWriteCacheTTL, f.metricsFactory, f.logger), nil + return cSpanStore.NewSpanWriter(f.primarySession, f.Options.SpanStoreWriteCacheTTL, f.primaryMetricsFactory, f.logger), nil } // CreateDependencyReader implements storage.Factory func (f *Factory) CreateDependencyReader() (dependencystore.Reader, error) { - return cDepStore.NewDependencyStore(f.primarySession, f.Options.DepStoreDataFrequency, f.metricsFactory, f.logger), nil + return cDepStore.NewDependencyStore(f.primarySession, f.Options.DepStoreDataFrequency, f.primaryMetricsFactory, f.logger), nil } // CreateArchiveSpanReader implements storage.ArchiveFactory @@ -109,7 +114,7 @@ func (f *Factory) CreateArchiveSpanReader() (spanstore.Reader, error) { if f.archiveSession == nil { return nil, storage.ErrArchiveStorageNotConfigured } - return cSpanStore.NewSpanReader(f.archiveSession, f.metricsFactory, f.logger), nil + return cSpanStore.NewSpanReader(f.archiveSession, f.archiveMetricsFactory, f.logger), nil } // CreateArchiveSpanWriter implements storage.ArchiveFactory @@ -117,5 +122,5 @@ func (f *Factory) CreateArchiveSpanWriter() (spanstore.Writer, error) { if f.archiveSession == nil { return nil, storage.ErrArchiveStorageNotConfigured } - return cSpanStore.NewSpanWriter(f.archiveSession, f.Options.SpanStoreWriteCacheTTL, f.metricsFactory, f.logger), nil + return cSpanStore.NewSpanWriter(f.archiveSession, f.Options.SpanStoreWriteCacheTTL, f.archiveMetricsFactory, f.logger), nil } diff --git a/plugin/storage/cassandra/factory_test.go b/plugin/storage/cassandra/factory_test.go index a2aff330f0f..078c008cf71 100644 --- a/plugin/storage/cassandra/factory_test.go +++ b/plugin/storage/cassandra/factory_test.go @@ -25,6 +25,7 @@ import ( "github.com/jaegertracing/jaeger/pkg/cassandra" "github.com/jaegertracing/jaeger/pkg/cassandra/mocks" "github.com/jaegertracing/jaeger/pkg/config" + "github.com/jaegertracing/jaeger/pkg/testutils" "github.com/jaegertracing/jaeger/storage" ) @@ -43,6 +44,7 @@ func (m *mockSessionBuilder) NewSession() (cassandra.Session, error) { } func TestCassandraFactory(t *testing.T) { + logger, logBuf := testutils.NewLogger() f := NewFactory() v, command := config.Viperize(f.AddFlags) command.ParseFlags([]string{"--cassandra-archive.enabled=true"}) @@ -58,7 +60,8 @@ func TestCassandraFactory(t *testing.T) { assert.EqualError(t, f.Initialize(metrics.NullFactory, zap.NewNop()), "made-up error") f.archiveConfig = nil - assert.NoError(t, f.Initialize(metrics.NullFactory, zap.NewNop())) + assert.NoError(t, f.Initialize(metrics.NullFactory, logger)) + assert.Contains(t, logBuf.String(), "Cassandra archive storage configuration is empty, skipping") _, err := f.CreateSpanReader() assert.NoError(t, err)