Documentation ¶
Overview ¶
Package tracelog 提供带 tracing 功能的日志功能以及一些工具
Index ¶
- Constants
- func EnsureTraceID(ctx context.Context) context.Context
- func RegisterTraceLogFilter()
- func ToErrJSON(e error) fmt.Stringer
- func ToJSON(v any) fmt.Stringer
- func ToJSONString(v any) fmt.Stringer
- func TraceID(ctx context.Context) string
- func TraceIDStack(ctx context.Context) []string
- func WithTraceID(ctx context.Context, traceID string) context.Context
- func WithTraceIDStack(ctx context.Context, traceIDStack []string) context.Context
Constants ¶
View Source
const ( // tracelog 的 filter 名称 FilterName = "tracelog" // TraceIDMetadataKey 定义用于传递 trace ID 的 trpc metadata 字段 TraceIDStackMetadataKey = "trace_id_stack" )
Variables ¶
This section is empty.
Functions ¶
func EnsureTraceID ¶
EnsureTraceID 确保 context 中有一个 trace ID, 协程不安全
func RegisterTraceLogFilter ¶
func RegisterTraceLogFilter()
RegisterTraceLogFilter 注册 tracelog filter。请在 trpc.NewServer 之前调用。
func ToJSONString ¶
func TraceIDStack ¶
TraceIDStack 从 context 中读取历史 trace ID 栈
func WithTraceID ¶
WithTraceID 更新 trace ID
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.