Repository: zeromicro/go-zero
Pull request #3104 (2023-04-07 13:10:09)

fix:multipule flag client go package name
#3103 

This code is not good, but I have no other ideas

codecov[bot]: ## [Codecov](https://codecov.io/gh/zeromicro/go-zero/pull/3104?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) Report
> Merging [#3104](https://codecov.io/gh/zeromicro/go-zero/pull/3104?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (bf83d2b) into [master](https://codecov.io/gh/zeromicro/go-zero/commit/38a97d45317ce983a559a9a12807904a8c1cd7f3?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) (38a97d4) will **decrease** coverage by `0.02%`.
> The diff coverage is `n/a`.


[see 1 file with indirect coverage changes](https://codecov.io/gh/zeromicro/go-zero/pull/3104/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None)


Patch:
diff --git a/core/conf/config.go b/core/conf/config.go
index 7d2e76e6..c39c73bf 100644
--- a/core/conf/config.go
+++ b/core/conf/config.go
@@ -242,6 +242,10 @@ func buildStructFieldsInfo(tp reflect.Type) (*fieldInfo, error) {
 
 	for i := 0; i < tp.NumField(); i++ {
 		field := tp.Field(i)
+		if !field.IsExported() {
+			continue
+		}
+
 		name := getTagName(field)
 		lowerCaseName := toLowerCase(name)
 		ft := mapping.Deref(field.Type)
diff --git a/core/mapping/unmarshaler.go b/core/mapping/unmarshaler.go
index e64a7675..e6d8a497 100644
--- a/core/mapping/unmarshaler.go
+++ b/core/mapping/unmarshaler.go
@@ -818,6 +818,11 @@ func (u *Unmarshaler) processNamedFieldWithoutValue(fieldType reflect.Type, valu
 	}
 
 	if u.opts.fillDefault {
+		if fieldType.Kind() != reflect.Ptr && fieldKind == reflect.Struct {
+			return u.processFieldNotFromString(fieldType, value, valueWithParent{
+				value: emptyMap,
+			}, opts, fullName)
+		}
 		return nil
 	}
 
diff --git a/go.mod b/go.mod
index 83df63c8..14a173ca 100644
--- a/go.mod
+++ b/go.mod
@@ -33,7 +33,7 @@ require (
 	go.opentelemetry.io/otel/trace v1.14.0
 	go.uber.org/automaxprocs v1.5.2
 	go.uber.org/goleak v1.2.1
-	golang.org/x/net v0.8.0
+	golang.org/x/net v0.9.0
 	golang.org/x/sys v0.7.0
 	golang.org/x/time v0.3.0
 	google.golang.org/genproto v0.0.0-20230123190316-2c411cf9d197
@@ -108,8 +108,8 @@ require (
 	golang.org/x/crypto v0.6.0 // indirect
 	golang.org/x/oauth2 v0.4.0 // indirect
 	golang.org/x/sync v0.1.0 // indirect
-	golang.org/x/term v0.6.0 // indirect
-	golang.org/x/text v0.8.0 // indirect
+	golang.org/x/term v0.7.0 // indirect
+	golang.org/x/text v0.9.0 // indirect
 	google.golang.org/appengine v1.6.7 // indirect
 	gopkg.in/inf.v0 v0.9.1 // indirect
 	gopkg.in/yaml.v3 v3.0.1 // indirect
diff --git a/go.sum b/go.sum
index 996c251f..cca6d9f3 100644
--- a/go.sum
+++ b/go.sum
@@ -500,8 +500,8 @@ golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qx
 golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
 golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
 golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
-golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
-golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
+golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
+golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
 golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
 golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
 golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -574,8 +574,8 @@ golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
 golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
-golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw=
-golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
+golang.org/x/term v0.7.0 h1:BEvjmm5fURWqcfbSKTdpkDXYBrUS1c0m8agp14W48vQ=
+golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
 golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -584,8 +584,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
-golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
+golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
+golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
 golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
diff --git a/tools/goctl/go.mod b/tools/goctl/go.mod
index a0b14fa6..ae57ddef 100644
--- a/tools/goctl/go.mod
+++ b/tools/goctl/go.mod
@@ -16,7 +16,7 @@ require (
 	github.com/zeromicro/antlr v0.0.1
 	github.com/zeromicro/ddl-parser v1.0.4
 	github.com/zeromicro/go-zero v1.5.0
-	golang.org/x/text v0.8.0
+	golang.org/x/text v0.9.0
 	google.golang.org/grpc v1.54.0
 	google.golang.org/protobuf v1.30.0
 )
diff --git a/tools/goctl/go.sum b/tools/goctl/go.sum
index 9d41877f..d6acde35 100644
--- a/tools/goctl/go.sum
+++ b/tools/goctl/go.sum
@@ -556,8 +556,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
-golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
-golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
+golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
+golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
 golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
diff --git a/tools/goctl/rpc/generator/gencall.go b/tools/goctl/rpc/generator/gencall.go
index d5e93e9f..060877cd 100644
--- a/tools/goctl/rpc/generator/gencall.go
+++ b/tools/goctl/rpc/generator/gencall.go
@@ -108,7 +108,7 @@ func (g *Generator) genCallGroup(ctx DirContext, proto parser.Proto, cfg *conf.C
 			"name":           callFilename,
 			"alias":          strings.Join(aliasKeys, pathx.NL),
 			"head":           head,
-			"filePackage":    dir.Base,
+			"filePackage":    childDir,
 			"pbPackage":      pbPackage,
 			"protoGoPackage": protoGoPackage,
 			"serviceName":    serviceName,
diff --git a/zrpc/internal/config.go b/zrpc/internal/config.go
index 8fc990ff..ddfb164e 100644
--- a/zrpc/internal/config.go
+++ b/zrpc/internal/config.go
@@ -1,5 +1,7 @@
 package internal
 
+import "time"
+
 type (
 	// ClientMiddlewaresConf defines whether to use client middlewares.
 	ClientMiddlewaresConf struct {
@@ -12,10 +14,12 @@ type (
 
 	// ServerMiddlewaresConf defines whether to use server middlewares.
 	ServerMiddlewaresConf struct {
-		Trace      bool `json:",default=true"`
-		Recover    bool `json:",default=true"`
-		Stat       bool `json:",default=true"`
-		Prometheus bool `json:",default=true"`
-		Breaker    bool `json:",default=true"`
+		Trace                    bool          `json:",default=true"`
+		Recover                  bool          `json:",default=true"`
+		Stat                     bool          `json:",default=true"`
+		StatSlowThreshold        time.Duration `json:",default=500ms"`
+		NotLoggingContentMethods []string      `json:",optional"`
+		Prometheus               bool          `json:",default=true"`
+		Breaker                  bool          `json:",default=true"`
 	}
 )
diff --git a/zrpc/internal/rpcserver.go b/zrpc/internal/rpcserver.go
index b981edf3..1efe35fd 100644
--- a/zrpc/internal/rpcserver.go
+++ b/zrpc/internal/rpcserver.go
@@ -113,7 +113,11 @@ func (s *rpcServer) buildUnaryInterceptors() []grpc.UnaryServerInterceptor {
 		interceptors = append(interceptors, serverinterceptors.UnaryRecoverInterceptor)
 	}
 	if s.middlewares.Stat {
-		interceptors = append(interceptors, serverinterceptors.UnaryStatInterceptor(s.metrics))
+		interceptors = append(interceptors, serverinterceptors.UnaryStatInterceptor(s.metrics,
+			serverinterceptors.StatConf{
+				SlowThreshold:            s.middlewares.StatSlowThreshold,
+				NotLoggingContentMethods: s.middlewares.NotLoggingContentMethods,
+			}))
 	}
 	if s.middlewares.Prometheus {
 		interceptors = append(interceptors, serverinterceptors.UnaryPrometheusInterceptor)
diff --git a/zrpc/internal/serverinterceptors/statinterceptor.go b/zrpc/internal/serverinterceptors/statinterceptor.go
index 7fe957cb..76812ae5 100644
--- a/zrpc/internal/serverinterceptors/statinterceptor.go
+++ b/zrpc/internal/serverinterceptors/statinterceptor.go
@@ -6,6 +6,7 @@ import (
 	"sync"
 	"time"
 
+	"github.com/zeromicro/go-zero/core/collection"
 	"github.com/zeromicro/go-zero/core/lang"
 	"github.com/zeromicro/go-zero/core/logx"
 	"github.com/zeromicro/go-zero/core/stat"
@@ -22,18 +23,29 @@ var (
 	slowThreshold            = syncx.ForAtomicDuration(defaultSlowThreshold)
 )
 
+// StatConf defines the static configuration for stat interceptor.
+type StatConf struct {
+	SlowThreshold            time.Duration
+	NotLoggingContentMethods []string
+}
+
 // DontLogContentForMethod disable logging content for given method.
+// Deprecated: use StatConf instead.
 func DontLogContentForMethod(method string) {
 	notLoggingContentMethods.Store(method, lang.Placeholder)
 }
 
 // SetSlowThreshold sets the slow threshold.
+// Deprecated: use StatConf instead.
 func SetSlowThreshold(threshold time.Duration) {
 	slowThreshold.Set(threshold)
 }
 
 // UnaryStatInterceptor returns a func that uses given metrics to report stats.
-func UnaryStatInterceptor(metrics *stat.Metrics) grpc.UnaryServerInterceptor {
+func UnaryStatInterceptor(metrics *stat.Metrics, conf StatConf) grpc.UnaryServerInterceptor {
+	staticNotLoggingContentMethods := collection.NewSet()
+	staticNotLoggingContentMethods.AddStr(conf.NotLoggingContentMethods...)
+
 	return func(ctx context.Context, req any, info *grpc.UnaryServerInfo,
 		handler grpc.UnaryHandler) (resp any, err error) {
 		startTime := timex.Now()
@@ -42,14 +54,16 @@ func UnaryStatInterceptor(metrics *stat.Metrics) grpc.UnaryServerInterceptor {
 			metrics.Add(stat.Task{
 				Duration: duration,
 			})
-			logDuration(ctx, info.FullMethod, req, duration)
+			logDuration(ctx, info.FullMethod, req, duration,
+				staticNotLoggingContentMethods, conf.SlowThreshold)
 		}()
 
 		return handler(ctx, req)
 	}
 }
 
-func logDuration(ctx context.Context, method string, req any, duration time.Duration) {
+func logDuration(ctx context.Context, method string, req any, duration time.Duration,
+	staticNotLoggingContentMethods *collection.Set, staticSlowThreshold time.Duration) {
 	var addr string
 	client, ok := peer.FromContext(ctx)
 	if ok {
@@ -57,9 +71,8 @@ func logDuration(ctx context.Context, method string, req any, duration time.Dura
 	}
 
 	logger := logx.WithContext(ctx).WithDuration(duration)
-	_, ok = notLoggingContentMethods.Load(method)
-	if ok {
-		if duration > slowThreshold.Load() {
+	if !shouldLogContent(method, staticNotLoggingContentMethods) {
+		if isSlow(duration, staticSlowThreshold) {
 			logger.Slowf("[RPC] slowcall - %s - %s", addr, method)
 		}
 	} else {
@@ -73,3 +86,13 @@ func logDuration(ctx context.Context, method string, req any, duration time.Dura
 		}
 	}
 }
+
+func shouldLogContent(method string, staticNotLoggingContentMethods *collection.Set) bool {
+	_, ok := notLoggingContentMethods.Load(method)
+	return !ok && !staticNotLoggingContentMethods.Contains(method)
+}
+
+func isSlow(duration time.Duration, staticSlowThreshold time.Duration) bool {
+	return duration > slowThreshold.Load() ||
+		(staticSlowThreshold > 0 && duration > staticSlowThreshold)
+}
diff --git a/zrpc/server.go b/zrpc/server.go
index 158d8109..4b9963d6 100644
--- a/zrpc/server.go
+++ b/zrpc/server.go
@@ -100,11 +100,13 @@ func (rs *RpcServer) Stop() {
 }
 
 // DontLogContentForMethod disable logging content for given method.
+// Deprecated: use ServerMiddlewaresConf.NotLoggingContentMethods instead.
 func DontLogContentForMethod(method string) {
 	serverinterceptors.DontLogContentForMethod(method)
 }
 
 // SetServerSlowThreshold sets the slow threshold on server side.
+// Deprecated: use ServerMiddlewaresConf.SlowThreshold instead.
 func SetServerSlowThreshold(threshold time.Duration) {
 	serverinterceptors.SetSlowThreshold(threshold)
 }


Test patch:
diff --git a/core/conf/config_test.go b/core/conf/config_test.go
index a0d15140..9667f93f 100644
--- a/core/conf/config_test.go
+++ b/core/conf/config_test.go
@@ -1040,6 +1040,24 @@ func TestLoadNamedFieldOverwritten(t *testing.T) {
 	})
 }
 
+func TestLoadLowerMemberShouldNotConflict(t *testing.T) {
+	type (
+		Redis struct {
+			db uint
+		}
+
+		Config struct {
+			db uint
+			Redis
+		}
+	)
+
+	var c Config
+	assert.NoError(t, LoadFromJsonBytes([]byte(`{}`), &c))
+	assert.Zero(t, c.db)
+	assert.Zero(t, c.Redis.db)
+}
+
 func TestFillDefaultUnmarshal(t *testing.T) {
 	t.Run("nil", func(t *testing.T) {
 		type St struct{}
diff --git a/core/mapping/unmarshaler_test.go b/core/mapping/unmarshaler_test.go
index 1f723263..6d373444 100644
--- a/core/mapping/unmarshaler_test.go
+++ b/core/mapping/unmarshaler_test.go
@@ -12,6 +12,7 @@ import (
 
 	"github.com/google/uuid"
 	"github.com/stretchr/testify/assert"
+
 	"github.com/zeromicro/go-zero/core/stringx"
 )
 
@@ -4453,7 +4454,7 @@ func TestFillDefaultUnmarshal(t *testing.T) {
 		var st St
 		err := fillDefaultUnmarshal.Unmarshal(map[string]any{}, &st)
 		assert.NoError(t, err)
-		assert.Equal(t, st.A, "a")
+		assert.Equal(t, "a", st.A)
 	})
 
 	t.Run("env", func(t *testing.T) {
@@ -4467,8 +4468,8 @@ func TestFillDefaultUnmarshal(t *testing.T) {
 		var st St
 		err := fillDefaultUnmarshal.Unmarshal(map[string]any{}, &st)
 		assert.NoError(t, err)
-		assert.Equal(t, st.A, "a")
-		assert.Equal(t, st.C, "c")
+		assert.Equal(t, "a", st.A)
+		assert.Equal(t, "c", st.C)
 	})
 
 	t.Run("has value", func(t *testing.T) {
@@ -4482,6 +4483,30 @@ func TestFillDefaultUnmarshal(t *testing.T) {
 		err := fillDefaultUnmarshal.Unmarshal(map[string]any{}, &st)
 		assert.Error(t, err)
 	})
+
+	t.Run("handling struct", func(t *testing.T) {
+		type St struct {
+			A string `json:",default=a"`
+			B string
+		}
+		type St2 struct {
+			St
+			St1   St
+			St3   *St
+			C     string `json:",default=c"`
+			D     string
+			Child *St2
+		}
+		var st2 St2
+		err := fillDefaultUnmarshal.Unmarshal(map[string]any{}, &st2)
+		assert.NoError(t, err)
+		assert.Equal(t, "a", st2.St.A)
+		assert.Equal(t, "a", st2.St1.A)
+		assert.Nil(t, st2.St3)
+		assert.Equal(t, "c", st2.C)
+		assert.Nil(t, st2.Child)
+	})
+
 }
 
 func Test_UnmarshalMap(t *testing.T) {
diff --git a/zrpc/internal/serverinterceptors/statinterceptor_test.go b/zrpc/internal/serverinterceptors/statinterceptor_test.go
index 90223a28..d3cbfaed 100644
--- a/zrpc/internal/serverinterceptors/statinterceptor_test.go
+++ b/zrpc/internal/serverinterceptors/statinterceptor_test.go
@@ -3,12 +3,15 @@ package serverinterceptors
 import (
 	"context"
 	"net"
+	"sync"
 	"testing"
 	"time"
 
 	"github.com/stretchr/testify/assert"
+	"github.com/zeromicro/go-zero/core/collection"
 	"github.com/zeromicro/go-zero/core/lang"
 	"github.com/zeromicro/go-zero/core/stat"
+	"github.com/zeromicro/go-zero/core/syncx"
 	"google.golang.org/grpc"
 	"google.golang.org/grpc/peer"
 )
@@ -16,12 +19,16 @@ import (
 func TestSetSlowThreshold(t *testing.T) {
 	assert.Equal(t, defaultSlowThreshold, slowThreshold.Load())
 	SetSlowThreshold(time.Second)
+	// reset slowThreshold
+	t.Cleanup(func() {
+		slowThreshold = syncx.ForAtomicDuration(defaultSlowThreshold)
+	})
 	assert.Equal(t, time.Second, slowThreshold.Load())
 }
 
 func TestUnaryStatInterceptor(t *testing.T) {
 	metrics := stat.NewMetrics("mock")
-	interceptor := UnaryStatInterceptor(metrics)
+	interceptor := UnaryStatInterceptor(metrics, StatConf{})
 	_, err := interceptor(context.Background(), nil, &grpc.UnaryServerInfo{
 		FullMethod: "/",
 	}, func(ctx context.Context, req any) (any, error) {
@@ -78,7 +85,8 @@ func TestLogDuration(t *testing.T) {
 			t.Parallel()
 
 			assert.NotPanics(t, func() {
-				logDuration(test.ctx, "foo", test.req, test.duration)
+				logDuration(test.ctx, "foo", test.req, test.duration,
+					collection.NewSet(), 0)
 			})
 		})
 	}
@@ -127,14 +135,129 @@ func TestLogDurationWithoutContent(t *testing.T) {
 	}
 
 	DontLogContentForMethod("foo")
+	// reset notLoggingContentMethods
+	t.Cleanup(func() {
+		notLoggingContentMethods = sync.Map{}
+	})
 	for _, test := range tests {
 		test := test
 		t.Run(test.name, func(t *testing.T) {
 			t.Parallel()
 
 			assert.NotPanics(t, func() {
-				logDuration(test.ctx, "foo", test.req, test.duration)
+				logDuration(test.ctx, "foo", test.req, test.duration,
+					collection.NewSet(), 0)
+			})
+		})
+	}
+}
+
+func Test_shouldLogContent(t *testing.T) {
+	type args struct {
+		method                         string
+		staticNotLoggingContentMethods []string
+	}
+
+	tests := []struct {
+		name  string
+		args  args
+		want  bool
+		setup func()
+	}{
+		{
+			"empty",
+			args{
+				method: "foo",
+			},
+			true,
+			nil,
+		},
+		{
+			"static",
+			args{
+				method:                         "foo",
+				staticNotLoggingContentMethods: []string{"foo"},
+			},
+			false,
+			nil,
+		},
+		{
+			"dynamic",
+			args{
+				method: "foo",
+			},
+			false,
+			func() {
+				DontLogContentForMethod("foo")
+			},
+		},
+	}
+
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			if tt.setup != nil {
+				tt.setup()
+			}
+			// reset notLoggingContentMethods
+			t.Cleanup(func() {
+				notLoggingContentMethods = sync.Map{}
+			})
+			set := collection.NewSet()
+			set.AddStr(tt.args.staticNotLoggingContentMethods...)
+			assert.Equalf(t, tt.want, shouldLogContent(tt.args.method, set), "shouldLogContent(%v, %v)", tt.args.method, tt.args.staticNotLoggingContentMethods)
+		})
+	}
+}
+
+func Test_isSlow(t *testing.T) {
+	type args struct {
+		duration            time.Duration
+		staticSlowThreshold time.Duration
+	}
+	tests := []struct {
+		name  string
+		args  args
+		want  bool
+		setup func()
+	}{
+		{
+			"default",
+			args{
+				duration: time.Millisecond * 501,
+			},
+			true,
+			nil,
+		},
+		{
+			"static",
+			args{
+				duration:            time.Millisecond * 200,
+				staticSlowThreshold: time.Millisecond * 100,
+			},
+			true,
+			nil,
+		},
+		{
+			"dynamic",
+			args{
+				duration: time.Millisecond * 200,
+			},
+			true,
+			func() {
+				SetSlowThreshold(time.Millisecond * 100)
+			},
+		},
+	}
+	for _, tt := range tests {
+		t.Run(tt.name, func(t *testing.T) {
+			if tt.setup != nil {
+				tt.setup()
+			}
+			// reset slowThreshold
+			t.Cleanup(func() {
+				slowThreshold = syncx.ForAtomicDuration(defaultSlowThreshold)
 			})
+			assert.Equalf(t, tt.want, isSlow(tt.args.duration, tt.args.staticSlowThreshold), "isSlow(%v, %v)", tt.args.duration, tt.args.staticSlowThreshold)
 		})
 	}
 }