gtrace

package
v0.0.0-...-2910145 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

gtrace包提供了一种便利的封装功能,用于使用OpenTelemetry进行跟踪特性。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckSetDefaultTextMapPropagator

func CheckSetDefaultTextMapPropagator()

CheckSetDefaultTextMapPropagator 检查并设置默认的 TextMapPropagator。如果此前未设置,则进行设置。

func CommonLabels

func CommonLabels() []attribute.KeyValue

CommonLabels 返回常用属性标签: ip.intranet(内网IP),hostname(主机名)

func GetBaggageMap

func GetBaggageMap(ctx context.Context) *map类.StrAnyMap

GetBaggageMap 获取并以map形式返回 baggage 的值。

func GetBaggageVar

func GetBaggageVar(ctx context.Context, key string) *泛型类.Var

GetBaggageVar 从 baggage 中按照指定键检索值,并返回一个 *gvar.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 IsTracingInternal

func IsTracingInternal() bool

IsTracingInternal 返回是否追踪内部组件的跟踪跨度。

func IsUsingDefaultProvider

func IsUsingDefaultProvider() bool

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

func MaxContentLogSize

func MaxContentLogSize() int

MaxContentLogSize 返回请求和响应正文的最大日志大小,特别是针对HTTP/RPC请求。

func SetBaggageMap

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

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

func SetBaggageValue

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

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

func WithTraceID

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

WithTraceID 向上下文中注入自定义跟踪 ID,以便进行传播。

func WithUUID

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

WithUUID 向上下文中注入自定义的 UUID 格式的跟踪 ID,以便进行传播。

Types

type Baggage

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

Baggage 在所有追踪跨度中保存数据。

func NewBaggage

func NewBaggage(ctx context.Context) *Baggage

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

func (*Baggage) Ctx

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

Ctx 返回 Baggage 持有的上下文。

func (*Baggage) GetMap

func (b *Baggage) GetMap() *map类.StrAnyMap

GetMap 获取并以map形式返回 baggage 的值。

func (*Baggage) GetVar

func (b *Baggage) GetVar(key string) *泛型类.Var

GetVar 从 baggage 中根据指定的键获取值,并返回一个指向该值的*gvar.Var指针。

func (*Baggage) SetMap

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

SetMap 是一个方便的函数,用于向 baggage 添加映射键值对。 注意,它使用 attribute.Any 来设置键值对。

func (*Baggage) SetValue

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

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

type Carrier

type Carrier map[string]interface{}

2024-01-14 备注,此文件方法不要翻译, gtrace_z_unit_carrier_test.go, "otel.GetTextMapPropagator().Inject(ctx, carrier1)" carrier1参数要求TextMapCarrier类型结构体.

Carrier 是 TextMapPropagator 使用的存储介质。

func NewCarrier

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

NewCarrier 创建并返回一个 Carrier。

func (Carrier) Get

func (c Carrier) Get(k string) string

2024-01-14 备注,此文件方法不要翻译, gtrace_z_unit_carrier_test.go, "otel.GetTextMapPropagator().Inject(ctx, carrier1)" carrier1参数要求TextMapCarrier类型结构体.

Get 方法用于获取与传递的键关联的值。

func (Carrier) Keys

func (c Carrier) Keys() []string

Keys 列出存储在此 carrier 中的所有键。

func (Carrier) MustMarshal

func (c Carrier) MustMarshal() []byte

MustMarshal .必须返回c的JSON编码

func (Carrier) Set

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

2024-01-14 备注,此文件方法不要翻译, gtrace_z_unit_carrier_test.go, "otel.GetTextMapPropagator().Inject(ctx, carrier1)" carrier1参数要求TextMapCarrier类型结构体.

Set 存储键值对。

func (Carrier) String

func (c Carrier) String() string

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

func (Carrier) UnmarshalJSON

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

UnmarshalJSON 实现了 json 包中的 UnmarshalJSON 接口。

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 使用默认的追踪器创建一个跨度。

type Tracer

type Tracer struct {
	trace.Tracer
}

Tracer 为兼容性和扩展性而封装了 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