trace

package
v0.0.0-...-60c55df Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 19 Imported by: 1

README

链路追踪

endpoint: "jaeger-collector.example.com"
useSsl: true
header:
  Authorization: "Basic ----"
sample: 0.001

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithSpan

func ContextWithSpan(parent context.Context, span trace.Span) context.Context

ContextWithSpan 将span存入context

func ContextWithTracer

func ContextWithTracer(ctx context.Context, tracer trace.Tracer) context.Context

func Default

func Default() trace.TracerProvider

Default 获取默认链路追踪组件 获取到后,其它组件可以判断是否存在,再进行使用

func LoggerLabel

func LoggerLabel(ctx context.Context) []zap.Field

LoggerLabel 从context中获取span信息,然后再取出信息返回[]zap.Field

func Middleware

func Middleware(serviceName string, tracerProvider trace.TracerProvider) gin.HandlerFunc

Middleware 链路追踪中间件

func NewWithConfig

func NewWithConfig(ctx context.Context, cfg *Config, opts ...Option) (trace.TracerProvider, error)

func SpanFromContext

func SpanFromContext(ctx context.Context) trace.Span

SpanFromContext 从context中获取span

func StartSpan

func StartSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)

func Trace

func Trace(ctx context.Context, config *configs.Config) error

Trace 链路追踪组件,尽早注册,其他组件会判断是否存在,再进行使用

func TracerFromContext

func TracerFromContext(ctx context.Context) trace.Tracer

Types

type Config

type Config struct {
	// Sample 采样率 0-1 其它数字为跟随父配置
	Sample   float64           `yaml:"sample"`
	Endpoint string            `yaml:"endpoint"`
	UseSSL   bool              `yaml:"useSSL"`
	Type     string            `yaml:"type"`
	Header   map[string]string `yaml:"header"`
}

type Option

type Option func(*Options)

func AppendAttributes

func AppendAttributes(attrs ...attribute.KeyValue) Option

type Options

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

Jump to

Keyboard shortcuts

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