processor

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBatchSpanProcessor

func NewBatchSpanProcessor(exporter trace.SpanExporter, opts ...BatchSpanProcessorOption) (trace.SpanProcessor, error)

NewBatchSpanProcessor 创建批处理器并返回初始化错误。 fallback 目录不可用时不会启动后台协程。

func NewMultiSpanProcessor

func NewMultiSpanProcessor(processors ...trace.SpanProcessor) trace.SpanProcessor

NewMultiSpanProcessor 创建一个新的MultiSpanProcessor

func NewSimpleSpanProcessor

func NewSimpleSpanProcessor(exporter trace.SpanExporter) trace.SpanProcessor

NewSimpleSpanProcessor 创建一个新的SimpleSpanProcessor

func NewWALSpanProcessor

func NewWALSpanProcessor(exporter trace.SyncSpanExporter, opts ...WALSpanProcessorOption) (trace.SpanProcessor, error)

NewWALSpanProcessor 创建 WAL 处理器。 初始化失败时直接返回错误,不启动任何后台协程。

Types

type BatchSpanProcessor

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

BatchSpanProcessor 批量处理和导出 Span。

当前设计里,BatchSpanProcessor 是唯一的异步调度层:

  • OnEnd 只负责快速入队
  • 单个聚合循环负责 batch 聚合与 flush 时机
  • 导出并发由 processor 自己控制
  • fallback 和 snapshot 释放统一由 processor 负责

func (*BatchSpanProcessor) GetLastError

func (b *BatchSpanProcessor) GetLastError() error

GetLastError 返回批处理器最近一次错误。

func (*BatchSpanProcessor) GetMaxQueueSize

func (b *BatchSpanProcessor) GetMaxQueueSize() int

GetMaxQueueSize 获取队列最大容量

func (*BatchSpanProcessor) GetQueueLength

func (b *BatchSpanProcessor) GetQueueLength() int

GetQueueLength 获取当前队列长度

func (*BatchSpanProcessor) GetStats

func (b *BatchSpanProcessor) GetStats() map[string]int64

GetStats 返回批处理器接收、导出、fallback 和错误统计。

func (*BatchSpanProcessor) OnEnd

func (b *BatchSpanProcessor) OnEnd(span trace.SpanSnapshot)

OnEnd 在结束时调用处理器

func (*BatchSpanProcessor) OnStart

func (b *BatchSpanProcessor) OnStart(ctx context.Context, span trace.Span)

OnStart 在开始时调用处理器

func (*BatchSpanProcessor) Shutdown

func (b *BatchSpanProcessor) Shutdown(ctx context.Context) error

Shutdown 关闭处理器

type BatchSpanProcessorOption

type BatchSpanProcessorOption func(*BatchSpanProcessor)

BatchSpanProcessorOption 配置批处理器的选项

func WithBatchSize

func WithBatchSize(batchSize int) BatchSpanProcessorOption

WithBatchSize 设置批次大小

func WithFallbackDir

func WithFallbackDir(dir string) BatchSpanProcessorOption

WithFallbackDir 设置回退目录

func WithFlushInterval

func WithFlushInterval(interval time.Duration) BatchSpanProcessorOption

WithFlushInterval 设置刷新间隔

func WithQueueHighWaterMark

func WithQueueHighWaterMark(highWaterMark int) BatchSpanProcessorOption

WithQueueHighWaterMark 设置队列高水位线

func WithQueueSize

func WithQueueSize(size int) BatchSpanProcessorOption

WithQueueSize 设置队列大小

func WithWorkers

func WithWorkers(workers int) BatchSpanProcessorOption

WithWorkers 设置导出并发数

type MultiSpanProcessor

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

MultiSpanProcessor 是一个多Span处理器实现

func (*MultiSpanProcessor) AddProcessor

func (p *MultiSpanProcessor) AddProcessor(processor trace.SpanProcessor)

AddProcessor 添加处理器 @param proc 处理器

func (*MultiSpanProcessor) OnEnd

func (p *MultiSpanProcessor) OnEnd(span trace.SpanSnapshot)

OnEnd 实现trace.SpanProcessor接口 主要用于在Span结束时执行,可以用于记录Span的结束时间、设置Span的标签、属性等 @param span Span快照

func (*MultiSpanProcessor) OnStart

func (p *MultiSpanProcessor) OnStart(ctx context.Context, span trace.Span)

OnStart 实现trace.SpanProcessor接口 主要用于在Span开始时执行,可以用于记录Span的开始时间、设置Span的标签、属性等 @param ctx 上下文 @param span Span实例

func (*MultiSpanProcessor) Shutdown

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

Shutdown 实现trace.SpanProcessor接口 主要用于在追踪器关闭时执行,可以用于关闭Span处理器、关闭资源等 @param ctx 上下文 @return error 错误,如果关闭失败,则返回错误

