package metricdatatest
import "go.opentelemetry.io/otel/sdk/metric/metricdata/metricdatatest"
Package metricdatatest provides testing functionality for use with the metricdata package.
Index ¶
- func AssertAggregationsEqual(t TestingT, expected, actual metricdata.Aggregation, opts ...Option) bool
- func AssertEqual[T Datatypes](t TestingT, expected, actual T, opts ...Option) bool
- func AssertHasAttributes[T Datatypes](t TestingT, actual T, attrs ...attribute.KeyValue) bool
- type Datatypes
- type Option
- type TestingT
Functions ¶
func AssertAggregationsEqual ¶
func AssertAggregationsEqual(t TestingT, expected, actual metricdata.Aggregation, opts ...Option) bool
AssertAggregationsEqual asserts that two Aggregations are equal.
func AssertEqual ¶
AssertEqual asserts that the two concrete data-types from the metricdata package are equal.
func AssertHasAttributes ¶
AssertHasAttributes asserts that all Datapoints or HistogramDataPoints have all passed attrs.
Types ¶
type Datatypes ¶
type Datatypes interface { metricdata.DataPoint[float64] | metricdata.DataPoint[int64] | metricdata.Gauge[float64] | metricdata.Gauge[int64] | metricdata.Histogram[float64] | metricdata.Histogram[int64] | metricdata.HistogramDataPoint[float64] | metricdata.HistogramDataPoint[int64] | metricdata.Extrema[int64] | metricdata.Extrema[float64] | metricdata.Metrics | metricdata.ResourceMetrics | metricdata.ScopeMetrics | metricdata.Sum[float64] | metricdata.Sum[int64] | metricdata.Exemplar[float64] | metricdata.Exemplar[int64] | metricdata.ExponentialHistogram[float64] | metricdata.ExponentialHistogram[int64] | metricdata.ExponentialHistogramDataPoint[float64] | metricdata.ExponentialHistogramDataPoint[int64] | metricdata.ExponentialBucket | metricdata.Summary | metricdata.SummaryDataPoint | metricdata.QuantileValue }
Datatypes are the concrete data-types the metricdata package provides.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option allows for fine grain control over how AssertEqual operates.
func IgnoreExemplars ¶
func IgnoreExemplars() Option
IgnoreExemplars disables checking if Exemplars are different.
func IgnoreTimestamp ¶
func IgnoreTimestamp() Option
IgnoreTimestamp disables checking if timestamps are different.
func IgnoreValue ¶
func IgnoreValue() Option
IgnoreValue disables checking if values are different. This can be useful for non-deterministic values, like measured durations.
This will ignore the value and trace information for Exemplars; the buckets, zero count, scale, sum, max, min, and counts of ExponentialHistogramDataPoints; the buckets, sum, count, max, and min of HistogramDataPoints; the value of DataPoints.
type TestingT ¶
type TestingT interface { Helper() Error(...any) }
TestingT is an interface that implements testing.T, but without the private method of testing.TB, so other testing packages can rely on it as well. The methods in this interface must match the testing.TB interface.
Source Files ¶
assertion.go comparisons.go
- Version
- v1.34.0 (latest)
- Published
- Jan 17, 2025
- Platform
- linux/amd64
- Imports
- 6 packages
- Last checked
- 3 hours ago –
Tools for package owners.