tracers

package
v5.1.9 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContextKey = "__LOG_TRACE_CONTEXT_KEY__"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

type Executor interface {
	// Processor
	// 类进程.
	//
	// 获取具体执行器的类进程, 基于此类进程启动/退出服务.
	Processor() process.Processor

	// Publish
	// 发布链路.
	Publish(spans ...Span) error

	// SetFormatter
	// 设置格式.
	SetFormatter(formatter Formatter)
}

Executor 链路执行器.

type Formatter

type Formatter interface {
	// Byte
	// 转字符码.
	Byte(vs ...Span) (body []byte, err error)

	// String
	// 转字符串.
	String(vs ...Span) (string, error)
}

Formatter 格式化.

type OperatorManager

type OperatorManager interface {
	// Generator
	// ID生成器.
	Generator() *id

	// GetExecutor
	// 执行器.
	GetExecutor() Executor

	// GetResource
	// 基础资源.
	GetResource() loggers.Kv

	// Push
	// 推送跨度.
	Push(span Span)

	// SetExecutor
	// 设置执行器.
	SetExecutor(v Executor)
}

OperatorManager 链路操作接口.

var (
	// Operator
	// 链路操作.
	Operator OperatorManager
)

type Span

type Span interface {
	ApplyRequest(req *http.Request)
	Child(name string) Span
	Context() context.Context
	Duration() time.Duration
	End()
	Kv() loggers.Kv
	Logger() SpanLogger
	Logs() []loggers.Log
	Name() string
	ParentSpanId() SpanId
	SpanId() SpanId
	StartTime() time.Time
	Trace() Trace
}

Span 链路跨度.

type SpanId

type SpanId [8]byte

SpanId 跨度ID.

func (SpanId) IsValid

func (o SpanId) IsValid() bool

IsValid 校验跨度ID.

func (SpanId) String

func (o SpanId) String() string

String 转成16进制字符串.

type SpanLogger

type SpanLogger interface {
	// Add
	// 添加 Key/Value 键值对.
	Add(key string, value interface{}) SpanLogger

	Debug(text string, args ...interface{})
	Error(text string, args ...interface{})
	Fatal(text string, args ...interface{})
	Info(text string, args ...interface{})
	Warn(text string, args ...interface{})
}

SpanLogger 跨度日志.

type Trace

type Trace interface {
	// Context
	// 上下文.
	Context() context.Context

	// Kv
	// 链路Key/Value属性.
	Kv() loggers.Kv

	// Name
	// 链路名.
	Name() string

	// New
	// 创建跨度.
	//
	// 基于 Trace 生成新的链路跨度 Span.
	New(name string) Span

	// SpanId
	// 跨度ID.
	SpanId() SpanId

	// TraceId
	// 链路ID.
	TraceId() TraceId
}

Trace 跨度组件.

func NewTrace

func NewTrace(name string) Trace

NewTrace 链路跟踪.

func NewTraceFromContext

func NewTraceFromContext(ctx context.Context, name string) Trace

NewTraceFromContext 链路跟踪.

func NewTraceFromRequest

func NewTraceFromRequest(req *http.Request, name string) Trace

NewTraceFromRequest 链路跟踪.

type TraceId

type TraceId [16]byte

TraceId 链路ID.

func (TraceId) IsValid

func (o TraceId) IsValid() bool

IsValid 校验链路ID.

func (TraceId) String

func (o TraceId) String() string

String 转成16进制字符串.

Directories

Path Synopsis
Package tracer_file 输出到文件中, 例如: /var/logs/2023-03/2023-03-01.trace.
Package tracer_file 输出到文件中, 例如: /var/logs/2023-03/2023-03-01.trace.
Package tracer_jaeger 上报到Jaeger.
Package tracer_jaeger 上报到Jaeger.
Package tracer_term 打印到终端/控制台.
Package tracer_term 打印到终端/控制台.
Package tracer_zipkin 上报到Zipkin.
Package tracer_zipkin 上报到Zipkin.
model
Package model contains the Zipkin V2 model which is used by the Zipkin Go tracer implementation.
Package model contains the Zipkin V2 model which is used by the Zipkin Go tracer implementation.

Jump to

Keyboard shortcuts

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