You've already forked opentelemetry-go
							
							
				mirror of
				https://github.com/open-telemetry/opentelemetry-go.git
				synced 2025-10-31 00:07:40 +02:00 
			
		
		
		
	Ignore value option for metricdatatest (#4447)
This commit is contained in:
		| @@ -56,6 +56,7 @@ type Datatypes interface { | ||||
| type config struct { | ||||
| 	ignoreTimestamp bool | ||||
| 	ignoreExemplars bool | ||||
| 	ignoreValue     bool | ||||
| } | ||||
|  | ||||
| func newConfig(opts []Option) config { | ||||
| @@ -93,6 +94,20 @@ func IgnoreExemplars() 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. | ||||
| func IgnoreValue() Option { | ||||
| 	return fnOption(func(cfg config) config { | ||||
| 		cfg.ignoreValue = true | ||||
| 		return cfg | ||||
| 	}) | ||||
| } | ||||
|  | ||||
| // AssertEqual asserts that the two concrete data-types from the metricdata | ||||
| // package are equal. | ||||
| func AssertEqual[T Datatypes](t *testing.T, expected, actual T, opts ...Option) bool { | ||||
|   | ||||
| @@ -85,6 +85,20 @@ var ( | ||||
| 		SpanID:             spanIDA, | ||||
| 		TraceID:            traceIDA, | ||||
| 	} | ||||
| 	exemplarInt64D = metricdata.Exemplar[int64]{ | ||||
| 		FilteredAttributes: fltrAttrA, | ||||
| 		Time:               endA, | ||||
| 		Value:              12, | ||||
| 		SpanID:             spanIDA, | ||||
| 		TraceID:            traceIDA, | ||||
| 	} | ||||
| 	exemplarFloat64D = metricdata.Exemplar[float64]{ | ||||
| 		FilteredAttributes: fltrAttrA, | ||||
| 		Time:               endA, | ||||
| 		Value:              12.0, | ||||
| 		SpanID:             spanIDA, | ||||
| 		TraceID:            traceIDA, | ||||
| 	} | ||||
|  | ||||
| 	dataPointInt64A = metricdata.DataPoint[int64]{ | ||||
| 		Attributes: attrA, | ||||
| @@ -128,6 +142,20 @@ var ( | ||||
| 		Value:      -1.0, | ||||
| 		Exemplars:  []metricdata.Exemplar[float64]{exemplarFloat64C}, | ||||
| 	} | ||||
| 	dataPointInt64D = metricdata.DataPoint[int64]{ | ||||
| 		Attributes: attrA, | ||||
| 		StartTime:  startA, | ||||
| 		Time:       endA, | ||||
| 		Value:      2, | ||||
| 		Exemplars:  []metricdata.Exemplar[int64]{exemplarInt64A}, | ||||
| 	} | ||||
| 	dataPointFloat64D = metricdata.DataPoint[float64]{ | ||||
| 		Attributes: attrA, | ||||
| 		StartTime:  startA, | ||||
| 		Time:       endA, | ||||
| 		Value:      2.0, | ||||
| 		Exemplars:  []metricdata.Exemplar[float64]{exemplarFloat64A}, | ||||
| 	} | ||||
|  | ||||
| 	minFloat64A              = metricdata.NewExtrema(-1.) | ||||
| 	minInt64A                = metricdata.NewExtrema[int64](-1) | ||||
| @@ -204,6 +232,30 @@ var ( | ||||
| 		Sum:          2, | ||||
| 		Exemplars:    []metricdata.Exemplar[float64]{exemplarFloat64C}, | ||||
| 	} | ||||
| 	histogramDataPointInt64D = metricdata.HistogramDataPoint[int64]{ | ||||
| 		Attributes:   attrA, | ||||
| 		StartTime:    startA, | ||||
| 		Time:         endA, | ||||
| 		Count:        3, | ||||
| 		Bounds:       []float64{0, 10, 100}, | ||||
| 		BucketCounts: []uint64{1, 1, 1}, | ||||
| 		Max:          maxInt64B, | ||||
| 		Min:          minInt64B, | ||||
| 		Sum:          3, | ||||
| 		Exemplars:    []metricdata.Exemplar[int64]{exemplarInt64A}, | ||||
| 	} | ||||
| 	histogramDataPointFloat64D = metricdata.HistogramDataPoint[float64]{ | ||||
| 		Attributes:   attrA, | ||||
| 		StartTime:    startA, | ||||
| 		Time:         endA, | ||||
| 		Count:        3, | ||||
| 		Bounds:       []float64{0, 10, 100}, | ||||
| 		BucketCounts: []uint64{1, 1, 1}, | ||||
| 		Max:          maxFloat64B, | ||||
| 		Min:          minFloat64B, | ||||
| 		Sum:          3, | ||||
| 		Exemplars:    []metricdata.Exemplar[float64]{exemplarFloat64A}, | ||||
| 	} | ||||
|  | ||||
| 	exponentialBucket2 = metricdata.ExponentialBucket{ | ||||
| 		Offset: 2, | ||||
| @@ -301,6 +353,34 @@ var ( | ||||
| 		NegativeBucket: exponentialBucket2, | ||||
| 		Exemplars:      []metricdata.Exemplar[float64]{exemplarFloat64C}, | ||||
| 	} | ||||
| 	exponentialHistogramDataPointInt64D = metricdata.ExponentialHistogramDataPoint[int64]{ | ||||
| 		Attributes:     attrA, | ||||
| 		StartTime:      startA, | ||||
| 		Time:           endA, | ||||
| 		Count:          6, | ||||
| 		Min:            minInt64B, | ||||
| 		Max:            maxInt64B, | ||||
| 		Sum:            3, | ||||
| 		Scale:          2, | ||||
| 		ZeroCount:      3, | ||||
| 		PositiveBucket: exponentialBucket4, | ||||
| 		NegativeBucket: exponentialBucket5, | ||||
| 		Exemplars:      []metricdata.Exemplar[int64]{exemplarInt64A}, | ||||
| 	} | ||||
| 	exponentialHistogramDataPointFloat64D = metricdata.ExponentialHistogramDataPoint[float64]{ | ||||
| 		Attributes:     attrA, | ||||
| 		StartTime:      startA, | ||||
| 		Time:           endA, | ||||
| 		Count:          6, | ||||
| 		Min:            minFloat64B, | ||||
| 		Max:            maxFloat64B, | ||||
| 		Sum:            3, | ||||
| 		Scale:          2, | ||||
| 		ZeroCount:      3, | ||||
| 		PositiveBucket: exponentialBucket4, | ||||
| 		NegativeBucket: exponentialBucket5, | ||||
| 		Exemplars:      []metricdata.Exemplar[float64]{exemplarFloat64A}, | ||||
| 	} | ||||
|  | ||||
| 	gaugeInt64A = metricdata.Gauge[int64]{ | ||||
| 		DataPoints: []metricdata.DataPoint[int64]{dataPointInt64A}, | ||||
| @@ -320,6 +400,12 @@ var ( | ||||
| 	gaugeFloat64C = metricdata.Gauge[float64]{ | ||||
| 		DataPoints: []metricdata.DataPoint[float64]{dataPointFloat64C}, | ||||
| 	} | ||||
| 	gaugeInt64D = metricdata.Gauge[int64]{ | ||||
| 		DataPoints: []metricdata.DataPoint[int64]{dataPointInt64D}, | ||||
| 	} | ||||
| 	gaugeFloat64D = metricdata.Gauge[float64]{ | ||||
| 		DataPoints: []metricdata.DataPoint[float64]{dataPointFloat64D}, | ||||
| 	} | ||||
|  | ||||
| 	sumInt64A = metricdata.Sum[int64]{ | ||||
| 		Temporality: metricdata.CumulativeTemporality, | ||||
| @@ -351,6 +437,16 @@ var ( | ||||
| 		IsMonotonic: true, | ||||
| 		DataPoints:  []metricdata.DataPoint[float64]{dataPointFloat64C}, | ||||
| 	} | ||||
| 	sumInt64D = metricdata.Sum[int64]{ | ||||
| 		Temporality: metricdata.CumulativeTemporality, | ||||
| 		IsMonotonic: true, | ||||
| 		DataPoints:  []metricdata.DataPoint[int64]{dataPointInt64D}, | ||||
| 	} | ||||
| 	sumFloat64D = metricdata.Sum[float64]{ | ||||
| 		Temporality: metricdata.CumulativeTemporality, | ||||
| 		IsMonotonic: true, | ||||
| 		DataPoints:  []metricdata.DataPoint[float64]{dataPointFloat64D}, | ||||
| 	} | ||||
|  | ||||
| 	histogramInt64A = metricdata.Histogram[int64]{ | ||||
| 		Temporality: metricdata.CumulativeTemporality, | ||||
| @@ -376,6 +472,14 @@ var ( | ||||
| 		Temporality: metricdata.CumulativeTemporality, | ||||
| 		DataPoints:  []metricdata.HistogramDataPoint[float64]{histogramDataPointFloat64C}, | ||||
| 	} | ||||
| 	histogramInt64D = metricdata.Histogram[int64]{ | ||||
| 		Temporality: metricdata.CumulativeTemporality, | ||||
| 		DataPoints:  []metricdata.HistogramDataPoint[int64]{histogramDataPointInt64D}, | ||||
| 	} | ||||
| 	histogramFloat64D = metricdata.Histogram[float64]{ | ||||
| 		Temporality: metricdata.CumulativeTemporality, | ||||
| 		DataPoints:  []metricdata.HistogramDataPoint[float64]{histogramDataPointFloat64D}, | ||||
| 	} | ||||
|  | ||||
| 	exponentialHistogramInt64A = metricdata.ExponentialHistogram[int64]{ | ||||
| 		Temporality: metricdata.CumulativeTemporality, | ||||
| @@ -401,6 +505,14 @@ var ( | ||||
| 		Temporality: metricdata.CumulativeTemporality, | ||||
| 		DataPoints:  []metricdata.ExponentialHistogramDataPoint[float64]{exponentialHistogramDataPointFloat64C}, | ||||
| 	} | ||||
| 	exponentialHistogramInt64D = metricdata.ExponentialHistogram[int64]{ | ||||
| 		Temporality: metricdata.CumulativeTemporality, | ||||
| 		DataPoints:  []metricdata.ExponentialHistogramDataPoint[int64]{exponentialHistogramDataPointInt64D}, | ||||
| 	} | ||||
| 	exponentialHistogramFloat64D = metricdata.ExponentialHistogram[float64]{ | ||||
| 		Temporality: metricdata.CumulativeTemporality, | ||||
| 		DataPoints:  []metricdata.ExponentialHistogramDataPoint[float64]{exponentialHistogramDataPointFloat64D}, | ||||
| 	} | ||||
|  | ||||
| 	metricsA = metricdata.Metrics{ | ||||
| 		Name:        "A", | ||||
| @@ -420,6 +532,12 @@ var ( | ||||
| 		Unit:        "1", | ||||
| 		Data:        sumInt64C, | ||||
| 	} | ||||
| 	metricsD = metricdata.Metrics{ | ||||
| 		Name:        "A", | ||||
| 		Description: "A desc", | ||||
| 		Unit:        "1", | ||||
| 		Data:        sumInt64D, | ||||
| 	} | ||||
|  | ||||
| 	scopeMetricsA = metricdata.ScopeMetrics{ | ||||
| 		Scope:   instrumentation.Scope{Name: "A"}, | ||||
| @@ -433,6 +551,10 @@ var ( | ||||
| 		Scope:   instrumentation.Scope{Name: "A"}, | ||||
| 		Metrics: []metricdata.Metrics{metricsC}, | ||||
| 	} | ||||
| 	scopeMetricsD = metricdata.ScopeMetrics{ | ||||
| 		Scope:   instrumentation.Scope{Name: "A"}, | ||||
| 		Metrics: []metricdata.Metrics{metricsD}, | ||||
| 	} | ||||
|  | ||||
| 	resourceMetricsA = metricdata.ResourceMetrics{ | ||||
| 		Resource:     resource.NewSchemaless(attribute.String("resource", "A")), | ||||
| @@ -446,6 +568,10 @@ var ( | ||||
| 		Resource:     resource.NewSchemaless(attribute.String("resource", "A")), | ||||
| 		ScopeMetrics: []metricdata.ScopeMetrics{scopeMetricsC}, | ||||
| 	} | ||||
| 	resourceMetricsD = metricdata.ResourceMetrics{ | ||||
| 		Resource:     resource.NewSchemaless(attribute.String("resource", "A")), | ||||
| 		ScopeMetrics: []metricdata.ScopeMetrics{scopeMetricsD}, | ||||
| 	} | ||||
| ) | ||||
|  | ||||
| type equalFunc[T Datatypes] func(T, T, config) []string | ||||
| @@ -482,6 +608,17 @@ func testDatatypeIgnoreExemplars[T Datatypes](a, b T, f equalFunc[T]) func(*test | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func testDatatypeIgnoreValue[T Datatypes](a, b T, f equalFunc[T]) func(*testing.T) { | ||||
| 	return func(t *testing.T) { | ||||
| 		AssertEqual(t, a, a) | ||||
| 		AssertEqual(t, b, b) | ||||
|  | ||||
| 		c := newConfig([]Option{IgnoreValue()}) | ||||
| 		r := f(a, b, c) | ||||
| 		assert.Len(t, r, 0, "unexpected inequality") | ||||
| 	} | ||||
| } | ||||
|  | ||||
| func TestAssertEqual(t *testing.T) { | ||||
| 	t.Run("ResourceMetrics", testDatatype(resourceMetricsA, resourceMetricsB, equalResourceMetrics)) | ||||
| 	t.Run("ScopeMetrics", testDatatype(scopeMetricsA, scopeMetricsB, equalScopeMetrics)) | ||||
| @@ -557,6 +694,28 @@ func TestAssertEqualIgnoreExemplars(t *testing.T) { | ||||
| 	t.Run("ExponentialHistogramDataPointFloat64", testDatatypeIgnoreExemplars(exponentialHistogramDataPointFloat64A, ehdpFloat64, equalExponentialHistogramDataPoints[float64])) | ||||
| } | ||||
|  | ||||
| func TestAssertEqualIgnoreValue(t *testing.T) { | ||||
| 	t.Run("ResourceMetrics", testDatatypeIgnoreValue(resourceMetricsA, resourceMetricsD, equalResourceMetrics)) | ||||
| 	t.Run("ScopeMetrics", testDatatypeIgnoreValue(scopeMetricsA, scopeMetricsD, equalScopeMetrics)) | ||||
| 	t.Run("Metrics", testDatatypeIgnoreValue(metricsA, metricsD, equalMetrics)) | ||||
| 	t.Run("HistogramInt64", testDatatypeIgnoreValue(histogramInt64A, histogramInt64D, equalHistograms[int64])) | ||||
| 	t.Run("HistogramFloat64", testDatatypeIgnoreValue(histogramFloat64A, histogramFloat64D, equalHistograms[float64])) | ||||
| 	t.Run("SumInt64", testDatatypeIgnoreValue(sumInt64A, sumInt64D, equalSums[int64])) | ||||
| 	t.Run("SumFloat64", testDatatypeIgnoreValue(sumFloat64A, sumFloat64D, equalSums[float64])) | ||||
| 	t.Run("GaugeInt64", testDatatypeIgnoreValue(gaugeInt64A, gaugeInt64D, equalGauges[int64])) | ||||
| 	t.Run("GaugeFloat64", testDatatypeIgnoreValue(gaugeFloat64A, gaugeFloat64D, equalGauges[float64])) | ||||
| 	t.Run("HistogramDataPointInt64", testDatatypeIgnoreValue(histogramDataPointInt64A, histogramDataPointInt64D, equalHistogramDataPoints[int64])) | ||||
| 	t.Run("HistogramDataPointFloat64", testDatatypeIgnoreValue(histogramDataPointFloat64A, histogramDataPointFloat64D, equalHistogramDataPoints[float64])) | ||||
| 	t.Run("DataPointInt64", testDatatypeIgnoreValue(dataPointInt64A, dataPointInt64D, equalDataPoints[int64])) | ||||
| 	t.Run("DataPointFloat64", testDatatypeIgnoreValue(dataPointFloat64A, dataPointFloat64D, equalDataPoints[float64])) | ||||
| 	t.Run("ExemplarInt64", testDatatypeIgnoreValue(exemplarInt64A, exemplarInt64D, equalExemplars[int64])) | ||||
| 	t.Run("ExemplarFloat64", testDatatypeIgnoreValue(exemplarFloat64A, exemplarFloat64D, equalExemplars[float64])) | ||||
| 	t.Run("ExponentialHistogramInt64", testDatatypeIgnoreValue(exponentialHistogramInt64A, exponentialHistogramInt64D, equalExponentialHistograms[int64])) | ||||
| 	t.Run("ExponentialHistogramFloat64", testDatatypeIgnoreValue(exponentialHistogramFloat64A, exponentialHistogramFloat64D, equalExponentialHistograms[float64])) | ||||
| 	t.Run("ExponentialHistogramDataPointInt64", testDatatypeIgnoreValue(exponentialHistogramDataPointInt64A, exponentialHistogramDataPointInt64D, equalExponentialHistogramDataPoints[int64])) | ||||
| 	t.Run("ExponentialHistogramDataPointFloat64", testDatatypeIgnoreValue(exponentialHistogramDataPointFloat64A, exponentialHistogramDataPointFloat64D, equalExponentialHistogramDataPoints[float64])) | ||||
| } | ||||
|  | ||||
| type unknownAggregation struct { | ||||
| 	metricdata.Aggregation | ||||
| } | ||||
| @@ -587,47 +746,71 @@ func TestAssertAggregationsEqual(t *testing.T) { | ||||
| 	r = equalAggregations(sumInt64A, sumInt64C, config{ignoreTimestamp: true}) | ||||
| 	assert.Len(t, r, 0, "sums should be equal: %v", r) | ||||
|  | ||||
| 	r = equalAggregations(sumInt64A, sumInt64D, config{ignoreValue: true}) | ||||
| 	assert.Len(t, r, 0, "value should be ignored: %v == %v", sumInt64A, sumInt64D) | ||||
|  | ||||
| 	r = equalAggregations(sumFloat64A, sumFloat64B, config{}) | ||||
| 	assert.Greaterf(t, len(r), 0, "sums should not be equal: %v == %v", sumFloat64A, sumFloat64B) | ||||
|  | ||||
| 	r = equalAggregations(sumFloat64A, sumFloat64C, config{ignoreTimestamp: true}) | ||||
| 	assert.Len(t, r, 0, "sums should be equal: %v", r) | ||||
|  | ||||
| 	r = equalAggregations(sumFloat64A, sumFloat64D, config{ignoreValue: true}) | ||||
| 	assert.Len(t, r, 0, "value should be ignored: %v == %v", sumFloat64A, sumFloat64D) | ||||
|  | ||||
| 	r = equalAggregations(gaugeInt64A, gaugeInt64B, config{}) | ||||
| 	assert.Greaterf(t, len(r), 0, "gauges should not be equal: %v == %v", gaugeInt64A, gaugeInt64B) | ||||
|  | ||||
| 	r = equalAggregations(gaugeInt64A, gaugeInt64C, config{ignoreTimestamp: true}) | ||||
| 	assert.Len(t, r, 0, "gauges should be equal: %v", r) | ||||
|  | ||||
| 	r = equalAggregations(gaugeInt64A, gaugeInt64D, config{ignoreValue: true}) | ||||
| 	assert.Len(t, r, 0, "value should be ignored: %v == %v", gaugeInt64A, gaugeInt64D) | ||||
|  | ||||
| 	r = equalAggregations(gaugeFloat64A, gaugeFloat64B, config{}) | ||||
| 	assert.Greaterf(t, len(r), 0, "gauges should not be equal: %v == %v", gaugeFloat64A, gaugeFloat64B) | ||||
|  | ||||
| 	r = equalAggregations(gaugeFloat64A, gaugeFloat64C, config{ignoreTimestamp: true}) | ||||
| 	assert.Len(t, r, 0, "gauges should be equal: %v", r) | ||||
|  | ||||
| 	r = equalAggregations(gaugeFloat64A, gaugeFloat64D, config{ignoreValue: true}) | ||||
| 	assert.Len(t, r, 0, "value should be ignored: %v == %v", gaugeFloat64A, gaugeFloat64D) | ||||
|  | ||||
| 	r = equalAggregations(histogramInt64A, histogramInt64B, config{}) | ||||
| 	assert.Greaterf(t, len(r), 0, "histograms should not be equal: %v == %v", histogramInt64A, histogramInt64B) | ||||
|  | ||||
| 	r = equalAggregations(histogramInt64A, histogramInt64C, config{ignoreTimestamp: true}) | ||||
| 	assert.Len(t, r, 0, "histograms should be equal: %v", r) | ||||
|  | ||||
| 	r = equalAggregations(histogramInt64A, histogramInt64D, config{ignoreValue: true}) | ||||
| 	assert.Len(t, r, 0, "value should be ignored: %v == %v", histogramInt64A, histogramInt64D) | ||||
|  | ||||
| 	r = equalAggregations(histogramFloat64A, histogramFloat64B, config{}) | ||||
| 	assert.Greaterf(t, len(r), 0, "histograms should not be equal: %v == %v", histogramFloat64A, histogramFloat64B) | ||||
|  | ||||
| 	r = equalAggregations(histogramFloat64A, histogramFloat64C, config{ignoreTimestamp: true}) | ||||
| 	assert.Len(t, r, 0, "histograms should be equal: %v", r) | ||||
|  | ||||
| 	r = equalAggregations(histogramFloat64A, histogramFloat64D, config{ignoreValue: true}) | ||||
| 	assert.Len(t, r, 0, "value should be ignored: %v == %v", histogramFloat64A, histogramFloat64D) | ||||
|  | ||||
| 	r = equalAggregations(exponentialHistogramInt64A, exponentialHistogramInt64B, config{}) | ||||
| 	assert.Greaterf(t, len(r), 0, "exponential histograms should not be equal: %v == %v", exponentialHistogramInt64A, exponentialHistogramInt64B) | ||||
|  | ||||
| 	r = equalAggregations(exponentialHistogramInt64A, exponentialHistogramInt64C, config{ignoreTimestamp: true}) | ||||
| 	assert.Len(t, r, 0, "exponential histograms should be equal: %v", r) | ||||
|  | ||||
| 	r = equalAggregations(exponentialHistogramInt64A, exponentialHistogramInt64D, config{ignoreValue: true}) | ||||
| 	assert.Len(t, r, 0, "value should be ignored: %v == %v", exponentialHistogramInt64A, exponentialHistogramInt64D) | ||||
|  | ||||
| 	r = equalAggregations(exponentialHistogramFloat64A, exponentialHistogramFloat64B, config{}) | ||||
| 	assert.Greaterf(t, len(r), 0, "exponential histograms should not be equal: %v == %v", exponentialHistogramFloat64A, exponentialHistogramFloat64B) | ||||
|  | ||||
| 	r = equalAggregations(exponentialHistogramFloat64A, exponentialHistogramFloat64C, config{ignoreTimestamp: true}) | ||||
| 	assert.Len(t, r, 0, "exponential histograms should be equal: %v", r) | ||||
|  | ||||
| 	r = equalAggregations(exponentialHistogramFloat64A, exponentialHistogramFloat64D, config{ignoreValue: true}) | ||||
| 	assert.Len(t, r, 0, "value should be ignored: %v == %v", exponentialHistogramFloat64A, exponentialHistogramFloat64D) | ||||
| } | ||||
|  | ||||
| func TestAssertAttributes(t *testing.T) { | ||||
|   | ||||
| @@ -252,8 +252,10 @@ func equalDataPoints[N int64 | float64](a, b metricdata.DataPoint[N], cfg config | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if a.Value != b.Value { | ||||
| 		reasons = append(reasons, notEqualStr("Value", a.Value, b.Value)) | ||||
| 	if !cfg.ignoreValue { | ||||
| 		if a.Value != b.Value { | ||||
| 			reasons = append(reasons, notEqualStr("Value", a.Value, b.Value)) | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	if !cfg.ignoreExemplars { | ||||
| @@ -290,23 +292,25 @@ func equalHistogramDataPoints[N int64 | float64](a, b metricdata.HistogramDataPo | ||||
| 			reasons = append(reasons, notEqualStr("Time", a.Time.UnixNano(), b.Time.UnixNano())) | ||||
| 		} | ||||
| 	} | ||||
| 	if a.Count != b.Count { | ||||
| 		reasons = append(reasons, notEqualStr("Count", a.Count, b.Count)) | ||||
| 	} | ||||
| 	if !equalSlices(a.Bounds, b.Bounds) { | ||||
| 		reasons = append(reasons, notEqualStr("Bounds", a.Bounds, b.Bounds)) | ||||
| 	} | ||||
| 	if !equalSlices(a.BucketCounts, b.BucketCounts) { | ||||
| 		reasons = append(reasons, notEqualStr("BucketCounts", a.BucketCounts, b.BucketCounts)) | ||||
| 	} | ||||
| 	if !eqExtrema(a.Min, b.Min) { | ||||
| 		reasons = append(reasons, notEqualStr("Min", a.Min, b.Min)) | ||||
| 	} | ||||
| 	if !eqExtrema(a.Max, b.Max) { | ||||
| 		reasons = append(reasons, notEqualStr("Max", a.Max, b.Max)) | ||||
| 	} | ||||
| 	if a.Sum != b.Sum { | ||||
| 		reasons = append(reasons, notEqualStr("Sum", a.Sum, b.Sum)) | ||||
| 	if !cfg.ignoreValue { | ||||
| 		if a.Count != b.Count { | ||||
| 			reasons = append(reasons, notEqualStr("Count", a.Count, b.Count)) | ||||
| 		} | ||||
| 		if !equalSlices(a.Bounds, b.Bounds) { | ||||
| 			reasons = append(reasons, notEqualStr("Bounds", a.Bounds, b.Bounds)) | ||||
| 		} | ||||
| 		if !equalSlices(a.BucketCounts, b.BucketCounts) { | ||||
| 			reasons = append(reasons, notEqualStr("BucketCounts", a.BucketCounts, b.BucketCounts)) | ||||
| 		} | ||||
| 		if !eqExtrema(a.Min, b.Min) { | ||||
| 			reasons = append(reasons, notEqualStr("Min", a.Min, b.Min)) | ||||
| 		} | ||||
| 		if !eqExtrema(a.Max, b.Max) { | ||||
| 			reasons = append(reasons, notEqualStr("Max", a.Max, b.Max)) | ||||
| 		} | ||||
| 		if a.Sum != b.Sum { | ||||
| 			reasons = append(reasons, notEqualStr("Sum", a.Sum, b.Sum)) | ||||
| 		} | ||||
| 	} | ||||
| 	if !cfg.ignoreExemplars { | ||||
| 		r := compareDiff(diffSlices( | ||||
| @@ -366,35 +370,36 @@ func equalExponentialHistogramDataPoints[N int64 | float64](a, b metricdata.Expo | ||||
| 			reasons = append(reasons, notEqualStr("Time", a.Time.UnixNano(), b.Time.UnixNano())) | ||||
| 		} | ||||
| 	} | ||||
| 	if a.Count != b.Count { | ||||
| 		reasons = append(reasons, notEqualStr("Count", a.Count, b.Count)) | ||||
| 	} | ||||
| 	if !eqExtrema(a.Min, b.Min) { | ||||
| 		reasons = append(reasons, notEqualStr("Min", a.Min, b.Min)) | ||||
| 	} | ||||
| 	if !eqExtrema(a.Max, b.Max) { | ||||
| 		reasons = append(reasons, notEqualStr("Max", a.Max, b.Max)) | ||||
| 	} | ||||
| 	if a.Sum != b.Sum { | ||||
| 		reasons = append(reasons, notEqualStr("Sum", a.Sum, b.Sum)) | ||||
| 	} | ||||
| 	if !cfg.ignoreValue { | ||||
| 		if a.Count != b.Count { | ||||
| 			reasons = append(reasons, notEqualStr("Count", a.Count, b.Count)) | ||||
| 		} | ||||
| 		if !eqExtrema(a.Min, b.Min) { | ||||
| 			reasons = append(reasons, notEqualStr("Min", a.Min, b.Min)) | ||||
| 		} | ||||
| 		if !eqExtrema(a.Max, b.Max) { | ||||
| 			reasons = append(reasons, notEqualStr("Max", a.Max, b.Max)) | ||||
| 		} | ||||
| 		if a.Sum != b.Sum { | ||||
| 			reasons = append(reasons, notEqualStr("Sum", a.Sum, b.Sum)) | ||||
| 		} | ||||
|  | ||||
| 	if a.Scale != b.Scale { | ||||
| 		reasons = append(reasons, notEqualStr("Scale", a.Scale, b.Scale)) | ||||
| 	} | ||||
| 	if a.ZeroCount != b.ZeroCount { | ||||
| 		reasons = append(reasons, notEqualStr("ZeroCount", a.ZeroCount, b.ZeroCount)) | ||||
| 	} | ||||
| 		if a.Scale != b.Scale { | ||||
| 			reasons = append(reasons, notEqualStr("Scale", a.Scale, b.Scale)) | ||||
| 		} | ||||
| 		if a.ZeroCount != b.ZeroCount { | ||||
| 			reasons = append(reasons, notEqualStr("ZeroCount", a.ZeroCount, b.ZeroCount)) | ||||
| 		} | ||||
|  | ||||
| 	r := equalExponentialBuckets(a.PositiveBucket, b.PositiveBucket, cfg) | ||||
| 	if len(r) > 0 { | ||||
| 		reasons = append(reasons, r...) | ||||
| 		r := equalExponentialBuckets(a.PositiveBucket, b.PositiveBucket, cfg) | ||||
| 		if len(r) > 0 { | ||||
| 			reasons = append(reasons, r...) | ||||
| 		} | ||||
| 		r = equalExponentialBuckets(a.NegativeBucket, b.NegativeBucket, cfg) | ||||
| 		if len(r) > 0 { | ||||
| 			reasons = append(reasons, r...) | ||||
| 		} | ||||
| 	} | ||||
| 	r = equalExponentialBuckets(a.NegativeBucket, b.NegativeBucket, cfg) | ||||
| 	if len(r) > 0 { | ||||
| 		reasons = append(reasons, r...) | ||||
| 	} | ||||
|  | ||||
| 	if !cfg.ignoreExemplars { | ||||
| 		r := compareDiff(diffSlices( | ||||
| 			a.Exemplars, | ||||
| @@ -518,8 +523,10 @@ func equalExemplars[N int64 | float64](a, b metricdata.Exemplar[N], cfg config) | ||||
| 			reasons = append(reasons, notEqualStr("Time", a.Time.UnixNano(), b.Time.UnixNano())) | ||||
| 		} | ||||
| 	} | ||||
| 	if a.Value != b.Value { | ||||
| 		reasons = append(reasons, notEqualStr("Value", a.Value, b.Value)) | ||||
| 	if !cfg.ignoreValue { | ||||
| 		if a.Value != b.Value { | ||||
| 			reasons = append(reasons, notEqualStr("Value", a.Value, b.Value)) | ||||
| 		} | ||||
| 	} | ||||
| 	if !equalSlices(a.SpanID, b.SpanID) { | ||||
| 		reasons = append(reasons, notEqualStr("SpanID", a.SpanID, b.SpanID)) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user