type NoopSpanProcessor

type NoopSpanProcessor struct{}

NoopSpanProcessor 是一个空Span处理器实现

func (*NoopSpanProcessor) OnEnd

func (n *NoopSpanProcessor) OnEnd(span trace.SpanSnapshot)

OnEnd 释放不需要继续处理的 Span 快照。 @param span Span实例

func (*NoopSpanProcessor) OnStart

func (n *NoopSpanProcessor) OnStart(ctx context.Context, span trace.Span)

OnStart 实现trace.SpanProcessor接口 主要用于在Span开始时执行,可以用于记录Span的开始时间、设置Span的标签、属性等 @param ctx 上下文 @param span Span实例

func (*NoopSpanProcessor) Shutdown

func (n *NoopSpanProcessor) Shutdown(ctx context.Context) error

Shutdown 实现trace.SpanProcessor接口 主要用于在追踪器关闭时执行,可以用于关闭Span处理器、关闭资源等 @param ctx 上下文 @return error 错误,如果关闭失败,则返回错误

type SimpleSpanProcessor

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

SimpleSpanProcessor 是一个简单的Span处理器实现

func (*SimpleSpanProcessor) OnEnd

func (p *SimpleSpanProcessor) OnEnd(span trace.SpanSnapshot)

OnEnd 实现trace.SpanProcessor接口 主要用于在Span结束时执行,可以用于记录Span的结束时间、设置Span的标签、属性等 @param span Span实例

func (*SimpleSpanProcessor) OnStart

func (p *SimpleSpanProcessor) OnStart(ctx context.Context, span trace.Span)

OnStart 实现trace.SpanProcessor接口 主要用于在Span开始时执行,可以用于记录Span的开始时间、设置Span的标签、属性等 @param ctx 上下文 @param span Span实例

func (*SimpleSpanProcessor) Shutdown

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

Shutdown 实现trace.SpanProcessor接口 主要用于在追踪器关闭时执行,可以用于关闭Span处理器、关闭资源等 @param ctx 上下文 @return error 错误,如果关闭失败,则返回错误

type WALSpanProcessor

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

WALSpanProcessor 将 span 先写入本地 WAL,再由后台协程同步投递到远端 exporter。 这让请求主路径只依赖本地顺序写,远端失败时也能通过 WAL 重放恢复。

func (*WALSpanProcessor) GetLastError

func (p *WALSpanProcessor) GetLastError() error

GetLastError 返回 WAL 处理器最近一次错误。

func (*WALSpanProcessor) GetStats

func (p *WALSpanProcessor) GetStats() map[string]int64

GetStats 返回 WAL 接收、落盘、直连兜底、丢弃和错误统计。

func (*WALSpanProcessor) OnEnd

func (p *WALSpanProcessor) OnEnd(span trace.SpanSnapshot)

OnEnd 将 span 先落到本地 WAL,随后异步投递。

func (*WALSpanProcessor) OnStart

func (p *WALSpanProcessor) OnStart(ctx context.Context, span trace.Span)

OnStart 在 span 开始时不做额外处理。

func (*WALSpanProcessor) Shutdown

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

Shutdown 停止接收新 span,并尽力把已经写入 WAL 的数据全部投递完成。

type WALSpanProcessorOption

type WALSpanProcessorOption func(*WALSpanProcessor)

WALSpanProcessorOption WAL 处理器配置选项。

func WithWALBufferSize

func WithWALBufferSize(size int) WALSpanProcessorOption

WithWALBufferSize 设置 WAL 缓冲写入大小。

func WithWALDir

func WithWALDir(dir string) WALSpanProcessorOption

WithWALDir 设置 WAL 目录。

func WithWALExportBatchSize

func WithWALExportBatchSize(size int) WALSpanProcessorOption

WithWALExportBatchSize 设置后台批量投递大小。

func WithWALFlushInterval

func WithWALFlushInterval(interval time.Duration) WALSpanProcessorOption

WithWALFlushInterval 设置 WAL 用户态缓冲的刷新间隔。 较小的间隔会降低日志停留在用户态缓冲区的时间,较大的间隔则更偏向吞吐。

func WithWALPollInterval

func WithWALPollInterval(interval time.Duration) WALSpanProcessorOption

WithWALPollInterval 设置后台扫描 WAL 的轮询间隔。

func WithWALSegmentSize

func WithWALSegmentSize(size int64) WALSpanProcessorOption

WithWALSegmentSize 设置单个 segment 的最大大小。

func WithWALSyncOnWrite

func WithWALSyncOnWrite(syncOnWrite bool) WALSpanProcessorOption

WithWALSyncOnWrite 设置是否每条写入后立即 fsync。 默认关闭以获得更高吞吐;开启后更偏向强一致,但会增加请求延迟。

Jump to

Keyboard shortcuts

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