Documentation
¶
Overview ¶
Package otlptest runs an in-process OTLP collector (HTTP or gRPC) for tests that export through the daemon's real telemetry runtime: the providers telemetry.Init installs, the sanitizing exporters, and the OTLP exporters.
Index ¶
- Constants
- type Collector
- func (c *Collector) Export(t testing.TB, sampleRatio float64, reg telemetry.Registries)
- func (c *Collector) ExportWithMetrics(t testing.TB, sampleRatio float64, reg telemetry.Registries)
- func (c *Collector) Flush(t testing.TB) []Span
- func (c *Collector) FlushMetrics(t testing.TB) map[string]Metric
- func (c *Collector) Metrics() map[string]Metric
- func (c *Collector) Payloads(path string) [][]byte
- func (c *Collector) Spans() []Span
- type Event
- type Metric
- type MetricType
- type Point
- type Span
Constants ¶
const ( TracesPath = "/v1/traces" MetricsPath = "/v1/metrics" )
Signal request paths of the OTLP/HTTP protocol; Payloads also files gRPC requests under them.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collector ¶
type Collector struct {
URL string
// contains filtered or unexported fields
}
Collector is an OTLP collector that keeps every request body and span it receives and the latest export of each metric.
func NewCollector ¶
NewCollector starts a collector that stops at test cleanup.
func NewGRPCCollector ¶
NewGRPCCollector starts an OTLP/gRPC collector that stops at test cleanup. Payloads holds each request's raw message bytes as they arrived on the wire, before decoding.
func (*Collector) Export ¶
Export starts the daemon telemetry runtime against the collector with the global OTel providers, the way the daemon boots it, and restores disabled export at cleanup. It installs process globals: callers must not run in parallel.
func (*Collector) ExportWithMetrics ¶
ExportWithMetrics is Export with metric export on; FlushMetrics collects on demand.
func (*Collector) Flush ¶
Flush exports every span ended so far through the installed provider and returns everything received.
func (*Collector) FlushMetrics ¶
FlushMetrics collects and exports every metric through the installed meter provider and returns everything received.
func (*Collector) Metrics ¶
Metrics returns the latest export of every metric received so far, by name.
type Metric ¶
type Metric struct {
Name string
Unit string
Scope string
Type MetricType
Monotonic bool
Points []Point
}
Metric is one metric of the latest export that carried it; cumulative temporality makes it the running total.
type MetricType ¶
type MetricType string
MetricType is the OTLP data type of an exported metric.
const ( MetricSum MetricType = "sum" MetricGauge MetricType = "gauge" MetricHistogram MetricType = "histogram" MetricOther MetricType = "other" )
Exported metric data types.
type Point ¶
type Point struct {
Attributes map[string]any
Value float64
Count uint64
Sum float64
Bounds []float64
Exemplars int
}
Point is one exported series. Value is the sum or gauge value; histograms set Count and Sum, plus Bounds and Exemplars to check the exported shape.
type Span ¶
type Span struct {
Name string
Scope string
Kind tracepb.Span_SpanKind
TraceID trace.TraceID
SpanID trace.SpanID
ParentSpanID trace.SpanID
Start time.Time
End time.Time
// Attributes holds string, int64, bool, and float64 values by key.
Attributes map[string]any
Events []Event
Links []trace.SpanContext
StatusCode tracepb.Status_StatusCode
StatusMessage string
}
Span is one exported span as the collector decoded it.