kk_stage

package
v0.0.0-...-cfc9456 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: BSD-3-Clause Imports: 19 Imported by: 3

Documentation

Index

Constants

View Source
const (
	ErrorKey   = "Error"
	TraceIdKey = "TraceId"
)

Variables

View Source
var EnableTracer = false

Functions

func CloseTracer

func CloseTracer(stage *Stage)

func DefaultLogConfig

func DefaultLogConfig(fileName string) *lumberjack.Logger

func InitSlog

func InitSlog(debugMode bool, logger *lumberjack.Logger, opts *slog.HandlerOptions)

InitSlog init slog with log file name. if debugMode is true, slog will print log to stdout and do not write to file.

func InitTracer

func InitTracer(stage *Stage, enabled bool, serviceName string, grpcTarget string)

Types

type LogBody

type LogBody struct {
	// contains filtered or unexported fields
}

func NewLog

func NewLog(stage *Stage) (l *LogBody)

func (*LogBody) Any

func (l *LogBody) Any(key string, value any) *LogBody

func (*LogBody) Args

func (l *LogBody) Args() []any

func (*LogBody) Error

func (l *LogBody) Error(err error) *LogBody

func (*LogBody) String

func (l *LogBody) String(key string, value string) *LogBody

type Stage

type Stage struct {
	Ctx         context.Context
	GinCtx      *gin.Context
	Keys        *sync.Map
	Tracer      *Tracer
	TraceId     string
	ServiceName string
	DebugMode   bool
}

func NewStage

func NewStage(ctx context.Context, serviceName string, debugMode bool) (stage *Stage)

func (*Stage) Copy

func (stage *Stage) Copy() *Stage

Copy use this to create a new stage in a new goroutine

func (*Stage) Get

func (stage *Stage) Get(key any) (value any, exists bool)

func (*Stage) Set

func (stage *Stage) Set(key any, value any)

func (*Stage) SetGinCtx

func (stage *Stage) SetGinCtx(c *gin.Context) *Stage

func (*Stage) StartTrace

func (stage *Stage) StartTrace(spanName string) (span trace.Span)

type Tracer

type Tracer struct {
	Tracer  trace.Tracer
	Context context.Context
}

func NewTracer

func NewTracer(serviceName string, ctx context.Context) *Tracer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL