tracers

package
v5.1.14 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 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() (processor process.Processor)

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

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

Executor 链路执行器.

type Formatter

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

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

Formatter 格式化.

type OperatorManager

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

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

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

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

	// SetExecutor
	// 设置执行器.
	SetExecutor(executor 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 链路跨度.

func NewSpan added in v5.1.12

func NewSpan(name string) Span

NewSpan 返回 tracers.Span 组件. 此过程先创建 tracers.Trace 组件, 然后基于此组 件创建 tracers.Span 组件并返回.

func NewSpanFromContext added in v5.1.14

func NewSpanFromContext(ctx context.Context, name string) Span

NewSpanFromContext 返回 tracers.Span 组件. 若 context.Context 绑定过 tracers.Span 组件则基于此创建子 tracers.Span 并返回, 若绑定过 tracers.Trace 则基于此创建新的 tracers.Span 并返回, 反之则使用和 NewSpan 相同逻辑.

func NewSpanFromRequest added in v5.1.14

func NewSpanFromRequest(req *http.Request, name string) Span

NewSpanFromRequest 返回 tracers.Span 组件. 基于 HTTP 请求创建并返回, 创建 过程同 NewSpan 逻辑, 不同点在于此过程打通服务间链路.

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 跨度组件.

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