gtrace

package
v0.0.0-...-fcd50c7 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

包gtrace提供了使用OpenTelemetry进行跟踪功能的便利封装。 md5:4c5ceb4a418df579

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckSetDefaultTextMapPropagator

func CheckSetDefaultTextMapPropagator()

CheckSetDefaultTextMapPropagator 如果之前未设置,默认情况下会设置文本映射传播器。 md5:586855119e290f63

func CommonLabels

func CommonLabels() []attribute.KeyValue

CommonLabels 返回常用属性标签: ip.intranet,hostname。 md5:8affbee0c43e3bad

func GetBaggageMap

func GetBaggageMap(ctx context.Context) *gmap.StrAnyMap

GetBaggageMap 获取并返回行李(baggage)的值作为map。 md5:c2fd062493b49cd1

func GetBaggageVar

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

GetBaggageVar 从 baggage 中检索值,并为指定的键返回一个 *gvar.Var。 md5:b7635ba9a07703cf

func GetDefaultTextMapPropagator

func GetDefaultTextMapPropagator() propagation.TextMapPropagator

GetDefaultTextMapPropagator 返回用于在对等体之间传播上下文的默认 propagator。 md5:c053466fb206297d

func GetSpanID

func GetSpanID(ctx context.Context) string

GetSpanID 从上下文中检索并返回 SpanId。如果跟踪功能未激活,则返回空字符串。 md5:1cca885adbc44f92

func GetTraceID

func GetTraceID(ctx context.Context) string

GetTraceID 从 context 中检索并返回 TraceId。如果跟踪功能未启用,则返回空字符串。 md5:09e9e014a696e105

func IsTracingInternal

func IsTracingInternal() bool

IsTracingInternal 返回是否正在追踪内部组件的跨度。 md5:4439b167674c69e6

func IsUsingDefaultProvider

func IsUsingDefaultProvider() bool

IsUsingDefaultProvider 检查并返回当前是否正在使用默认的跟踪提供程序。 md5:dd9a8bbd104a14cf

func MaxContentLogSize

func MaxContentLogSize() int

MaxContentLogSize 返回请求和响应体的最大日志大小,特别是对于HTTP/RPC请求。 md5:762f425039c664ca

func SafeContent

func SafeContent(data []byte) string

SafeContent 通过 `MaxContentLogSize` 剪切并返回给定的内容。如果内容大小超过 `MaxContentLogSize`,则在结果的尾部添加字符串 `...`。 md5:7ea5429876707ef6

func SafeContentForHttp

func SafeContentForHttp(data []byte, header http.Header) (string, error)

SafeContentForHttp 通过 `MaxContentLogSize` 剪切并返回给定内容。如果内容大小超过 `MaxContentLogSize`,它会在结果尾部添加字符串 `...`。 md5:ba3a657223c70042

func SetBaggageMap

func SetBaggageMap(ctx context.Context, data map[string]interface{}) context.Context

SetBaggageMap 是一个方便的函数,用于向行李中添加映射的键值对。 请注意,它使用 attribute.Any 来设置键值对。 md5:635cc7b15635106d

func SetBaggageValue

func SetBaggageValue(ctx context.Context, key string, value interface{}) context.Context

SetBaggageValue 是一个便捷函数,用于向 baggage 中添加一个键值对。 注意,它使用 attribute.Any 来设置键值对。 md5:a0a5e77a036e4b8b

func WithTraceID

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

WithTraceID 将自定义的跟踪ID注入上下文以进行传播。 md5:74657c53cd9aeefb

func WithUUID

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

WithUUID 向上下文注入自定义的基于UUID的追踪ID以进行传播。 md5:b75be6e561eacb0c

Types

type Baggage

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

Baggage在所有跟踪span中持有数据。 md5:0ad27152ec042f81

func NewBaggage

func NewBaggage(ctx context.Context) *Baggage

NewBaggage 从给定的追踪上下文中创建并返回一个新的Baggage对象。 md5:6c3e8093bd06a60a

func (*Baggage) Ctx

func (b *Baggage) Ctx() context.Context

Ctx 返回Baggage持有的上下文。 md5:37268f528c617799

func (*Baggage) GetMap

func (b *Baggage) GetMap() *gmap.StrAnyMap

GetMap 获取并以映射形式返回baggage值。 md5:d6024d765655a29e

func (*Baggage) GetVar

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

GetVar 从行李中获取指定键的值,并返回一个 *gvar.Var。 md5:6cda7fcfb8ff1c6e

func (*Baggage) SetMap

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

SetMap 是一个方便的函数,用于将映射键值对添加到行李中。 注意,它使用 attribute.Any 设置键值对。 md5:a18951801562457c

func (*Baggage) SetValue

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

SetValue 是一个方便的函数,用于向 baggage 中添加一个键值对。 注意,它使用 attribute.Any 设置键值对。 md5:830faae9a81721ce

type Carrier

type Carrier map[string]interface{}

Carrier是TextMapPropagator使用的存储介质。 md5:8d62ccc64614a0c7

func NewCarrier

func NewCarrier(data ...map[string]interface{}) Carrier

NewCarrier 创建并返回一个 Carrier。 md5:e8b512c41d0c9bd7

func (Carrier) Get

func (c Carrier) Get(k string) string

Get 返回与传入键关联的值。 md5:d20be4af58bc2fa7

func (Carrier) Keys

func (c Carrier) Keys() []string

Keys 列出了存储在该载体中的键。 md5:8dca78c8668c962f

func (Carrier) MustMarshal

func (c Carrier) MustMarshal() []byte

MustMarshal 返回c的JSON编码. md5:58f2f2d8e0370a56

func (Carrier) Set

func (c Carrier) Set(k, v string)

Set 存储键值对。 md5:797de4e363035487

func (Carrier) String

func (c Carrier) String() string

String 将当前Carrier转换并以字符串形式返回。 md5:9a30611e4d817539

func (Carrier) UnmarshalJSON

func (c Carrier) UnmarshalJSON(b []byte) error

UnmarshalJSON 实现了 json 包中的 UnmarshalJSON 接口。 md5:6a50aca077e136ff

type Span

type Span struct {
	trace.Span
}

Span 是为了兼容性和扩展性而包装 trace.Span。 md5:4d80699ca0a21c89

func NewSpan

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

NewSpan 使用默认追踪器创建一个span。 md5:0b09fd499d941eba

type Tracer

type Tracer struct {
	trace.Tracer
}

Tracer 为了兼容性和扩展性对 trace.Tracer 进行了封装。 md5:0b2682d6e466cbd6

func NewTracer

func NewTracer(name ...string) *Tracer

NewTracer 是一个简短的函数,用于获取Tracer。 md5:188ccb7ad71b192b

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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