[#1619] logger: Set tags for node
components
Change-Id: I55ffcce9d2a74fdd47621674739b07f2e20199e3 Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
36fb15b9a4
commit
100eb8b654
37 changed files with 151 additions and 77 deletions
|
@ -19,7 +19,8 @@ func TestBlobovniczaTree_Concurrency(t *testing.T) {
|
|||
|
||||
st := NewBlobovniczaTree(
|
||||
context.Background(),
|
||||
WithLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaTreeLogger(test.NewLogger(t)),
|
||||
WithObjectSizeLimit(1024),
|
||||
WithBlobovniczaShallowWidth(10),
|
||||
WithBlobovniczaShallowDepth(1),
|
||||
|
|
|
@ -19,7 +19,8 @@ func TestExistsInvalidStorageID(t *testing.T) {
|
|||
dir := t.TempDir()
|
||||
b := NewBlobovniczaTree(
|
||||
context.Background(),
|
||||
WithLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaTreeLogger(test.NewLogger(t)),
|
||||
WithObjectSizeLimit(1024),
|
||||
WithBlobovniczaShallowWidth(2),
|
||||
WithBlobovniczaShallowDepth(2),
|
||||
|
|
|
@ -15,7 +15,8 @@ func TestGeneric(t *testing.T) {
|
|||
helper := func(t *testing.T, dir string) common.Storage {
|
||||
return NewBlobovniczaTree(
|
||||
context.Background(),
|
||||
WithLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaTreeLogger(test.NewLogger(t)),
|
||||
WithObjectSizeLimit(maxObjectSize),
|
||||
WithBlobovniczaShallowWidth(2),
|
||||
WithBlobovniczaShallowDepth(2),
|
||||
|
@ -43,7 +44,8 @@ func TestControl(t *testing.T) {
|
|||
newTree := func(t *testing.T) common.Storage {
|
||||
return NewBlobovniczaTree(
|
||||
context.Background(),
|
||||
WithLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaTreeLogger(test.NewLogger(t)),
|
||||
WithObjectSizeLimit(maxObjectSize),
|
||||
WithBlobovniczaShallowWidth(2),
|
||||
WithBlobovniczaShallowDepth(2),
|
||||
|
|
|
@ -63,10 +63,15 @@ func initConfig(c *cfg) {
|
|||
}
|
||||
}
|
||||
|
||||
func WithLogger(l *logger.Logger) Option {
|
||||
func WithBlobovniczaTreeLogger(log *logger.Logger) Option {
|
||||
return func(c *cfg) {
|
||||
c.log = l
|
||||
c.blzOpts = append(c.blzOpts, blobovnicza.WithLogger(l))
|
||||
c.log = log
|
||||
}
|
||||
}
|
||||
|
||||
func WithBlobovniczaLogger(log *logger.Logger) Option {
|
||||
return func(c *cfg) {
|
||||
c.blzOpts = append(c.blzOpts, blobovnicza.WithLogger(log))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -140,7 +140,8 @@ func testRebuildFailoverObjectDeletedFromSource(t *testing.T) {
|
|||
func testRebuildFailoverValidate(t *testing.T, dir string, obj *objectSDK.Object, mustUpdateStorageID bool) {
|
||||
b := NewBlobovniczaTree(
|
||||
context.Background(),
|
||||
WithLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaTreeLogger(test.NewLogger(t)),
|
||||
WithObjectSizeLimit(2048),
|
||||
WithBlobovniczaShallowWidth(2),
|
||||
WithBlobovniczaShallowDepth(2),
|
||||
|
|
|
@ -50,7 +50,8 @@ func TestBlobovniczaTreeFillPercentRebuild(t *testing.T) {
|
|||
dir := t.TempDir()
|
||||
b := NewBlobovniczaTree(
|
||||
context.Background(),
|
||||
WithLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaTreeLogger(test.NewLogger(t)),
|
||||
WithObjectSizeLimit(64*1024),
|
||||
WithBlobovniczaShallowWidth(1), // single directory
|
||||
WithBlobovniczaShallowDepth(1),
|
||||
|
@ -106,7 +107,8 @@ func TestBlobovniczaTreeFillPercentRebuild(t *testing.T) {
|
|||
dir := t.TempDir()
|
||||
b := NewBlobovniczaTree(
|
||||
context.Background(),
|
||||
WithLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaTreeLogger(test.NewLogger(t)),
|
||||
WithObjectSizeLimit(64*1024),
|
||||
WithBlobovniczaShallowWidth(1), // single directory
|
||||
WithBlobovniczaShallowDepth(1),
|
||||
|
@ -160,7 +162,8 @@ func TestBlobovniczaTreeFillPercentRebuild(t *testing.T) {
|
|||
dir := t.TempDir()
|
||||
b := NewBlobovniczaTree(
|
||||
context.Background(),
|
||||
WithLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaTreeLogger(test.NewLogger(t)),
|
||||
WithObjectSizeLimit(64*1024),
|
||||
WithBlobovniczaShallowWidth(1), // single directory
|
||||
WithBlobovniczaShallowDepth(1),
|
||||
|
@ -231,7 +234,8 @@ func TestBlobovniczaTreeFillPercentRebuild(t *testing.T) {
|
|||
dir := t.TempDir()
|
||||
b := NewBlobovniczaTree(
|
||||
context.Background(),
|
||||
WithLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaTreeLogger(test.NewLogger(t)),
|
||||
WithObjectSizeLimit(64*1024),
|
||||
WithBlobovniczaShallowWidth(1), // single directory
|
||||
WithBlobovniczaShallowDepth(1),
|
||||
|
@ -262,7 +266,8 @@ func TestBlobovniczaTreeFillPercentRebuild(t *testing.T) {
|
|||
require.NoError(t, b.Close(context.Background()))
|
||||
b = NewBlobovniczaTree(
|
||||
context.Background(),
|
||||
WithLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaTreeLogger(test.NewLogger(t)),
|
||||
WithObjectSizeLimit(64*1024),
|
||||
WithBlobovniczaShallowWidth(1),
|
||||
WithBlobovniczaShallowDepth(1),
|
||||
|
@ -304,7 +309,8 @@ func TestBlobovniczaTreeRebuildLargeObject(t *testing.T) {
|
|||
dir := t.TempDir()
|
||||
b := NewBlobovniczaTree(
|
||||
context.Background(),
|
||||
WithLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaTreeLogger(test.NewLogger(t)),
|
||||
WithObjectSizeLimit(64*1024), // 64KB object size limit
|
||||
WithBlobovniczaShallowWidth(5),
|
||||
WithBlobovniczaShallowDepth(2), // depth = 2
|
||||
|
@ -332,7 +338,8 @@ func TestBlobovniczaTreeRebuildLargeObject(t *testing.T) {
|
|||
|
||||
b = NewBlobovniczaTree(
|
||||
context.Background(),
|
||||
WithLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaTreeLogger(test.NewLogger(t)),
|
||||
WithObjectSizeLimit(32*1024), // 32KB object size limit
|
||||
WithBlobovniczaShallowWidth(5),
|
||||
WithBlobovniczaShallowDepth(3), // depth = 3
|
||||
|
@ -374,7 +381,8 @@ func testBlobovniczaTreeRebuildHelper(t *testing.T, sourceDepth, sourceWidth, ta
|
|||
dir := t.TempDir()
|
||||
b := NewBlobovniczaTree(
|
||||
context.Background(),
|
||||
WithLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaTreeLogger(test.NewLogger(t)),
|
||||
WithObjectSizeLimit(2048),
|
||||
WithBlobovniczaShallowWidth(sourceWidth),
|
||||
WithBlobovniczaShallowDepth(sourceDepth),
|
||||
|
@ -415,7 +423,8 @@ func testBlobovniczaTreeRebuildHelper(t *testing.T, sourceDepth, sourceWidth, ta
|
|||
|
||||
b = NewBlobovniczaTree(
|
||||
context.Background(),
|
||||
WithLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaLogger(test.NewLogger(t)),
|
||||
WithBlobovniczaTreeLogger(test.NewLogger(t)),
|
||||
WithObjectSizeLimit(2048),
|
||||
WithBlobovniczaShallowWidth(targetWidth),
|
||||
WithBlobovniczaShallowDepth(targetDepth),
|
||||
|
|
|
@ -91,7 +91,7 @@ func WithStorages(st []SubStorage) Option {
|
|||
// WithLogger returns option to specify BlobStor's logger.
|
||||
func WithLogger(l *logger.Logger) Option {
|
||||
return func(c *cfg) {
|
||||
c.log = l.With(zap.String("component", "BlobStor"))
|
||||
c.log = l
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"io/fs"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/util/logger"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type Option func(*FSTree)
|
||||
|
@ -53,6 +52,6 @@ func WithFileCounter(c FileCounter) Option {
|
|||
|
||||
func WithLogger(l *logger.Logger) Option {
|
||||
return func(f *FSTree) {
|
||||
f.log = l.With(zap.String("component", "FSTree"))
|
||||
f.log = l
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue