fix: should not ignore slowThreshold (#4655)

This commit is contained in:
Kevin Wan
2025-02-14 23:14:57 +08:00
committed by GitHub
parent 6a0672b801
commit 790302b486
2 changed files with 6 additions and 4 deletions

View File

@@ -25,7 +25,7 @@ var (
// StatConf defines the static configuration for stat interceptor.
type StatConf struct {
SlowThreshold time.Duration `json:",optional"`
SlowThreshold time.Duration `json:",default=500ms"`
IgnoreContentMethods []string `json:",optional"`
}
@@ -63,7 +63,8 @@ func UnaryStatInterceptor(metrics *stat.Metrics, conf StatConf) grpc.UnaryServer
}
func isSlow(duration, durationThreshold time.Duration) bool {
return durationThreshold > 0 && duration > durationThreshold
return duration > slowThreshold.Load() ||
(durationThreshold > 0 && duration > durationThreshold)
}
func logDuration(ctx context.Context, method string, req any, duration time.Duration,