Documentation
¶
Overview ¶
Package telemetrytest 提供写入内存的遥测管道,供各包测试断言 span、指标与日志;与 net/http/httptest 同类。
Index ¶
- func GetSpanAttribute(span sdktrace.ReadOnlySpan, key string) string
- func GetSpanValue(span sdktrace.ReadOnlySpan, key string) (attribute.Value, bool)
- type Pipeline
- func (p *Pipeline) GetEndedSpans() []sdktrace.ReadOnlySpan
- func (p *Pipeline) GetHistogramBounds(t testing.TB, name string) []float64
- func (p *Pipeline) GetHistogramCount(t testing.TB, name string, attrs ...attribute.KeyValue) uint64
- func (p *Pipeline) GetLogRecords(t testing.TB, msg string) []map[string]any
- func (p *Pipeline) GetLogText() string
- func (p *Pipeline) GetMetricAttributeKeys(t testing.TB, name string) []string
- func (p *Pipeline) GetMetricSum(t testing.TB, name string, attrs ...attribute.KeyValue) float64
- func (p *Pipeline) WaitEndedSpans(t testing.TB, name string, count int) []sdktrace.ReadOnlySpan
- func (p *Pipeline) WaitLogRecords(t testing.TB, msg string, count int) []map[string]any
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSpanAttribute ¶
func GetSpanAttribute(span sdktrace.ReadOnlySpan, key string) string
GetSpanAttribute 读取 span 属性的文本形式。
func GetSpanValue ¶
GetSpanValue 读取 span 属性的原始值及存在标记。
Types ¶
type Pipeline ¶
type Pipeline struct {
Telemetry *telemetry.Telemetry
// TracerProvider 供测试自己开 span,例如模拟提交输入的请求。
TracerProvider *sdktrace.TracerProvider
// contains filtered or unexported fields
}
Pipeline 是写入内存的遥测管道:span 结束时记录,指标在断言时收集,日志以 Debug 级别的 JSON 行写入内存。
func NewPipelineWithoutContent ¶
NewPipelineWithoutContent 创建关闭内容采集的内存遥测管道。
func (*Pipeline) GetEndedSpans ¶
func (p *Pipeline) GetEndedSpans() []sdktrace.ReadOnlySpan
GetEndedSpans 按结束顺序返回已结束的 span。
func (*Pipeline) GetHistogramBounds ¶
GetHistogramBounds 读取指定直方图的分桶。
func (*Pipeline) GetHistogramCount ¶
GetHistogramCount 汇总指定直方图的记录次数。
func (*Pipeline) GetLogRecords ¶
GetLogRecords 解析内存日志并筛选消息。
func (*Pipeline) GetMetricAttributeKeys ¶
GetMetricAttributeKeys 收集指定指标的全部属性键。
func (*Pipeline) GetMetricSum ¶
GetMetricSum 收集并汇总指定指标的数据点。
func (*Pipeline) WaitEndedSpans ¶
WaitEndedSpans 等待指定名称的结束 span 达到要求数量。
Click to show internal directories.
Click to hide internal directories.