testotel

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package testotel provides test utilities for OpenTelemetry tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAttributeString

func GetAttributeString(attrs []*commonv1.KeyValue, key string) string

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.

Jump to

Keyboard shortcuts

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