tracing

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Client

func Client(opts ...Option) middleware.Middleware

Client 返回一个客户端跟踪中间件

func Server

func Server(opts ...Option) middleware.Middleware

Server 返回一个服务端跟踪中间件

Types

type Option

type Option func(*options)

Option 是跟踪中间件的选项

func WithTracer

func WithTracer(tracer Tracer) Option

WithTracer 设置跟踪器

type Span

type Span interface {
	// End 结束Span
	End()
	// SetTag 设置Span标签
	SetTag(key string, value interface{})
	// SetError 设置Span错误
	SetError(err error)
	// SetStatus 设置状态
	SetStatus(code StatusCode, description string)
}

Span 是跟踪Span接口

type StatusCode added in v0.1.0

type StatusCode int

StatusCode 表示追踪状态码

const (
	// StatusOk 表示操作成功
	StatusOk StatusCode = 0
	// StatusError 表示操作失败
	StatusError StatusCode = 1
)

type Tracer

type Tracer interface {
	// Start 开始一个新的跟踪Span
	Start(ctx context.Context, operation string) (context.Context, Span)
}

Tracer 是跟踪器接口

Jump to

Keyboard shortcuts

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