tracelog

package
v0.0.0-...-be573ad Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: MIT Imports: 12 Imported by: 4

Documentation

Overview

Package tracelog 提供带 tracing 功能的日志功能以及一些工具

Index

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

func EnsureTraceID(ctx context.Context) context.Context

EnsureTraceID 确保 context 中有一个 trace ID, 协程不安全

func RegisterTraceLogFilter

func RegisterTraceLogFilter()

RegisterTraceLogFilter 注册 tracelog filter。请在 trpc.NewServer 之前调用。

func ToErrJSON

func ToErrJSON(e error) fmt.Stringer

func ToJSON

func ToJSON(v any) fmt.Stringer

ToJSON 在打日志的时候转为 JSON string

func ToJSONString

func ToJSONString(v any) fmt.Stringer

func TraceID

func TraceID(ctx context.Context) string

TraceID 从 context 中读取 trace ID

func TraceIDStack

func TraceIDStack(ctx context.Context) []string

TraceIDStack 从 context 中读取历史 trace ID 栈

func WithTraceID

func WithTraceID(ctx context.Context, traceID string) context.Context

WithTraceID 更新 trace ID

func WithTraceIDStack

func WithTraceIDStack(ctx context.Context, traceIDStack []string) context.Context

WithTraceIDStack 完全替换整个 trace ID 栈

Types

This section is empty.

Jump to

Keyboard shortcuts

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