Documentation
¶
Overview ¶
Package testotel provides test utilities for OpenTelemetry tests.
Index ¶
- func GetAttributeString(attrs []*commonv1.KeyValue, key string) string
- func GetResourceAttribute(r *resourcev1.Resource, key string) string
- type GRPCCollector
- func (c *GRPCCollector) Address() string
- func (c *GRPCCollector) Close()
- func (c *GRPCCollector) Port() int
- func (c *GRPCCollector) TakeLog() *logsv1.LogRecord
- func (c *GRPCCollector) TakeMetric() *metricsv1.ResourceMetrics
- func (c *GRPCCollector) TakeResourceLogs() *logsv1.ResourceLogs
- func (c *GRPCCollector) TakeResourceSpans() *tracev1.ResourceSpans
- func (c *GRPCCollector) TakeSpan() *tracev1.Span
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAttributeString ¶
GetAttributeString returns the string value for the given key, or empty string if not found.
func GetResourceAttribute ¶
func GetResourceAttribute(r *resourcev1.Resource, key string) string
GetResourceAttribute returns the string value for the given key from resource attributes.
Types ¶
type GRPCCollector ¶
type GRPCCollector struct {
// contains filtered or unexported fields
}
GRPCCollector is a test OTLP gRPC collector that captures logs, traces, and metrics. gRPC metadata is injected as attributes on each signal for easy assertion.
func StartGRPCCollector ¶
func StartGRPCCollector() (*GRPCCollector, error)
StartGRPCCollector starts a test OTLP gRPC collector on an available port.
func (*GRPCCollector) Address ¶
func (c *GRPCCollector) Address() string
Address returns the full address (host:port) the collector is listening on.
func (*GRPCCollector) Close ¶
func (c *GRPCCollector) Close()
Close shuts down the collector and cleans up resources.
func (*GRPCCollector) Port ¶
func (c *GRPCCollector) Port() int
Port returns the port the collector is listening on.
func (*GRPCCollector) TakeLog ¶
func (c *GRPCCollector) TakeLog() *logsv1.LogRecord
TakeLog returns a single log record or nil if none were recorded within the timeout.
func (*GRPCCollector) TakeMetric ¶
func (c *GRPCCollector) TakeMetric() *metricsv1.ResourceMetrics
TakeMetric returns resource metrics or nil if none were recorded within the timeout.
func (*GRPCCollector) TakeResourceLogs ¶
func (c *GRPCCollector) TakeResourceLogs() *logsv1.ResourceLogs
TakeResourceLogs returns resource logs or nil if none were recorded within the timeout.
func (*GRPCCollector) TakeResourceSpans ¶
func (c *GRPCCollector) TakeResourceSpans() *tracev1.ResourceSpans
TakeResourceSpans returns resource spans or nil if none were recorded within the timeout.
func (*GRPCCollector) TakeSpan ¶
func (c *GRPCCollector) TakeSpan() *tracev1.Span
TakeSpan returns a single span or nil if none were recorded within the timeout.