trace

package
v0.0.0-...-8124b04 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 3 Imported by: 1

Documentation

Overview

Package trace 基于 context 封装一个 trace ID 功能

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureTraceID

func EnsureTraceID(ctx context.Context) context.Context

EnsureTraceID 确保 context 中有一个 trace ID

func TraceID

func TraceID(ctx context.Context) string

TraceID 从 context 中读取 trace ID

func TraceIDContextKey

func TraceIDContextKey() any

TraceIDContextKey 返回 trace ID 的 context key, 用于一些外部需要复制 context 的 key / value 的场景

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