Documentation
¶
Index ¶
- func AttachTraceID(ctx context.Context) (traceID string, result context.Context)
- func ForkTracedContext(ctx context.Context) (forked context.Context)
- func GetClientIPFromPeer(ctx context.Context) (ip string)
- func GetTraceID(ctx context.Context) (traceID string, result context.Context)
- func NewContext() context.Context
- func NewContextWithTid(traceID string) context.Context
- func NewContextWithTraceID() context.Context
- func Stack(skip int) []byte
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AttachTraceID ¶
AttachTraceID 为 context 附加 trace_id
func ForkTracedContext ¶ added in v1.2.6
ForkTracedContext 从已有 trace_id 的 context 中生成一个新的 context,用于在新的 goroutine 中使用
func GetClientIPFromPeer ¶ added in v1.2.11
GetClientIPFromPeer get client ip from a grpc request, if not a grpc request or no client ip, return empty string example:
clientIP := trace.GetClientIPFromPeer(ctx)
if clientIP == "" {
// not a grpc request or no client ip
}
func GetTraceID ¶
GetTraceID 从 context 中获取 trace_id,如果获取失败,则重新生成
func NewContext ¶ added in v1.2.11
NewContext build a new context with trace_id
func NewContextWithTid ¶ added in v1.2.11
NewContextWithTid build a new context with existed trace_id
func NewContextWithTraceID ¶
NewContextWithTraceID 从 context.Background 生成一个新的 context,并附加 trace_id Deprecated: use NewContext instead
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.