You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ha...@apache.org on 2024/09/02 03:36:10 UTC

(skywalking-banyandb) branch etcd created (now fcbe5c84)

This is an automated email from the ASF dual-hosted git repository.

hanahmily pushed a change to branch etcd
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git


      at fcbe5c84 Change etcd default log level

This branch includes the following new commits:

     new fcbe5c84 Change etcd default log level

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(skywalking-banyandb) 01/01: Change etcd default log level

Posted by ha...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hanahmily pushed a commit to branch etcd
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git

commit fcbe5c842cbe2629b3f40dfd3ee923f3518253ef
Author: Gao Hongtao <ha...@gmail.com>
AuthorDate: Mon Sep 2 03:32:46 2024 +0000

    Change etcd default log level
    
    Signed-off-by: Gao Hongtao <ha...@gmail.com>
---
 CHANGES.md                              | 13 +++++++------
 banyand/metadata/embeddedetcd/server.go |  3 ++-
 banyand/metadata/schema/etcd.go         |  5 +++--
 docs/operation/observability.md         |  2 +-
 pkg/logger/logger.go                    | 21 +++++++++++++++++----
 5 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index 789d1aef..dd11093b 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -54,12 +54,13 @@ Release Notes.
 
 ### Chores
 
-Bump up the version of infra e2e framework.
-Separate the monolithic release package into two packages: banyand and bydbctl.
-Separate the monolithic Docker image into two images: banyand and bydbctl.
-Update CI to publish linux/amd64 and linux/arm64 Docker images.
-Make the build system compiles the binary based on the platform which is running on.
-Push "skywalking-banyandb-test" image for e2e and stress test. This image contains bydbctl to do a health check.
+- Bump up the version of infra e2e framework.
+- Separate the monolithic release package into two packages: banyand and bydbctl.
+- Separate the monolithic Docker image into two images: banyand and bydbctl.
+- Update CI to publish linux/amd64 and linux/arm64 Docker images.
+- Make the build system compiles the binary based on the platform which is running on.
+- Push "skywalking-banyandb-test" image for e2e and stress test. This image contains bydbctl to do a health check.
+- Set etcd-client log level to "error" and etcd-server log level to "warn".
 
 ## 0.6.1
 
