Skip to content

Commit bdf9b13

Browse files
committed
[feat] eliminate log consumption
1 parent 81431d8 commit bdf9b13

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

pkg/breaker/googlesrebreaker.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,13 @@ func (gsb *googleSreBreaker) Allow() error {
8383
success, total := gsb.summary()
8484
googleAccepts := gsb.k * success
8585
dropRatio := math.Max(0, (float64(total)-googleAccepts)/float64(total+1))
86-
log.Debugf("breaker", log.String("name", gsb.name), log.Int64("total", total), log.Float64("success", success), log.Float64("accepts", googleAccepts), log.Float64("ratio", dropRatio))
8786
if dropRatio <= 0 {
8887
if atomic.LoadInt32(&gsb.state) == StateOpen {
8988
atomic.CompareAndSwapInt32(&gsb.state, StateOpen, StateClosed)
9089
}
9190
return nil
91+
} else {
92+
log.Errorf("breaker", log.String("name", gsb.name), log.Int64("total", total), log.Float64("success", success), log.Float64("accepts", googleAccepts), log.Float64("ratio", dropRatio))
9293
}
9394

9495
if atomic.LoadInt32(&gsb.state) == StateClosed {

pkg/server/rpc/client/client.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,7 @@ func (c *Client) ChainUnaryClient() grpc.UnaryClientInterceptor {
123123
}
124124
}
125125

126-
// Chain creates a single interceptor out of a chain of many interceptors.
127126
// WithUnaryServerChain is a grpc.Client dial option that accepts multiple unary interceptors.
128-
// Basically syntactic sugar.
129127
func (c *Client) WithUnaryServerChain() grpc.DialOption {
130128
return grpc.WithUnaryInterceptor(c.ChainUnaryClient())
131129
}
@@ -151,7 +149,7 @@ func (c *Client) GetConn() *grpc.ClientConn {
151149
return c.conn
152150
}
153151

154-
// GetConn return the client breakers
152+
// GetBreakers return the client breakers
155153
func (c *Client) GetBreakers() *breaker.BreakerGroup {
156154
return c.breakers
157155
}

pkg/server/rpc/interceptors/logger.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,13 @@ func LoggerForUnaryClient(config *config.ClientConfig) grpc.UnaryClientIntercept
107107
if peerInfo.Addr != nil {
108108
peerIP = peerInfo.Addr.String()
109109
}
110-
fields := make([]log.Field, 0, 8)
110+
fields := make([]log.Field, 0, 7)
111111
fields = append(
112112
fields,
113113
log.String("peer", peerIP),
114114
log.String("method", method),
115115
log.Float64("quota", quota),
116116
log.Float64("duration", duration.Seconds()),
117-
log.Any("reply", json.RawMessage(log.JsonBytes(reply))),
118117
log.Int("code", estatus.Code()),
119118
log.String("error", estatus.Message()),
120119
)

0 commit comments

Comments
 (0)