Skip to content

Commit

Permalink
Badger: v1 to v3 upgrade (#3096)
Browse files Browse the repository at this point in the history
* Badger: v1 to v3 upgrade

Signed-off-by: Ashmita Bohara <[email protected]>

* Increase codecov

Signed-off-by: Ashmita Bohara <[email protected]>

* Implement feedbacks

Signed-off-by: Ashmita Bohara <[email protected]>

* Implement feedbacks

Signed-off-by: Ashmita Bohara <[email protected]>

* Implement feedbacks

Signed-off-by: Ashmita Bohara <[email protected]>

* Implement feedbacks

Signed-off-by: Ashmita Bohara <[email protected]>

* Remove unnessary logger passing

Signed-off-by: Ashmita Bohara <[email protected]>

* Feedbacks

Signed-off-by: Ashmita Bohara <[email protected]>

* Feedbacks

Signed-off-by: Ashmita Bohara <[email protected]>
  • Loading branch information
Ashmita152 authored Jun 21, 2021
1 parent 681dd68 commit f23484b
Show file tree
Hide file tree
Showing 48 changed files with 131 additions and 107 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions cmd/all-in-one/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand All @@ -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))
}
Expand Down Expand Up @@ -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()
}
4 changes: 2 additions & 2 deletions cmd/collector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand All @@ -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))
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/ingester/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/query/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down Expand Up @@ -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()
}
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 13 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down
3 changes: 2 additions & 1 deletion plugin/configurable.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
}
2 changes: 1 addition & 1 deletion plugin/metrics/disabled/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion plugin/metrics/disabled/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions plugin/metrics/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
6 changes: 4 additions & 2 deletions plugin/metrics/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ type configurable struct {
mocks.MetricsFactory
flagSet *flag.FlagSet
viper *viper.Viper
logger *zap.Logger
}

// AddFlags implements plugin.Configurable.
Expand All @@ -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) {
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion plugin/metrics/prometheus/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion plugin/metrics/prometheus/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
2 changes: 1 addition & 1 deletion plugin/sampling/strategystore/adaptive/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion plugin/sampling/strategystore/adaptive/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions plugin/sampling/strategystore/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions plugin/sampling/strategystore/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -87,15 +87,17 @@ func TestConfigurable(t *testing.T) {
type mockFactory struct {
flagSet *flag.FlagSet
viper *viper.Viper
logger *zap.Logger
retError bool
}

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) {
Expand Down
2 changes: 1 addition & 1 deletion plugin/sampling/strategystore/static/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion plugin/sampling/strategystore/static/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion plugin/storage/badger/dependencystore/storage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 3 additions & 6 deletions plugin/storage/badger/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
}

Expand Down
Loading

0 comments on commit f23484b

Please sign in to comment.