From f23484b9f2431b73cc0e12c8da911560ab9ec11d Mon Sep 17 00:00:00 2001 From: Ashmita Date: Tue, 22 Jun 2021 01:00:43 +1000 Subject: [PATCH] Badger: v1 to v3 upgrade (#3096) * Badger: v1 to v3 upgrade Signed-off-by: Ashmita Bohara * Increase codecov Signed-off-by: Ashmita Bohara * Implement feedbacks Signed-off-by: Ashmita Bohara * Implement feedbacks Signed-off-by: Ashmita Bohara * Implement feedbacks Signed-off-by: Ashmita Bohara * Implement feedbacks Signed-off-by: Ashmita Bohara * Remove unnessary logger passing Signed-off-by: Ashmita Bohara * Feedbacks Signed-off-by: Ashmita Bohara * Feedbacks Signed-off-by: Ashmita Bohara --- CHANGELOG.md | 10 +++++++ cmd/all-in-one/main.go | 6 ++-- cmd/collector/main.go | 4 +-- cmd/ingester/main.go | 2 +- cmd/query/main.go | 4 +-- go.mod | 3 +- go.sum | 21 ++++++++------ plugin/configurable.go | 3 +- plugin/metrics/disabled/factory.go | 2 +- plugin/metrics/disabled/factory_test.go | 2 +- plugin/metrics/factory.go | 4 +-- plugin/metrics/factory_test.go | 6 ++-- plugin/metrics/prometheus/factory.go | 2 +- plugin/metrics/prometheus/factory_test.go | 2 +- .../strategystore/adaptive/factory.go | 2 +- .../strategystore/adaptive/factory_test.go | 2 +- plugin/sampling/strategystore/factory.go | 4 +-- plugin/sampling/strategystore/factory_test.go | 6 ++-- .../sampling/strategystore/static/factory.go | 2 +- .../strategystore/static/factory_test.go | 2 +- .../badger/dependencystore/storage_test.go | 2 +- plugin/storage/badger/factory.go | 9 ++---- plugin/storage/badger/factory_test.go | 28 +++++++++---------- plugin/storage/badger/options.go | 19 ++++++++----- plugin/storage/badger/options_test.go | 9 +++--- plugin/storage/badger/spanstore/cache.go | 2 +- plugin/storage/badger/spanstore/cache_test.go | 2 +- .../badger/spanstore/read_write_test.go | 6 ++-- plugin/storage/badger/spanstore/reader.go | 2 +- .../badger/spanstore/rw_internal_test.go | 2 +- plugin/storage/badger/spanstore/writer.go | 2 +- plugin/storage/badger/stats_linux_test.go | 2 +- plugin/storage/badger/stats_test.go | 2 +- plugin/storage/cassandra/factory.go | 2 +- plugin/storage/cassandra/factory_test.go | 4 +-- plugin/storage/es/factory.go | 2 +- plugin/storage/es/factory_test.go | 2 +- plugin/storage/factory.go | 4 +-- plugin/storage/factory_test.go | 12 ++++---- plugin/storage/grpc/factory.go | 2 +- plugin/storage/grpc/factory_test.go | 12 ++++---- plugin/storage/integration/cassandra_test.go | 2 +- plugin/storage/integration/grpc_test.go | 2 +- plugin/storage/integration/kafka_test.go | 2 +- plugin/storage/kafka/factory.go | 2 +- plugin/storage/kafka/factory_test.go | 8 +++--- plugin/storage/memory/factory.go | 2 +- plugin/storage/memory/factory_test.go | 4 +-- 48 files changed, 131 insertions(+), 107 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41db28e3aa9..d906d677e2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,16 @@ Changes by Version ================== +Unreleased +------------------- +### Backend Changes + +#### Breaking Changes + +* Upgrade Badger from v1.6.2 to v3.2103.0 ([#3096](https://github.com/jaegertracing/jaeger/pull/3096), [@Ashmita152](https://github.com/Ashmita152)): + * Deprecated `--badger.truncate` flag. + * All badger related expvar prefix has changed from `badger` to `badger_v3`. + 1.23.0 (2021-06-04) ------------------- ### Backend Changes diff --git a/cmd/all-in-one/main.go b/cmd/all-in-one/main.go index 8571f829f12..a22598b8382 100644 --- a/cmd/all-in-one/main.go +++ b/cmd/all-in-one/main.go @@ -97,7 +97,7 @@ by default uses only in-memory database.`, tracerCloser := initTracer(rootMetricsFactory, svc.Logger) - storageFactory.InitFromViper(v) + storageFactory.InitFromViper(v, logger) if err := storageFactory.Initialize(metricsFactory, logger); err != nil { logger.Fatal("Failed to init storage factory", zap.Error(err)) } @@ -120,7 +120,7 @@ by default uses only in-memory database.`, logger.Fatal("Failed to create metrics reader", zap.Error(err)) } - strategyStoreFactory.InitFromViper(v) + strategyStoreFactory.InitFromViper(v, logger) if err := strategyStoreFactory.Initialize(metricsFactory, logger); err != nil { logger.Fatal("Failed to init sampling strategy store factory", zap.Error(err)) } @@ -293,6 +293,6 @@ func createMetricsQueryService(factory *metricsPlugin.Factory, v *viper.Viper, l } // Ensure default parameter values are loaded correctly. - factory.InitFromViper(v) + factory.InitFromViper(v, logger) return factory.CreateMetricsReader() } diff --git a/cmd/collector/main.go b/cmd/collector/main.go index 87d24ba5b9a..383409d6bb6 100644 --- a/cmd/collector/main.go +++ b/cmd/collector/main.go @@ -70,7 +70,7 @@ func main() { jexpvar.NewFactory(10), // backend for internal opts baseFactory.Namespace(metrics.NSOptions{Name: "collector"})) - storageFactory.InitFromViper(v) + storageFactory.InitFromViper(v, logger) if err := storageFactory.Initialize(baseFactory, logger); err != nil { logger.Fatal("Failed to init storage factory", zap.Error(err)) } @@ -79,7 +79,7 @@ func main() { logger.Fatal("Failed to create span writer", zap.Error(err)) } - strategyStoreFactory.InitFromViper(v) + strategyStoreFactory.InitFromViper(v, logger) if err := strategyStoreFactory.Initialize(metricsFactory, logger); err != nil { logger.Fatal("Failed to init sampling strategy store factory", zap.Error(err)) } diff --git a/cmd/ingester/main.go b/cmd/ingester/main.go index 4a4d36fa4bd..f1c25bbd94d 100644 --- a/cmd/ingester/main.go +++ b/cmd/ingester/main.go @@ -59,7 +59,7 @@ func main() { baseFactory := svc.MetricsFactory.Namespace(metrics.NSOptions{Name: "jaeger"}) metricsFactory := baseFactory.Namespace(metrics.NSOptions{Name: "ingester"}) - storageFactory.InitFromViper(v) + storageFactory.InitFromViper(v, logger) if err := storageFactory.Initialize(baseFactory, logger); err != nil { logger.Fatal("Failed to init storage factory", zap.Error(err)) } diff --git a/cmd/query/main.go b/cmd/query/main.go index cc012180597..14439aa33c0 100644 --- a/cmd/query/main.go +++ b/cmd/query/main.go @@ -95,7 +95,7 @@ func main() { queryOpts := new(app.QueryOptions).InitFromViper(v, logger) // TODO: Need to figure out set enable/disable propagation on storage plugins. v.Set(spanstore.StoragePropagationKey, queryOpts.BearerTokenPropagation) - storageFactory.InitFromViper(v) + storageFactory.InitFromViper(v, logger) if err := storageFactory.Initialize(baseFactory, logger); err != nil { logger.Fatal("Failed to init storage factory", zap.Error(err)) } @@ -169,6 +169,6 @@ func createMetricsQueryService(factory *metricsPlugin.Factory, v *viper.Viper, l } // Ensure default parameter values are loaded correctly. - factory.InitFromViper(v) + factory.InitFromViper(v, logger) return factory.CreateMetricsReader() } diff --git a/go.mod b/go.mod index 27918dde9ef..0924ae1805d 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,8 @@ require ( github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect github.com/bsm/sarama-cluster v2.1.13+incompatible github.com/crossdock/crossdock-go v0.0.0-20160816171116-049aabb0122b - github.com/dgraph-io/badger v1.6.2 + github.com/dgraph-io/badger/v3 v3.2103.0 + github.com/dgraph-io/ristretto v0.1.0 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/fatih/color v1.9.0 // indirect github.com/fsnotify/fsnotify v1.4.9 diff --git a/go.sum b/go.sum index e6ceee89ab7..be113473025 100644 --- a/go.sum +++ b/go.sum @@ -37,11 +37,11 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96 h1:cTp8I5+VIoKjsnZuH8vjyaysT/ses3EvZeaV/1UkF2M= -github.com/AndreasBriese/bbloom v0.0.0-20190825152654-46b345b51c96/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/DataDog/zstd v1.4.1 h1:3oxKN3wbHibqx897utPC2LTQU4J+IHWWJO+glkAkpFM= +github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= github.com/HdrHistogram/hdrhistogram-go v0.9.0 h1:dpujRju0R4M/QZzcnR1LH1qm+TVG3UzkWdp5tH1WMcg= github.com/HdrHistogram/hdrhistogram-go v0.9.0/go.mod h1:nxrse8/Tzg2tg3DZcZjm6qEclQKK70g0KxO61gFFZD4= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= @@ -136,10 +136,11 @@ github.com/crossdock/crossdock-go v0.0.0-20160816171116-049aabb0122b/go.mod h1:v github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgraph-io/badger v1.6.2 h1:mNw0qs90GVgGGWylh0umH5iag1j6n/PeJtNvL6KY/x8= -github.com/dgraph-io/badger v1.6.2/go.mod h1:JW2yswe3V058sS0kZ2h/AXeDSqFjxnZcRrVH//y2UQE= -github.com/dgraph-io/ristretto v0.0.2 h1:a5WaUrDa0qm0YrAAS1tUykT5El3kt62KNZZeMxQn3po= -github.com/dgraph-io/ristretto v0.0.2/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= +github.com/dgraph-io/badger/v3 v3.2103.0 h1:abkD2EnP3+6Tj8h5LI1y00dJ9ICKTIAzvG9WmZ8S2c4= +github.com/dgraph-io/badger/v3 v3.2103.0/go.mod h1:GHMCYxuDWyzbHkh4k3yyg4PM61tJPFfEGSMbE3Vd5QE= +github.com/dgraph-io/ristretto v0.0.4-0.20210309073149-3836124cdc5a/go.mod h1:MIonLggsKgZLUSt414ExgwNtlOL5MuEoAJP514mwGe8= +github.com/dgraph-io/ristretto v0.1.0 h1:Jv3CGQHp9OjuMBSne1485aDpUkTKEcUqF+jm/LuerPI= +github.com/dgraph-io/ristretto v0.1.0/go.mod h1:fux0lOrBhrVCJd3lcTHsIJhq1T2rokOu6v9Vcb3Q9ug= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= @@ -327,11 +328,13 @@ github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e h1:1r7pUrabqp18hOBcwBwiTsbnFeTZHV9eER/QT5JVZxY= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= @@ -367,6 +370,8 @@ github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/flatbuffers v1.12.0 h1:/PtAHvnBY4Kqnx/xCQ3OIV9uYcSFGScBsWI3Oogeh6w= +github.com/google/flatbuffers v1.12.0/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -520,7 +525,6 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxv github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -820,6 +824,8 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= @@ -998,7 +1004,6 @@ golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= diff --git a/plugin/configurable.go b/plugin/configurable.go index 324926a24ff..20872798630 100644 --- a/plugin/configurable.go +++ b/plugin/configurable.go @@ -19,6 +19,7 @@ import ( "flag" "github.com/spf13/viper" + "go.uber.org/zap" ) // Configurable interface can be implemented by plugins that require external configuration, @@ -28,5 +29,5 @@ type Configurable interface { AddFlags(flagSet *flag.FlagSet) // InitFromViper initializes this component with properties from spf13/viper. - InitFromViper(v *viper.Viper) + InitFromViper(v *viper.Viper, logger *zap.Logger) } diff --git a/plugin/metrics/disabled/factory.go b/plugin/metrics/disabled/factory.go index fec3f45c9bf..c3ec9800caf 100644 --- a/plugin/metrics/disabled/factory.go +++ b/plugin/metrics/disabled/factory.go @@ -35,7 +35,7 @@ func NewFactory() *Factory { func (f *Factory) AddFlags(_ *flag.FlagSet) {} // InitFromViper implements plugin.Configurable. -func (f *Factory) InitFromViper(_ *viper.Viper) {} +func (f *Factory) InitFromViper(_ *viper.Viper, _ *zap.Logger) {} // Initialize implements storage.MetricsFactory. func (f *Factory) Initialize(_ *zap.Logger) error { diff --git a/plugin/metrics/disabled/factory_test.go b/plugin/metrics/disabled/factory_test.go index 4f1d1444e7b..31884e0a7b0 100644 --- a/plugin/metrics/disabled/factory_test.go +++ b/plugin/metrics/disabled/factory_test.go @@ -34,7 +34,7 @@ func TestPrometheusFactory(t *testing.T) { require.NoError(t, err) f.AddFlags(nil) - f.InitFromViper(nil) + f.InitFromViper(nil, zap.NewNop()) reader, err := f.CreateMetricsReader() assert.NoError(t, err) diff --git a/plugin/metrics/factory.go b/plugin/metrics/factory.go index 433be025b8f..d2be4d7cf7f 100644 --- a/plugin/metrics/factory.go +++ b/plugin/metrics/factory.go @@ -98,10 +98,10 @@ func (f *Factory) AddFlags(flagSet *flag.FlagSet) { } // InitFromViper implements plugin.Configurable. -func (f *Factory) InitFromViper(v *viper.Viper) { +func (f *Factory) InitFromViper(v *viper.Viper, logger *zap.Logger) { for _, factory := range f.factories { if conf, ok := factory.(plugin.Configurable); ok { - conf.InitFromViper(v) + conf.InitFromViper(v, logger) } } } diff --git a/plugin/metrics/factory_test.go b/plugin/metrics/factory_test.go index fe8c4e1592b..13a9444beb6 100644 --- a/plugin/metrics/factory_test.go +++ b/plugin/metrics/factory_test.go @@ -82,6 +82,7 @@ type configurable struct { mocks.MetricsFactory flagSet *flag.FlagSet viper *viper.Viper + logger *zap.Logger } // AddFlags implements plugin.Configurable. @@ -90,8 +91,9 @@ func (f *configurable) AddFlags(flagSet *flag.FlagSet) { } // InitFromViper implements plugin.Configurable. -func (f *configurable) InitFromViper(v *viper.Viper) { +func (f *configurable) InitFromViper(v *viper.Viper, logger *zap.Logger) { f.viper = v + f.logger = logger } func TestConfigurable(t *testing.T) { @@ -110,7 +112,7 @@ func TestConfigurable(t *testing.T) { v := viper.New() f.AddFlags(fs) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) 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 index 31802418a0d..cfae05928f8 100644 --- a/plugin/metrics/prometheus/factory.go +++ b/plugin/metrics/prometheus/factory.go @@ -43,7 +43,7 @@ func (f *Factory) AddFlags(flagSet *flag.FlagSet) { } // InitFromViper implements plugin.Configurable. -func (f *Factory) InitFromViper(v *viper.Viper) { +func (f *Factory) InitFromViper(v *viper.Viper, logger *zap.Logger) { f.options.InitFromViper(v) } diff --git a/plugin/metrics/prometheus/factory_test.go b/plugin/metrics/prometheus/factory_test.go index e3b028a020b..bd8f6f1405b 100644 --- a/plugin/metrics/prometheus/factory_test.go +++ b/plugin/metrics/prometheus/factory_test.go @@ -62,7 +62,7 @@ func TestWithConfiguration(t *testing.T) { }) require.NoError(t, err) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) assert.Equal(t, f.options.Primary.ServerURL, "http://localhost:1234") assert.Equal(t, f.options.Primary.ConnectTimeout, 5*time.Second) } diff --git a/plugin/sampling/strategystore/adaptive/factory.go b/plugin/sampling/strategystore/adaptive/factory.go index 70c967337fc..76da40a9740 100644 --- a/plugin/sampling/strategystore/adaptive/factory.go +++ b/plugin/sampling/strategystore/adaptive/factory.go @@ -45,7 +45,7 @@ func (f *Factory) AddFlags(flagSet *flag.FlagSet) { } // InitFromViper implements plugin.Configurable -func (f *Factory) InitFromViper(v *viper.Viper) { +func (f *Factory) InitFromViper(v *viper.Viper, logger *zap.Logger) { f.options = Options{}.InitFromViper(v) } diff --git a/plugin/sampling/strategystore/adaptive/factory_test.go b/plugin/sampling/strategystore/adaptive/factory_test.go index 72eac3b1ecf..807af255a62 100644 --- a/plugin/sampling/strategystore/adaptive/factory_test.go +++ b/plugin/sampling/strategystore/adaptive/factory_test.go @@ -47,7 +47,7 @@ func TestFactory(t *testing.T) { "--sampling.follower-lease-refresh-interval=2s", }) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) assert.Equal(t, 5.0, f.options.TargetSamplesPerSecond) assert.Equal(t, 0.25, f.options.DeltaTolerance) diff --git a/plugin/sampling/strategystore/factory.go b/plugin/sampling/strategystore/factory.go index c2a0a9fa50c..7d4fb974bac 100644 --- a/plugin/sampling/strategystore/factory.go +++ b/plugin/sampling/strategystore/factory.go @@ -76,10 +76,10 @@ func (f *Factory) AddFlags(flagSet *flag.FlagSet) { } // InitFromViper implements plugin.Configurable -func (f *Factory) InitFromViper(v *viper.Viper) { +func (f *Factory) InitFromViper(v *viper.Viper, logger *zap.Logger) { for _, factory := range f.factories { if conf, ok := factory.(plugin.Configurable); ok { - conf.InitFromViper(v) + conf.InitFromViper(v, logger) } } } diff --git a/plugin/sampling/strategystore/factory_test.go b/plugin/sampling/strategystore/factory_test.go index 9425ba337ce..069ddbb9585 100644 --- a/plugin/sampling/strategystore/factory_test.go +++ b/plugin/sampling/strategystore/factory_test.go @@ -78,7 +78,7 @@ func TestConfigurable(t *testing.T) { v := viper.New() f.AddFlags(fs) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) assert.Equal(t, fs, mock.flagSet) assert.Equal(t, v, mock.viper) @@ -87,6 +87,7 @@ func TestConfigurable(t *testing.T) { type mockFactory struct { flagSet *flag.FlagSet viper *viper.Viper + logger *zap.Logger retError bool } @@ -94,8 +95,9 @@ func (f *mockFactory) AddFlags(flagSet *flag.FlagSet) { f.flagSet = flagSet } -func (f *mockFactory) InitFromViper(v *viper.Viper) { +func (f *mockFactory) InitFromViper(v *viper.Viper, logger *zap.Logger) { f.viper = v + f.logger = logger } func (f *mockFactory) CreateStrategyStore() (ss.StrategyStore, error) { diff --git a/plugin/sampling/strategystore/static/factory.go b/plugin/sampling/strategystore/static/factory.go index ddc769e94af..5ff50847202 100644 --- a/plugin/sampling/strategystore/static/factory.go +++ b/plugin/sampling/strategystore/static/factory.go @@ -44,7 +44,7 @@ func (f *Factory) AddFlags(flagSet *flag.FlagSet) { } // InitFromViper implements plugin.Configurable -func (f *Factory) InitFromViper(v *viper.Viper) { +func (f *Factory) InitFromViper(v *viper.Viper, logger *zap.Logger) { f.options.InitFromViper(v) } diff --git a/plugin/sampling/strategystore/static/factory_test.go b/plugin/sampling/strategystore/static/factory_test.go index 205c35651ba..fe83d4e02ec 100644 --- a/plugin/sampling/strategystore/static/factory_test.go +++ b/plugin/sampling/strategystore/static/factory_test.go @@ -33,7 +33,7 @@ func TestFactory(t *testing.T) { f := NewFactory() v, command := config.Viperize(f.AddFlags) command.ParseFlags([]string{"--sampling.strategies-file=fixtures/strategies.json"}) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) assert.NoError(t, f.Initialize(metrics.NullFactory, zap.NewNop())) _, err := f.CreateStrategyStore() diff --git a/plugin/storage/badger/dependencystore/storage_test.go b/plugin/storage/badger/dependencystore/storage_test.go index 5c5d2af78e3..5042e6c4443 100644 --- a/plugin/storage/badger/dependencystore/storage_test.go +++ b/plugin/storage/badger/dependencystore/storage_test.go @@ -45,7 +45,7 @@ func runFactoryTest(tb testing.TB, test func(tb testing.TB, sw spanstore.Writer, "--badger.ephemeral=true", "--badger.consistency=false", }) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) err := f.Initialize(metrics.NullFactory, zap.NewNop()) assert.NoError(tb, err) diff --git a/plugin/storage/badger/factory.go b/plugin/storage/badger/factory.go index 4d19f12c3e8..98e6a10e603 100644 --- a/plugin/storage/badger/factory.go +++ b/plugin/storage/badger/factory.go @@ -22,8 +22,7 @@ import ( "strings" "time" - "github.com/dgraph-io/badger" - "github.com/dgraph-io/badger/options" + "github.com/dgraph-io/badger/v3" "github.com/spf13/viper" "github.com/uber/jaeger-lib/metrics" "go.uber.org/zap" @@ -81,8 +80,8 @@ func (f *Factory) AddFlags(flagSet *flag.FlagSet) { } // InitFromViper implements plugin.Configurable -func (f *Factory) InitFromViper(v *viper.Viper) { - f.Options.InitFromViper(v) +func (f *Factory) InitFromViper(v *viper.Viper, logger *zap.Logger) { + f.Options.InitFromViper(v, logger) } // InitFromOptions initializes Factory from supplied options @@ -95,7 +94,6 @@ func (f *Factory) Initialize(metricsFactory metrics.Factory, logger *zap.Logger) f.logger = logger opts := badger.DefaultOptions("") - opts.TableLoadingMode = options.MemoryMap if f.Options.Primary.Ephemeral { opts.SyncWrites = false @@ -117,7 +115,6 @@ func (f *Factory) Initialize(metricsFactory metrics.Factory, logger *zap.Logger) opts.ValueDir = f.Options.Primary.ValueDirectory // These options make no sense with ephemeral data - opts.Truncate = f.Options.Primary.Truncate opts.ReadOnly = f.Options.Primary.ReadOnly } diff --git a/plugin/storage/badger/factory_test.go b/plugin/storage/badger/factory_test.go index d63de46e501..503919ef562 100644 --- a/plugin/storage/badger/factory_test.go +++ b/plugin/storage/badger/factory_test.go @@ -43,7 +43,7 @@ func TestInitializationErrors(t *testing.T) { keyParam, valueParam, }) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) err := f.Initialize(metrics.NullFactory, zap.NewNop()) assert.Error(t, err) @@ -53,7 +53,7 @@ func TestForCodecov(t *testing.T) { // These tests are testing our vendor packages and are intended to satisfy Codecov. f := NewFactory() v, _ := config.Viperize(f.AddFlags) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) err := f.Initialize(metrics.NullFactory, zap.NewNop()) assert.NoError(t, err) @@ -85,7 +85,7 @@ func TestMaintenanceRun(t *testing.T) { command.ParseFlags([]string{ "--badger.maintenance-interval=10ms", }) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) // Safeguard mFactory := metricstest.NewFactory(0) _, gs := mFactory.Snapshot() @@ -109,7 +109,7 @@ func TestMaintenanceRun(t *testing.T) { // This is to for codecov only. Can break without anything else breaking as it does test badger's // internal implementation - vlogSize := expvar.Get("badger_vlog_size_bytes").(*expvar.Map).Get(f.tmpDir).(*expvar.Int) + vlogSize := expvar.Get("badger_v3_vlog_size_bytes").(*expvar.Map).Get(f.tmpDir).(*expvar.Int) currSize := vlogSize.Value() vlogSize.Set(currSize + 1<<31) @@ -130,7 +130,7 @@ func TestMaintenanceCodecov(t *testing.T) { command.ParseFlags([]string{ "--badger.maintenance-interval=10ms", }) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) mFactory := metricstest.NewFactory(0) f.Initialize(mFactory, zap.NewNop()) defer f.Close() @@ -149,7 +149,7 @@ func TestMaintenanceCodecov(t *testing.T) { func TestBadgerMetrics(t *testing.T) { // The expvar is leaking keyparams between tests. We need to clean up a bit.. - eMap := expvar.Get("badger_lsm_size_bytes").(*expvar.Map) + eMap := expvar.Get("badger_v3_lsm_size_bytes").(*expvar.Map) eMap.Init() f := NewFactory() @@ -157,32 +157,32 @@ func TestBadgerMetrics(t *testing.T) { command.ParseFlags([]string{ "--badger.metrics-update-interval=10ms", }) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) mFactory := metricstest.NewFactory(0) f.Initialize(mFactory, zap.NewNop()) assert.NotNil(t, f.metrics.badgerMetrics) - _, found := f.metrics.badgerMetrics["badger_memtable_gets_total"] + _, found := f.metrics.badgerMetrics["badger_v3_memtable_gets_total"] assert.True(t, found) waiter := func(previousValue int64) int64 { sleeps := 0 _, gs := mFactory.Snapshot() - for gs["badger_memtable_gets_total"] == previousValue && sleeps < 8 { + for gs["badger_v3_memtable_gets_total"] == previousValue && sleeps < 8 { // Wait for the scheduler time.Sleep(time.Duration(50) * time.Millisecond) sleeps++ _, gs = mFactory.Snapshot() } - assert.True(t, gs["badger_memtable_gets_total"] > previousValue) - return gs["badger_memtable_gets_total"] + assert.True(t, gs["badger_v3_memtable_gets_total"] == previousValue) + return gs["badger_v3_memtable_gets_total"] } vlogSize := waiter(0) _, gs := mFactory.Snapshot() - assert.True(t, vlogSize > 0) - assert.True(t, gs["badger_memtable_gets_total"] > 0) // IntVal metric + assert.True(t, vlogSize == 0) + assert.True(t, gs["badger_v3_memtable_gets_total"] == 0) // IntVal metric - _, found = gs["badger_lsm_size_bytes"] // Map metric + _, found = gs["badger_v3_lsm_size_bytes"] // Map metric assert.True(t, found) err := f.Close() diff --git a/plugin/storage/badger/options.go b/plugin/storage/badger/options.go index e6c4562c50f..755bc862ed3 100644 --- a/plugin/storage/badger/options.go +++ b/plugin/storage/badger/options.go @@ -21,6 +21,7 @@ import ( "time" "github.com/spf13/viper" + "go.uber.org/zap" ) // Options store storage plugin related configs @@ -40,10 +41,12 @@ type NamespaceConfig struct { SyncWrites bool `mapstructure:"consistency"` MaintenanceInterval time.Duration `mapstructure:"maintenance_interval"` MetricsUpdateInterval time.Duration `mapstructure:"metrics_update_interval"` - Truncate bool `mapstructure:"truncate"` ReadOnly bool `mapstructure:"read_only"` } +// TODO deprecated flag to be removed +const truncateWarning = "(deprecated, will be removed after 2021-09-21 or in release v1.26.0, whichever is later)" + const ( defaultMaintenanceInterval time.Duration = 5 * time.Minute defaultMetricsUpdateInterval time.Duration = 10 * time.Second @@ -135,8 +138,8 @@ func addFlags(flagSet *flag.FlagSet, nsConfig NamespaceConfig) { ) flagSet.Bool( nsConfig.namespace+suffixTruncate, - nsConfig.Truncate, - "If write-ahead-log should be truncated on restart. this will cause data loss.", + false, + truncateWarning+" If write-ahead-log should be truncated on restart. This will cause data loss.", ) flagSet.Bool( nsConfig.namespace+suffixReadOnly, @@ -146,11 +149,11 @@ func addFlags(flagSet *flag.FlagSet, nsConfig NamespaceConfig) { } // InitFromViper initializes Options with properties from viper -func (opt *Options) InitFromViper(v *viper.Viper) { - initFromViper(&opt.Primary, v) +func (opt *Options) InitFromViper(v *viper.Viper, logger *zap.Logger) { + initFromViper(&opt.Primary, v, logger) } -func initFromViper(cfg *NamespaceConfig, v *viper.Viper) { +func initFromViper(cfg *NamespaceConfig, v *viper.Viper, logger *zap.Logger) { cfg.Ephemeral = v.GetBool(cfg.namespace + suffixEphemeral) cfg.KeyDirectory = v.GetString(cfg.namespace + suffixKeyDirectory) cfg.ValueDirectory = v.GetString(cfg.namespace + suffixValueDirectory) @@ -158,8 +161,10 @@ func initFromViper(cfg *NamespaceConfig, v *viper.Viper) { cfg.SpanStoreTTL = v.GetDuration(cfg.namespace + suffixSpanstoreTTL) cfg.MaintenanceInterval = v.GetDuration(cfg.namespace + suffixMaintenanceInterval) cfg.MetricsUpdateInterval = v.GetDuration(cfg.namespace + suffixMetricsInterval) - cfg.Truncate = v.GetBool(cfg.namespace + suffixTruncate) cfg.ReadOnly = v.GetBool(cfg.namespace + suffixReadOnly) + if v.IsSet(cfg.namespace + suffixTruncate) { + logger.Warn("NOTE: Deprecated flag --badger.truncate passed " + truncateWarning) + } } // GetPrimary returns the primary namespace configuration diff --git a/plugin/storage/badger/options_test.go b/plugin/storage/badger/options_test.go index cd9353072cb..ffe317615d0 100644 --- a/plugin/storage/badger/options_test.go +++ b/plugin/storage/badger/options_test.go @@ -19,6 +19,7 @@ import ( "time" assert "github.com/stretchr/testify/require" + "go.uber.org/zap" "github.com/jaegertracing/jaeger/pkg/config" ) @@ -27,7 +28,7 @@ func TestDefaultOptionsParsing(t *testing.T) { opts := NewOptions("badger") v, command := config.Viperize(opts.AddFlags) command.ParseFlags([]string{}) - opts.InitFromViper(v) + opts.InitFromViper(v, zap.NewNop()) assert.True(t, opts.GetPrimary().Ephemeral) assert.False(t, opts.GetPrimary().SyncWrites) @@ -44,7 +45,7 @@ func TestParseOptions(t *testing.T) { "--badger.directory-value=/mnt/slow/badger", "--badger.span-store-ttl=168h", }) - opts.InitFromViper(v) + opts.InitFromViper(v, zap.NewNop()) assert.False(t, opts.GetPrimary().Ephemeral) assert.True(t, opts.GetPrimary().SyncWrites) @@ -52,7 +53,6 @@ func TestParseOptions(t *testing.T) { assert.Equal(t, "/var/lib/badger", opts.GetPrimary().KeyDirectory) assert.Equal(t, "/mnt/slow/badger", opts.GetPrimary().ValueDirectory) assert.False(t, opts.GetPrimary().ReadOnly) - assert.False(t, opts.GetPrimary().Truncate) } func TestTruncateAndReadOnlyOptions(t *testing.T) { @@ -62,8 +62,7 @@ func TestTruncateAndReadOnlyOptions(t *testing.T) { "--badger.truncate=true", "--badger.read-only=true", }) - opts.InitFromViper(v) + opts.InitFromViper(v, zap.NewNop()) assert.True(t, opts.GetPrimary().ReadOnly) - assert.True(t, opts.GetPrimary().Truncate) } diff --git a/plugin/storage/badger/spanstore/cache.go b/plugin/storage/badger/spanstore/cache.go index b43750d9ea7..5f1b7f89f41 100644 --- a/plugin/storage/badger/spanstore/cache.go +++ b/plugin/storage/badger/spanstore/cache.go @@ -19,7 +19,7 @@ import ( "sync" "time" - "github.com/dgraph-io/badger" + "github.com/dgraph-io/badger/v3" "github.com/jaegertracing/jaeger/storage/spanstore" ) diff --git a/plugin/storage/badger/spanstore/cache_test.go b/plugin/storage/badger/spanstore/cache_test.go index 67be9d07ced..a09f08369aa 100644 --- a/plugin/storage/badger/spanstore/cache_test.go +++ b/plugin/storage/badger/spanstore/cache_test.go @@ -19,7 +19,7 @@ import ( "testing" "time" - "github.com/dgraph-io/badger" + "github.com/dgraph-io/badger/v3" "github.com/stretchr/testify/assert" "github.com/jaegertracing/jaeger/model" diff --git a/plugin/storage/badger/spanstore/read_write_test.go b/plugin/storage/badger/spanstore/read_write_test.go index 6b5a724974b..f037bc18ac3 100644 --- a/plugin/storage/badger/spanstore/read_write_test.go +++ b/plugin/storage/badger/spanstore/read_write_test.go @@ -398,7 +398,7 @@ func TestPersist(t *testing.T) { keyParam, valueParam, }) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) err = f.Initialize(metrics.NullFactory, zap.NewNop()) assert.NoError(t, err) @@ -457,7 +457,7 @@ func runFactoryTest(tb testing.TB, test func(tb testing.TB, sw spanstore.Writer, "--badger.ephemeral=true", "--badger.consistency=false", }) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) err := f.Initialize(metrics.NullFactory, zap.NewNop()) assert.NoError(tb, err) @@ -628,7 +628,7 @@ func runLargeFactoryTest(tb testing.TB, test func(tb testing.TB, sw spanstore.Wr valueParam, }) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) err = f.Initialize(metrics.NullFactory, zap.NewNop()) assert.NoError(err) diff --git a/plugin/storage/badger/spanstore/reader.go b/plugin/storage/badger/spanstore/reader.go index 372c1ef99e0..d1863a170e1 100644 --- a/plugin/storage/badger/spanstore/reader.go +++ b/plugin/storage/badger/spanstore/reader.go @@ -24,7 +24,7 @@ import ( "math" "sort" - "github.com/dgraph-io/badger" + "github.com/dgraph-io/badger/v3" "github.com/jaegertracing/jaeger/model" "github.com/jaegertracing/jaeger/storage/spanstore" diff --git a/plugin/storage/badger/spanstore/rw_internal_test.go b/plugin/storage/badger/spanstore/rw_internal_test.go index 08b437222ae..f706f97c653 100644 --- a/plugin/storage/badger/spanstore/rw_internal_test.go +++ b/plugin/storage/badger/spanstore/rw_internal_test.go @@ -20,7 +20,7 @@ import ( "testing" "time" - "github.com/dgraph-io/badger" + "github.com/dgraph-io/badger/v3" "github.com/stretchr/testify/assert" "github.com/jaegertracing/jaeger/model" diff --git a/plugin/storage/badger/spanstore/writer.go b/plugin/storage/badger/spanstore/writer.go index 65910559f09..cd9aa56e19c 100644 --- a/plugin/storage/badger/spanstore/writer.go +++ b/plugin/storage/badger/spanstore/writer.go @@ -21,7 +21,7 @@ import ( "fmt" "time" - "github.com/dgraph-io/badger" + "github.com/dgraph-io/badger/v3" "github.com/gogo/protobuf/proto" "github.com/jaegertracing/jaeger/model" diff --git a/plugin/storage/badger/stats_linux_test.go b/plugin/storage/badger/stats_linux_test.go index 213b25c1573..9b27cb7f77b 100644 --- a/plugin/storage/badger/stats_linux_test.go +++ b/plugin/storage/badger/stats_linux_test.go @@ -32,7 +32,7 @@ func TestDiskStatisticsUpdate(t *testing.T) { "--badger.ephemeral=true", "--badger.consistency=false", }) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) mFactory := metricstest.NewFactory(0) err := f.Initialize(mFactory, zap.NewNop()) assert.NoError(t, err) diff --git a/plugin/storage/badger/stats_test.go b/plugin/storage/badger/stats_test.go index b60d01e42fd..e13a67b17de 100644 --- a/plugin/storage/badger/stats_test.go +++ b/plugin/storage/badger/stats_test.go @@ -34,7 +34,7 @@ func TestDiskStatisticsUpdate(t *testing.T) { "--badger.ephemeral=true", "--badger.consistency=false", }) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) err := f.Initialize(metrics.NullFactory, zap.NewNop()) assert.NoError(t, err) defer f.Close() diff --git a/plugin/storage/cassandra/factory.go b/plugin/storage/cassandra/factory.go index d48d0d0896b..4385d9fb7db 100644 --- a/plugin/storage/cassandra/factory.go +++ b/plugin/storage/cassandra/factory.go @@ -66,7 +66,7 @@ func (f *Factory) AddFlags(flagSet *flag.FlagSet) { } // InitFromViper implements plugin.Configurable -func (f *Factory) InitFromViper(v *viper.Viper) { +func (f *Factory) InitFromViper(v *viper.Viper, logger *zap.Logger) { f.Options.InitFromViper(v) f.primaryConfig = f.Options.GetPrimary() if cfg := f.Options.Get(archiveStorageConfig); cfg != nil { diff --git a/plugin/storage/cassandra/factory_test.go b/plugin/storage/cassandra/factory_test.go index cc1b2541252..14599834a10 100644 --- a/plugin/storage/cassandra/factory_test.go +++ b/plugin/storage/cassandra/factory_test.go @@ -55,7 +55,7 @@ func TestCassandraFactory(t *testing.T) { f := NewFactory() v, command := config.Viperize(f.AddFlags) command.ParseFlags([]string{"--cassandra-archive.enabled=true"}) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) // after InitFromViper, f.primaryConfig points to a real session builder that will fail in unit tests, // so we override it with a mock. @@ -110,7 +110,7 @@ func TestExclusiveWhitelistBlacklist(t *testing.T) { command.ParseFlags([]string{"--cassandra-archive.enabled=true", "--cassandra.index.tag-whitelist=a,b,c", "--cassandra.index.tag-blacklist=a,b,c"}) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) // after InitFromViper, f.primaryConfig points to a real session builder that will fail in unit tests, // so we override it with a mock. diff --git a/plugin/storage/es/factory.go b/plugin/storage/es/factory.go index c7eebcfe596..6ce1f25d34f 100644 --- a/plugin/storage/es/factory.go +++ b/plugin/storage/es/factory.go @@ -64,7 +64,7 @@ func (f *Factory) AddFlags(flagSet *flag.FlagSet) { } // InitFromViper implements plugin.Configurable -func (f *Factory) InitFromViper(v *viper.Viper) { +func (f *Factory) InitFromViper(v *viper.Viper, logger *zap.Logger) { f.Options.InitFromViper(v) f.primaryConfig = f.Options.GetPrimary() f.archiveConfig = f.Options.Get(archiveNamespace) diff --git a/plugin/storage/es/factory_test.go b/plugin/storage/es/factory_test.go index 728e203d339..525dc9a29dc 100644 --- a/plugin/storage/es/factory_test.go +++ b/plugin/storage/es/factory_test.go @@ -58,7 +58,7 @@ func TestElasticsearchFactory(t *testing.T) { f := NewFactory() v, command := config.Viperize(f.AddFlags) command.ParseFlags([]string{}) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) // after InitFromViper, f.primaryConfig points to a real session builder that will fail in unit tests, // so we override it with a mock. diff --git a/plugin/storage/factory.go b/plugin/storage/factory.go index 59d8a19e4aa..1461a3c378b 100644 --- a/plugin/storage/factory.go +++ b/plugin/storage/factory.go @@ -200,10 +200,10 @@ func (f *Factory) addDownsamplingFlags(flagSet *flag.FlagSet) { } // InitFromViper implements plugin.Configurable -func (f *Factory) InitFromViper(v *viper.Viper) { +func (f *Factory) InitFromViper(v *viper.Viper, logger *zap.Logger) { for _, factory := range f.factories { if conf, ok := factory.(plugin.Configurable); ok { - conf.InitFromViper(v) + conf.InitFromViper(v, logger) } } f.initDownsamplingFromViper(v) diff --git a/plugin/storage/factory_test.go b/plugin/storage/factory_test.go index 973862eca9e..9bda39b0f59 100644 --- a/plugin/storage/factory_test.go +++ b/plugin/storage/factory_test.go @@ -300,6 +300,7 @@ type configurable struct { mocks.Factory flagSet *flag.FlagSet viper *viper.Viper + logger *zap.Logger } // AddFlags implements plugin.Configurable @@ -308,8 +309,9 @@ func (f *configurable) AddFlags(flagSet *flag.FlagSet) { } // InitFromViper implements plugin.Configurable -func (f *configurable) InitFromViper(v *viper.Viper) { +func (f *configurable) InitFromViper(v *viper.Viper, logger *zap.Logger) { f.viper = v + f.logger = logger } func TestConfigurable(t *testing.T) { @@ -328,7 +330,7 @@ func TestConfigurable(t *testing.T) { v := viper.New() f.AddFlags(fs) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) assert.Equal(t, fs, mock.flagSet) assert.Equal(t, v, mock.viper) @@ -341,7 +343,7 @@ func TestParsingDownsamplingRatio(t *testing.T) { "--downsampling.ratio=1.5", "--downsampling.hashsalt=jaeger"}) assert.NoError(t, err) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) assert.Equal(t, f.FactoryConfig.DownsamplingRatio, 1.0) assert.Equal(t, f.FactoryConfig.DownsamplingHashSalt, "jaeger") @@ -349,7 +351,7 @@ func TestParsingDownsamplingRatio(t *testing.T) { err = command.ParseFlags([]string{ "--downsampling.ratio=0.5"}) assert.NoError(t, err) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) assert.Equal(t, f.FactoryConfig.DownsamplingRatio, 0.5) } @@ -358,7 +360,7 @@ func TestDefaultDownsamplingWithAddFlags(t *testing.T) { v, command := config.Viperize(f.AddFlags) err := command.ParseFlags([]string{}) assert.NoError(t, err) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) assert.Equal(t, f.FactoryConfig.DownsamplingRatio, defaultDownsamplingRatio) assert.Equal(t, f.FactoryConfig.DownsamplingHashSalt, defaultDownsamplingHashSalt) diff --git a/plugin/storage/grpc/factory.go b/plugin/storage/grpc/factory.go index e5ee5dc7855..bb5e3a89e3a 100644 --- a/plugin/storage/grpc/factory.go +++ b/plugin/storage/grpc/factory.go @@ -53,7 +53,7 @@ func (f *Factory) AddFlags(flagSet *flag.FlagSet) { } // InitFromViper implements plugin.Configurable -func (f *Factory) InitFromViper(v *viper.Viper) { +func (f *Factory) InitFromViper(v *viper.Viper, logger *zap.Logger) { f.options.InitFromViper(v) f.builder = &f.options.Configuration } diff --git a/plugin/storage/grpc/factory_test.go b/plugin/storage/grpc/factory_test.go index b8b295435fd..5ed7a6b9e2e 100644 --- a/plugin/storage/grpc/factory_test.go +++ b/plugin/storage/grpc/factory_test.go @@ -96,7 +96,7 @@ func (mp *mockPlugin) DependencyReader() dependencystore.Reader { func TestGRPCStorageFactory(t *testing.T) { f := NewFactory() v := viper.New() - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) // after InitFromViper, f.builder points to a real plugin builder that will fail in unit tests, // so we override it with a mock. @@ -134,7 +134,7 @@ func TestGRPCStorageFactory(t *testing.T) { func TestGRPCStorageFactory_Capabilities(t *testing.T) { f := NewFactory() v := viper.New() - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) capabilities := new(mocks.PluginCapabilities) capabilities.On("Capabilities"). @@ -164,7 +164,7 @@ func TestGRPCStorageFactory_Capabilities(t *testing.T) { func TestGRPCStorageFactory_CapabilitiesDisabled(t *testing.T) { f := NewFactory() v := viper.New() - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) capabilities := new(mocks.PluginCapabilities) capabilities.On("Capabilities"). @@ -194,7 +194,7 @@ func TestGRPCStorageFactory_CapabilitiesDisabled(t *testing.T) { func TestGRPCStorageFactory_CapabilitiesError(t *testing.T) { f := NewFactory() v := viper.New() - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) capabilities := new(mocks.PluginCapabilities) customError := errors.New("made-up error") @@ -222,7 +222,7 @@ func TestGRPCStorageFactory_CapabilitiesError(t *testing.T) { func TestGRPCStorageFactory_CapabilitiesNil(t *testing.T) { f := NewFactory() v := viper.New() - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) f.builder = &mockPluginBuilder{ plugin: &mockPlugin{ @@ -250,7 +250,7 @@ func TestWithConfiguration(t *testing.T) { "--grpc-storage-plugin.configuration-file=config.json", }) assert.NoError(t, err) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) assert.Equal(t, f.options.Configuration.PluginBinary, "noop-grpc-plugin") assert.Equal(t, f.options.Configuration.PluginConfigurationFile, "config.json") assert.Equal(t, f.options.Configuration.PluginLogLevel, "debug") diff --git a/plugin/storage/integration/cassandra_test.go b/plugin/storage/integration/cassandra_test.go index a1375993fe8..cfba419941d 100644 --- a/plugin/storage/integration/cassandra_test.go +++ b/plugin/storage/integration/cassandra_test.go @@ -58,7 +58,7 @@ func (s *CassandraStorageIntegration) initializeCassandraFactory(flags []string) f := cassandra.NewFactory() v, command := config.Viperize(f.AddFlags) command.ParseFlags(flags) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) if err := f.Initialize(metrics.NullFactory, s.logger); err != nil { return nil, err } diff --git a/plugin/storage/integration/grpc_test.go b/plugin/storage/integration/grpc_test.go index e9ce29968c7..847f07e0e97 100644 --- a/plugin/storage/integration/grpc_test.go +++ b/plugin/storage/integration/grpc_test.go @@ -50,7 +50,7 @@ func (s *GRPCStorageIntegrationTestSuite) initialize() error { if err != nil { return err } - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) if err := f.Initialize(metrics.NullFactory, s.logger); err != nil { return err } diff --git a/plugin/storage/integration/kafka_test.go b/plugin/storage/integration/kafka_test.go index 667646d81f7..f515c7df39b 100644 --- a/plugin/storage/integration/kafka_test.go +++ b/plugin/storage/integration/kafka_test.go @@ -63,7 +63,7 @@ func (s *KafkaIntegrationTestSuite) initialize() error { if err != nil { return err } - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) if err := f.Initialize(metrics.NullFactory, s.logger); err != nil { return err } diff --git a/plugin/storage/kafka/factory.go b/plugin/storage/kafka/factory.go index b11caf1983c..6fd037c1c08 100644 --- a/plugin/storage/kafka/factory.go +++ b/plugin/storage/kafka/factory.go @@ -52,7 +52,7 @@ func (f *Factory) AddFlags(flagSet *flag.FlagSet) { } // InitFromViper implements plugin.Configurable -func (f *Factory) InitFromViper(v *viper.Viper) { +func (f *Factory) InitFromViper(v *viper.Viper, logger *zap.Logger) { f.options.InitFromViper(v) f.Builder = &f.options.Config } diff --git a/plugin/storage/kafka/factory_test.go b/plugin/storage/kafka/factory_test.go index e6538f7c278..edb356cb665 100644 --- a/plugin/storage/kafka/factory_test.go +++ b/plugin/storage/kafka/factory_test.go @@ -52,7 +52,7 @@ func TestKafkaFactory(t *testing.T) { f := NewFactory() v, command := config.Viperize(f.AddFlags) command.ParseFlags([]string{}) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) f.Builder = &mockProducerBuilder{ err: errors.New("made-up error"), @@ -90,7 +90,7 @@ func TestKafkaFactoryEncoding(t *testing.T) { v, command := config.Viperize(f.AddFlags) err := command.ParseFlags([]string{"--kafka.producer.encoding=" + test.encoding}) require.NoError(t, err) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) f.Builder = &mockProducerBuilder{t: t} assert.NoError(t, f.Initialize(metrics.NullFactory, zap.NewNop())) @@ -103,7 +103,7 @@ func TestKafkaFactoryMarshallerErr(t *testing.T) { f := NewFactory() v, command := config.Viperize(f.AddFlags) command.ParseFlags([]string{"--kafka.producer.encoding=bad-input"}) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) f.Builder = &mockProducerBuilder{t: t} assert.Error(t, f.Initialize(metrics.NullFactory, zap.NewNop())) @@ -142,7 +142,7 @@ func TestKafkaFactoryDoesNotLogPassword(t *testing.T) { err := command.ParseFlags(test.flags) require.NoError(t, err) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) parsedConfig := f.Builder.(*kafkaConfig.Configuration) f.Builder = &mockProducerBuilder{t: t, Configuration: *parsedConfig} diff --git a/plugin/storage/memory/factory.go b/plugin/storage/memory/factory.go index 48d3d6bdcb2..c94fbfa6c50 100644 --- a/plugin/storage/memory/factory.go +++ b/plugin/storage/memory/factory.go @@ -45,7 +45,7 @@ func (f *Factory) AddFlags(flagSet *flag.FlagSet) { } // InitFromViper implements plugin.Configurable -func (f *Factory) InitFromViper(v *viper.Viper) { +func (f *Factory) InitFromViper(v *viper.Viper, logger *zap.Logger) { f.options.InitFromViper(v) } diff --git a/plugin/storage/memory/factory_test.go b/plugin/storage/memory/factory_test.go index f024f2ff0a4..729c05ff0fd 100644 --- a/plugin/storage/memory/factory_test.go +++ b/plugin/storage/memory/factory_test.go @@ -50,7 +50,7 @@ func TestWithConfiguration(t *testing.T) { f := NewFactory() v, command := config.Viperize(f.AddFlags) command.ParseFlags([]string{"--memory.max-traces=100"}) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) assert.Equal(t, f.options.Configuration.MaxTraces, 100) } @@ -65,7 +65,7 @@ func TestPublishOpts(t *testing.T) { f := NewFactory() v, command := config.Viperize(f.AddFlags) command.ParseFlags([]string{"--memory.max-traces=100"}) - f.InitFromViper(v) + f.InitFromViper(v, zap.NewNop()) baseMetrics := metricstest.NewFactory(time.Second) forkFactory := metricstest.NewFactory(time.Second)