mtrace

package
v0.0.0-...-961d35a Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckSetDefaultTextMapPropagator

func CheckSetDefaultTextMapPropagator()

CheckSetDefaultTextMapPropagator 如果之前未设置,则设置默认的 TextMapPropagator

func GetBaggageMap

func GetBaggageMap(ctx context.Context) map[string]any

GetBaggageMap 获取并返回 baggage 值的 map

func GetBaggageVar

func GetBaggageVar(ctx context.Context, key string) *mvar.Var

GetBaggageVar 从 baggage 中获取指定 key 的值并返回 *mvar.Var

func GetDefaultTextMapPropagator

func GetDefaultTextMapPropagator() propagation.TextMapPropagator

GetDefaultTextMapPropagator 返回用于对等体间上下文传播的默认传播器

func GetSpanID

func GetSpanID(ctx context.Context) string

GetSpanID 从上下文中获取 SpanId

func GetTraceID

func GetTraceID(ctx context.Context) string

GetTraceID 从上下文中获取 TraceId

func IsUsingDefaultProvider

func IsUsingDefaultProvider() bool

IsUsingDefaultProvider 检查是否使用默认的 trace provider

func SetBaggageMap

func SetBaggageMap(ctx context.Context, data map[string]any) context.Context

SetBaggageMap 是一个便捷函数,用于向 baggage 添加多个键值对

func SetBaggageValue

func SetBaggageValue(ctx context.Context, key string, value any) context.Context

SetBaggageValue 是一个便捷函数,用于向 baggage 添加一个键值对

func WithTraceID

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

WithTraceID 将自定义的 trace id 注入到上下文中

func WithUUID

func WithUUID(ctx context.Context, uuid string) (context.Context, error)

WithUUID 将自定义的 UUID 作为 trace id 注入到上下文中

Types

type Baggage

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

Baggage 是一种在分布式系统的上下文中传播键值对数据的机制 它允许将自定义数据(如用户ID、请求ID等)附加到跟踪中,并在服务调用之间传播

func NewBaggage

func NewBaggage(ctx context.Context) *Baggage

NewBaggage 创建一个新的 Baggage 实例

func (*Baggage) GetMap

func (b *Baggage) GetMap() map[string]interface{}

GetMap 获取所有 baggage 值

func (*Baggage) GetVar

func (b *Baggage) GetVar(key string) *mvar.Var

GetVar 获取指定 key 的 baggage 值

func (*Baggage) SetMap

func (b *Baggage) SetMap(data map[string]interface{}) context.Context

SetMap 批量设置 baggage 值

func (*Baggage) SetValue

func (b *Baggage) SetValue(key string, value interface{}) context.Context

SetValue 设置单个 baggage 值

type Span

type Span struct {
	trace.Span
}

Span 包装了 trace.Span 以提供兼容性和扩展

func NewSpan

func NewSpan(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, *Span)

NewSpan 使用默认的 tracer 创建一个 span

type Tracer

type Tracer struct {
	trace.Tracer
}

func NewTracer

func NewTracer(name ...string) *Tracer

NewTracer 创建并返回一个新的 tracer

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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