diff --git a/banyand/metadata/embeddedetcd/server.go b/banyand/metadata/embeddedetcd/server.go
index c6833ef2..0271df40 100644
--- a/banyand/metadata/embeddedetcd/server.go
+++ b/banyand/metadata/embeddedetcd/server.go
@@ -25,6 +25,7 @@ import (
 	"path/filepath"
 	"time"
 
+	"github.com/rs/zerolog"
 	"go.etcd.io/etcd/server/v3/embed"
 	"go.uber.org/zap"
 
@@ -99,7 +100,7 @@ func NewServer(options ...Option) (Server, error) {
 	for _, opt := range options {
 		opt(conf)
 	}
-	zapCfg := logger.GetLogger("etcd").ToZapConfig()
+	zapCfg := logger.GetLogger("etcd-server").DefaultLevel(zerolog.WarnLevel).ToZapConfig()
 
 	var l *zap.Logger
 	var err error
diff --git a/banyand/metadata/schema/etcd.go b/banyand/metadata/schema/etcd.go
index 38b5615a..00392f3d 100644
--- a/banyand/metadata/schema/etcd.go
+++ b/banyand/metadata/schema/etcd.go
@@ -26,6 +26,7 @@ import (
 	"time"
 
 	"github.com/pkg/errors"
+	"github.com/rs/zerolog"
 	pb "go.etcd.io/etcd/api/v3/etcdserverpb"
 	"go.etcd.io/etcd/client/pkg/v3/transport"
 	clientv3 "go.etcd.io/etcd/client/v3"
@@ -177,7 +178,7 @@ func NewEtcdSchemaRegistry(options ...RegistryOption) (Registry, error) {
 	if registryConfig.serverEndpoints == nil {
 		return nil, errors.New("server address is not set")
 	}
-	log := logger.GetLogger("etcd")
+	log := logger.GetLogger("etcd-client").DefaultLevel(zerolog.ErrorLevel)
 	zapCfg := log.ToZapConfig()
 
 	var l *zap.Logger
@@ -205,7 +206,7 @@ func NewEtcdSchemaRegistry(options ...RegistryOption) (Registry, error) {
 		namespace: registryConfig.namespace,
 		client:    client,
 		closer:    run.NewCloser(1),
-		l:         log,
+		l:         logger.GetLogger("schema-registry"),
 	}
 	return reg, nil
 }
diff --git a/docs/operation/observability.md b/docs/operation/observability.md
index 7b4e6141..d28b5f41 100644
--- a/docs/operation/observability.md
+++ b/docs/operation/observability.md
@@ -8,7 +8,7 @@ BanyanDB uses the [zerolo](https://github.com/rs/zerolog) library for logging. T
 
 `logging-env` is used to set the logging environment. The default value is `prod`. The logging environment can be set to `dev` for development or `prod` for production. The logging environment affects the log format and output. In the `dev` environment, logs are output in a human-readable format, while in the `prod` environment, logs are output in JSON format.
 
-`logging-modules` and `logging-levels` are used to set the log level for specific modules. The `logging-modules` flag is a comma-separated list of module names, and the `logging-levels` flag is a comma-separated list of log levels corresponding to the module names. The log level for a specific module can be set using these flags. Available modules are `storage`, `distributed-query`, `liaison-grpc`, `liaison-http`, `measure`, `stream`, `metadata`, `etcd`, `metrics`, `pprof-service`, `quer [...]
+`logging-modules` and `logging-levels` are used to set the log level for specific modules. The `logging-modules` flag is a comma-separated list of module names, and the `logging-levels` flag is a comma-separated list of log levels corresponding to the module names. The log level for a specific module can be set using these flags. Available modules are `storage`, `distributed-query`, `liaison-grpc`, `liaison-http`, `measure`, `stream`, `metadata`, `etcd-client`, `etcd-server`, `schema-reg [...]
 
 ```sh
 --logging-modules=storage --logging-levels=debug
diff --git a/pkg/logger/logger.go b/pkg/logger/logger.go
index b967083a..aa17d57b 100644
--- a/pkg/logger/logger.go
+++ b/pkg/logger/logger.go
@@ -46,9 +46,10 @@ type Logging struct {
 // Logger is wrapper for rs/zerolog logger with module, it is singleton.
 type Logger struct {
 	*zerolog.Logger
-	modules     map[string]zerolog.Level
-	module      string
-	development bool
+	modules        map[string]zerolog.Level
+	module         string
+	development    bool
+	isDefaultLevel bool
 }
 
 // Module returns logger's module name.
@@ -67,6 +68,7 @@ func (l *Logger) Named(name ...string) *Logger {
 	var moduleBuilder strings.Builder
 	var module string
 	level := l.GetLevel()
+	isDefaultLevel := true
 	for i, m := range mm {
 		if i != 0 {
 			moduleBuilder.WriteString(".")
@@ -75,10 +77,12 @@ func (l *Logger) Named(name ...string) *Logger {
 		module = moduleBuilder.String()
 		if ml, ok := l.modules[module]; ok {
 			level = ml
+			isDefaultLevel = false
+			break
 		}
 	}
 	subLogger := root.get().With().Str("module", moduleBuilder.String()).Logger().Level(level)
-	return &Logger{module: module, modules: l.modules, development: l.development, Logger: &subLogger}
+	return &Logger{module: module, modules: l.modules, development: l.development, Logger: &subLogger, isDefaultLevel: isDefaultLevel}
 }
 
 // Sampled return a Logger with a sampler that will send every Nth events.
@@ -138,6 +142,15 @@ func (l *Logger) ToZapConfig() zap.Config {
 	}
 }
 
+// DefaultLevel sets the default level for the logger.
+func (l *Logger) DefaultLevel(level zerolog.Level) *Logger {
+	if l.isDefaultLevel {
+		nl := l.Logger.Level(level)
+		l.Logger = &nl
+	}
+	return l
+}
+
 // Loggable indicates the implement supports logging.
 type Loggable interface {
 	SetLogger(*Logger)