12345678910111213141516171819202122232425 |
- package task
- import (
- "context"
- "fmt"
- "time"
- "gadm-ods/common.in/utils"
- "go.uber.org/zap"
- )
- func printAccessLog(ctx context.Context, startTime uint64, status string) {
- if l != nil {
- // 取出跟踪日志id息
- spanID := utils.GetSpanFromRpcCtx(ctx)
- // 结束时间
- endTime := uint64(time.Now().UnixNano())
- l.Info(utils.GetMethodFromRpcCtx(ctx),
- zap.Uint64("trace_id", uint64(spanID.Trace)),
- zap.Uint64("span_id", uint64(spanID.Span)),
- zap.Uint64("parent_id", uint64(spanID.Parent)),
- zap.String("status", status),
- zap.String("elapsed", fmt.Sprintf("%fms", float64(endTime-startTime)/1000000)))
- }
- }
|