(*common.Trace) Log.logger.Error(tag, append(fields, zap.String("trace_id", trace.TraceId), zap.Int("user_id", trace.UserId))..., ) } func Fatal(tag string, fields ...zap.Field) { Log.logger.Fatal(tag, fields...) } func FatalF(ctx context.Context, tag string, fields ......
Filename: filepath.Join(l.logDir, l.logFileName), // ⽇志⽂件路径 MaxSize: l.logMaxSize, // 单位为MB,默认为512MB MaxAge: l.logMaxAge, // 文件最多保存多少天 LocalTime: l.localTime, // 采用本地时间 Compress: l.logCompress, // 是否压缩日志 }), } if l.stdout { opts = a...
func AddTraceId() gin.HandlerFunc { return func(g *gin.Context) { traceId := g.GetHeader("traceId") if traceId == "" { traceId = uuid.New().String() } ctx, log := hlog.GetLogger().AddCtx(g.Request.Context(), zap.Any("traceId", traceId)) g.Request = g.Request.WithContext(...
SkipPaths:[]string{"/no_log"}, })) ``` Custom Zap fields example for custom log request body, response request ID or logOpen TelemetryTraceID. ```go funcmain(){ r:=gin.New() logger,_:=zap.NewProduction() r.Use(ginzap.GinzapWithConfig(logger,&ginzap.Config{ ...
Field // 读取ctx中的trace_id,然后设置到日志中 traceId := ctx.Value("trace_id") if traceId != nil { fields = append(fields, zap.String("trace_id", traceId.(string))) } return fields }, } if err := zaplogger.Init(conf); err != nil { panic(err) } // 通过context传递trace_...
example for custom log request body, response request ID or logOpen TelemetryTraceID. funcmain() {r:=gin.New()logger,_:=zap.NewProduction()r.Use(ginzap.GinzapWithConfig(logger,&ginzap.Config{UTC:true,TimeFormat:time.RFC3339,Context:ginzap.Fn(func(c*gin.Context) []zapcore.Field{fields:...
TraceID, local.SpanID, local.ParentSpanID} { if value, ok := ctx.Value(key).(string); ok { fields = append(fields, zap.String(key, value)) } } if len(fields) > 0 { setup = setup.With(fields...) } return context.WithValue(ctx, loggerKey, setup) } // Get zap.Logger from ...
如果需要自定义跟踪信息,格式如下(将istio的请求头中的X-B3-的跟踪信息取出来,拼成以下格式): 格式 traceid:spanid:parentid:1 46b1506e7332f7c1:7f75737aa70629cc:3bb947500f42ad71:1 ctx := context.WithValue(ctx,tracer.LogTraceKey,"46b1506e7332f7c1:7f75737aa70629cc:3bb947500f42ad71:1") 只需...
forked fromGLCharge/otelzap NotificationsYou must be signed in to change notification settings Fork0 Star0 Files master example README.md arrayencoder.go fieldextractor.go global.go go.mod go.sum option.go otelzap.go otelzap_test.go
Solutions By company size Enterprises Small and medium teams Startups Nonprofits By use case DevSecOps DevOps CI/CD View all use cases By industry Healthcare Financial services Manufacturing Government View all industries View all solutions Resources Topics AI DevOps Security Software...