Documentation
¶
Index ¶
- func NewBatchSpanProcessor(exporter trace.SpanExporter, opts ...BatchSpanProcessorOption) (trace.SpanProcessor, error)
- func NewMultiSpanProcessor(processors ...trace.SpanProcessor) trace.SpanProcessor
- func NewSimpleSpanProcessor(exporter trace.SpanExporter) trace.SpanProcessor
- func NewWALSpanProcessor(exporter trace.SyncSpanExporter, opts ...WALSpanProcessorOption) (trace.SpanProcessor, error)
- type BatchSpanProcessor
- func (b *BatchSpanProcessor) GetLastError() error
- func (b *BatchSpanProcessor) GetMaxQueueSize() int
- func (b *BatchSpanProcessor) GetQueueLength() int
- func (b *BatchSpanProcessor) GetStats() map[string]int64
- func (b *BatchSpanProcessor) OnEnd(span trace.SpanSnapshot)
- func (b *BatchSpanProcessor) OnStart(ctx context.Context, span trace.Span)
- func (b *BatchSpanProcessor) Shutdown(ctx context.Context) error
- type BatchSpanProcessorOption
- func WithBatchSize(batchSize int) BatchSpanProcessorOption
- func WithFallbackDir(dir string) BatchSpanProcessorOption
- func WithFlushInterval(interval time.Duration) BatchSpanProcessorOption
- func WithQueueHighWaterMark(highWaterMark int) BatchSpanProcessorOption
- func WithQueueSize(size int) BatchSpanProcessorOption
- func WithWorkers(workers int) BatchSpanProcessorOption
- type MultiSpanProcessor
- type NoopSpanProcessor
- type SimpleSpanProcessor
- type WALSpanProcessor
- type WALSpanProcessorOption
- func WithWALBufferSize(size int) WALSpanProcessorOption
- func WithWALDir(dir string) WALSpanProcessorOption
- func WithWALExportBatchSize(size int) WALSpanProcessorOption
- func WithWALFlushInterval(interval time.Duration) WALSpanProcessorOption
- func WithWALPollInterval(interval time.Duration) WALSpanProcessorOption
- func WithWALSegmentSize(size int64) WALSpanProcessorOption
- func WithWALSyncOnWrite(syncOnWrite bool) WALSpanProcessorOption
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 在结束时调用处理器
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 设置队列高水位线
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快照
type NoopSpanProcessor ¶
type NoopSpanProcessor struct{}
NoopSpanProcessor 是一个空Span处理器实现
func (*NoopSpanProcessor) OnEnd ¶
func (n *NoopSpanProcessor) OnEnd(span trace.SpanSnapshot)
OnEnd 释放不需要继续处理的 Span 快照。 @param span Span实例
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实例
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,随后异步投递。
type WALSpanProcessorOption ¶
type WALSpanProcessorOption func(*WALSpanProcessor)
WALSpanProcessorOption WAL 处理器配置选项。
func WithWALBufferSize ¶
func WithWALBufferSize(size int) WALSpanProcessorOption
WithWALBufferSize 设置 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。 默认关闭以获得更高吞吐;开启后更偏向强一致,但会增加请求延迟。