trace

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MIT Imports: 15 Imported by: 0

README

链路追踪

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

func Default

func Default() trace.TracerProvider

func LoggerLabel

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

LoggerLabel 获取logger的traceID

func Middleware

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

Middleware 链路追踪中间件

func New

func New(opt ...Option) (trace.TracerProvider, error)

func NewWithConfig

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

func RegisterExporter

func RegisterExporter(name string, f NewExporterFunc)

func SpanFromContext

func SpanFromContext(ctx 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 {
	Endpoint string
	Type     ExporterType
	Username string
	Password string
	Dsn      string
	// Sample 采样率 0-1 其它数字为跟随父配置
	Sample float64
}

type ExporterType

type ExporterType string
const (
	Jaeger  ExporterType = "jaeger"
	UpTrace ExporterType = "uptrace"
)

type NewExporterFunc

type NewExporterFunc func(ctx context.Context, config *Config) (tracesdk.SpanExporter, error)

type Option

type Option func(*Options)

func AppendAttributes

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

func Sample

func Sample(sample float64) Option

func WithExporter

func WithExporter(exp tracesdk.SpanExporter) Option

type Options

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

Directories

Path Synopsis
exporter

Jump to

Keyboard shortcuts

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