tracing

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddEvent

func AddEvent(span trace.Span, name string, attrs ...attribute.KeyValue)

AddEvent 添加事件到 span

func ContextWithSpan

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

ContextWithSpan 创建带 span 的 context

func DatabaseSpan

func DatabaseSpan(ctx context.Context, operation, table string) (context.Context, trace.Span)

DatabaseSpan 数据库操作追踪

func GRPCSpan

func GRPCSpan(ctx context.Context, service, method string) (context.Context, trace.Span)

GRPCSpan gRPC 调用追踪

func HTTPClientSpan

func HTTPClientSpan(ctx context.Context, method, url string) (context.Context, trace.Span)

HTTPClientSpan HTTP 客户端请求追踪

func RecordError

func RecordError(span trace.Span, err error)

RecordError 记录错误到 span

func RedisSpan

func RedisSpan(ctx context.Context, command string) (context.Context, trace.Span)

RedisSpan Redis 操作追踪

func SetAttributes

func SetAttributes(span trace.Span, attrs ...attribute.KeyValue)

SetAttributes 设置属性到 span

func SetStatus

func SetStatus(span trace.Span, code codes.Code, description string)

SetStatus 设置 span 状态

func SpanFromContext

func SpanFromContext(ctx context.Context) trace.Span

SpanFromContext 从 context 获取 span

func SpanID

func SpanID(ctx context.Context) string

SpanID 获取 span ID

func StartSpan

func StartSpan(ctx context.Context, spanName string) (context.Context, trace.Span)

Span 辅助函数

func TraceID

func TraceID(ctx context.Context) string

TraceID 获取 trace ID

Types

type Config

type Config struct {
	ServiceName    string
	ServiceVersion string
	Environment    string
	JaegerEndpoint string
	SamplingRate   float64
}

Config 追踪配置

type Middleware

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

Middleware 追踪中间件

func NewMiddleware

func NewMiddleware(tracer trace.Tracer) *Middleware

NewMiddleware 创建追踪中间件

func (*Middleware) Handler

func (m *Middleware) Handler(next http.HandlerFunc) http.HandlerFunc

Handler HTTP 追踪中间件处理器

type Provider

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

Provider 追踪提供者

func NewProvider

func NewProvider(config Config) (*Provider, error)

NewProvider 创建追踪提供者

func (*Provider) Shutdown

func (p *Provider) Shutdown(ctx context.Context) error

Shutdown 关闭追踪提供者

func (*Provider) Start

func (p *Provider) Start(ctx context.Context, spanName string, opts ...trace.SpanStartOption) (context.Context, trace.Span)

Start 开始一个 span

func (*Provider) Tracer

func (p *Provider) Tracer() trace.Tracer

Tracer 获取 tracer

Jump to

Keyboard shortcuts

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