Documentation ¶
Index ¶
- func Debug(ctx context.Context, msg string, attributes ...Field)
- func End(ctx context.Context)
- func Error(ctx context.Context, msg string, attributes ...Field)
- func Fatal(ctx context.Context, msg string, attributes ...Field)
- func FieldsToKeyValues(fields ...Field) []attribute.KeyValue
- func FieldsToZapFields(ctx context.Context, fields ...Field) []zapcore.Field
- func GenSpanID() string
- func GenTraceID() string
- func GinMiddleware(service string) gin.HandlerFunc
- func HttpInject(ctx context.Context, request *http.Request) error
- func Info(ctx context.Context, msg string, attributes ...Field)
- func Init(conf Config, applicationAttributes ...Field)
- func NewRootContext(traceID string, spanID string) (context.Context, error)
- func SetSpanAttr(ctx context.Context, attributes ...Field)
- func SpanID(ctx context.Context) string
- func Start(ctx context.Context, spanName string, spanStartOption ...Field) context.Context
- func TraceID(ctx context.Context) string
- func Warn(ctx context.Context, msg string, attributes ...Field)
- type Config
- type Field
- func Any(key string, val interface{}) Field
- func Bool(key string, val bool) Field
- func BoolSlice(key string, val []bool) Field
- func Err(err error) Field
- func Float64(key string, val float64) Field
- func Float64Slice(key string, val []float64) Field
- func Int(key string, val int) Field
- func Int64(key string, val int64) Field
- func Int64Slice(key string, val []int64) Field
- func IntSlice(key string, val []int) Field
- func String(key string, val string) Field
- func StringSlice(key string, val []string) Field
- func Stringer(key string, val fmt.Stringer) Field
- type FieldType
- type LoggerSpanContext
- type Trace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FieldsToKeyValues ¶
FieldsToKeyValue
func FieldsToZapFields ¶
FieldsToZapFields
func GenTraceID ¶
func GenTraceID() string
GenTraceID generate traceID current timestamp with 8 rand bytes
func GinMiddleware ¶
func GinMiddleware(service string) gin.HandlerFunc
GinMiddleware extract spanContext
func HttpInject ¶
HTTPInject inject spanContext
func Init ¶
LoggerInit logger初始化
applicationAttributes 应用属性,如应用的名称,版本等 can use service.name,service.namesapce,service.instance.id,service.version, telemetry.sdk.name,telemetry.sdk.language,telemetry.sdk.version,telemetry.auto.version or other key that you need
example: Init(conf,String("sevice.name",service1))
func NewRootContext ¶
NewRootContext new root context with given traceID and spanID
func SetSpanAttr ¶ added in v0.0.2
SetSpanAttr 为当前的span动态设置属性
Types ¶
type Config ¶
type Config struct { // 是否开启debug模式,未开启debug模式,仅记录错误 Debug bool `yaml:"debug" mapstructure:"debug"` // 追踪使能 EnableTrace bool `yaml:"enable_trace" mapstructure:"enable_trace"` // 日志输出的方式 // none为不输出日志,file 为文件方式输出,console为控制台。默认为console Output string `yaml:"output" mapstructure:"output"` // 日志文件路径 File string `yaml:"file" mapstructure:"file"` // 日志文件路径 // 日志文件大小限制,默认最大100MB,超过将触发文件切割 MaxSize int `yaml:"max_size" mapstructure:"max_size"` // 日志文件的分割文件的数量,超过的将会被删除 MaxBackups int `yaml:"max_backups" mapstructure:"max_backups"` // 日志文件的保留时间,超过的将会被删除 MaxAge int `yaml:"max_age" mapstructure:"max_age"` // 是否启用日志文件的压缩功能 Compress bool `yaml:"compress" mapstructure:"compress"` // 是否启用日志的切割功能 Rotate string `yaml:"rotate" mapstructure:"rotate"` // 日志追踪的类型,file or jaeger TracerProviderType string `yaml:"tracer_provider_type" mapstructure:"tracer_provider_type"` // 日志追踪采样的比率, 0.0-1 // 0,never trace // 1,always trace TraceSampleRatio float64 `yaml:"trace_sample_ratio" mapstructure:"trace_sample_ratio"` // 最大span数量限制,当达到最大限制时,停止trace // default 200 MaxSpan int `yaml:"max_span" mapstructure:"max_span"` // Jaeger server JaegerServer string `yaml:"jaeger_server" mapstructure:"jaeger_server"` JaegerUsername string `yaml:"jaeger_username" mapstructure:"jaeger_username"` JaegerPassword string `yaml:"jaeger_password" mapstructure:"jaeger_password"` }
Config 配置项
type Field ¶
type LoggerSpanContext ¶
type LoggerSpanContext struct {
// contains filtered or unexported fields
}
save context span
type Trace ¶
type Trace struct{}
func (Trace) NewFileProvider ¶
NewFileProvider
func (Trace) NewJaegerProvider ¶
func (tx Trace) NewJaegerProvider(conf Config, attributes ...Field, ) (*trace.TracerProvider, error)
NewJaegerProvider
Click to show internal directories.
Click to hide internal directories.