Help us shape the future of Go! Take the 2026 Go Developer Survey

testmetrics

package
v1.24.2 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MetricData

type MetricData struct {
	Name   string
	Value  float64
	Labels map[string]string
}

MetricData represents a metric measurement for testing.

type TestExporter

type TestExporter struct {
	// contains filtered or unexported fields
}

TestExporter captures and validates OpenTelemetry metrics in tests.

func NewTestExporter

func NewTestExporter() (*TestExporter, error)

NewTestExporter creates a new test exporter with a fresh OpenTelemetry setup. This function initializes a new meter provider and all metric instruments for testing purposes. It returns an error if initialization fails.

func (*TestExporter) ClearMetrics

func (e *TestExporter) ClearMetrics()

ClearMetrics clears all collected metrics for this test exporter.

func (*TestExporter) CollectMetrics

func (e *TestExporter) CollectMetrics(ctx context.Context) error

CollectMetrics collects all OpenTelemetry metrics and stores them in a simple format.

func (*TestExporter) GetMetrics

func (e *TestExporter) GetMetrics() []MetricData

GetMetrics returns all collected metrics.

func (*TestExporter) ValidateMetrics

func (e *TestExporter) ValidateMetrics(expected []MetricData) string

ValidateMetrics compares collected metrics with expected values.

Jump to

Keyboard shortcuts

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