Skip to content

Commit

Permalink
log: temporary remove recvTs from context log (#9673)
Browse files Browse the repository at this point in the history
  • Loading branch information
lysu authored and ngaut committed Mar 12, 2019
1 parent 52c8267 commit a2d4bd1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
2 changes: 1 addition & 1 deletion server/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ func (cc *clientConn) Run(ctx context.Context) {
}

startTime := time.Now()
if err = cc.dispatch(logutil.WithRecvTs(ctx, startTime.UnixNano()/int64(time.Millisecond)), data); err != nil {
if err = cc.dispatch(ctx, data); err != nil {
if terror.ErrorEqual(err, io.EOF) {
cc.addMetrics(data[0], startTime, nil)
return
Expand Down
13 changes: 0 additions & 13 deletions util/logutil/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,16 +382,3 @@ func WithConnID(ctx context.Context, connID uint32) context.Context {
}
return context.WithValue(ctx, ctxLogKey, logger.With(zap.Uint32("conn", connID)))
}

// WithRecvTs attaches current packet received timestamp to context.
// it's common that each SQL has a packet receive timestamp in MySQL Protocol,
// so we can use recvTs to gather log for some sql request on one connection.
func WithRecvTs(ctx context.Context, recvTs int64) context.Context {
var logger *zap.Logger
if ctxLogger, ok := ctx.Value(ctxLogKey).(*zap.Logger); ok {
logger = ctxLogger
} else {
logger = zaplog.L()
}
return context.WithValue(ctx, ctxLogKey, logger.With(zap.Int64("recvTs", recvTs)))
}

0 comments on commit a2d4bd1

Please sign in to comment.