diff --git a/CHANGELOG.md b/CHANGELOG.md index 47661450d5c..2539088b6c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,19 @@ ### 🚩 Deprecations 🚩 +- In preparation of migration to immutable slices for primitive type items, the following methods are renamed (#5344) + - `Value.BytesVal` func is deprecated in favor of `Value.MBytesVal`. + - `Value.SetBytesVal` func is deprecated in favor of `Value.SetMBytesVal`. + - `Value.UpdateBytes` func is deprecated in favor of `Value.UpdateMBytes`. + - `Value.InsertBytes` func is deprecated in favor of `Value.InsertMBytes`. + - `Value.UpsertBytes` func is deprecated in favor of `Value.UpsertMBytes`. + - `.BucketCounts` funcs are deprecated in favor of + `.MBucketCounts`. + - `.SetBucketCounts` funcs are deprecated in favor of + `.SetMBucketCounts`. + - `HistogramDataPoint.ExplicitBounds` func is deprecated in favor of `HistogramDataPoint.MExplicitBounds`. + - `HistogramDataPoint.SetExplicitBounds` func is deprecated in favor of `HistogramDataPoint.SetMExplicitBounds`. + ### 💡 Enhancements 💡 - `pdata`: Expose `pcommon.NewSliceFromRay` and `pcommon.Slice.AsRaw` functions (#5298) diff --git a/internal/otlptext/databuffer.go b/internal/otlptext/databuffer.go index f84b446c33c..2e7e4a28d5d 100644 --- a/internal/otlptext/databuffer.go +++ b/internal/otlptext/databuffer.go @@ -119,14 +119,14 @@ func (b *dataBuffer) logDoubleHistogramDataPoints(ps pmetric.HistogramDataPointS b.logEntry("Count: %d", p.Count()) b.logEntry("Sum: %f", p.Sum()) - bounds := p.ExplicitBounds() + bounds := p.MExplicitBounds() if len(bounds) != 0 { for i, bound := range bounds { b.logEntry("ExplicitBounds #%d: %f", i, bound) } } - buckets := p.BucketCounts() + buckets := p.MBucketCounts() if len(buckets) != 0 { for j, bucket := range buckets { b.logEntry("Buckets #%d, Count: %d", j, bucket) @@ -157,13 +157,13 @@ func (b *dataBuffer) logExponentialHistogramDataPoints(ps pmetric.ExponentialHis // uses a lookup table for the last finite boundary, which can be // easily computed using `math/big` (for scales up to 20). - negB := p.Negative().BucketCounts() - posB := p.Positive().BucketCounts() + negB := p.Negative().MBucketCounts() + posB := p.Positive().MBucketCounts() for i := 0; i < len(negB); i++ { pos := len(negB) - i - 1 index := p.Negative().Offset() + int32(pos) - count := p.Negative().BucketCounts()[pos] + count := p.Negative().MBucketCounts()[pos] lower := math.Exp(float64(index) * factor) upper := math.Exp(float64(index+1) * factor) b.logEntry("Bucket (%f, %f], Count: %d", -upper, -lower, count) @@ -175,7 +175,7 @@ func (b *dataBuffer) logExponentialHistogramDataPoints(ps pmetric.ExponentialHis for pos := 0; pos < len(posB); pos++ { index := p.Positive().Offset() + int32(pos) - count := p.Positive().BucketCounts()[pos] + count := p.Positive().MBucketCounts()[pos] lower := math.Exp(float64(index) * factor) upper := math.Exp(float64(index+1) * factor) b.logEntry("Bucket [%f, %f), Count: %d", lower, upper, count) diff --git a/internal/testdata/metric.go b/internal/testdata/metric.go index 76387d21ec4..02737d5b625 100644 --- a/internal/testdata/metric.go +++ b/internal/testdata/metric.go @@ -206,12 +206,12 @@ func initHistogramMetric(hm pmetric.Metric) { hdp1.SetTimestamp(TestMetricTimestamp) hdp1.SetCount(1) hdp1.SetSum(15) - hdp1.SetBucketCounts([]uint64{0, 1}) + hdp1.SetMBucketCounts([]uint64{0, 1}) exemplar := hdp1.Exemplars().AppendEmpty() exemplar.SetTimestamp(TestMetricExemplarTimestamp) exemplar.SetDoubleVal(15) initMetricAttachment(exemplar.FilteredAttributes()) - hdp1.SetExplicitBounds([]float64{1}) + hdp1.SetMExplicitBounds([]float64{1}) } func initExponentialHistogramMetric(hm pmetric.Metric) { @@ -229,10 +229,10 @@ func initExponentialHistogramMetric(hm pmetric.Metric) { // positive index 1 and 2 are values sqrt(2), 2 at scale 1 hdp0.Positive().SetOffset(1) - hdp0.Positive().SetBucketCounts([]uint64{1, 1}) + hdp0.Positive().SetMBucketCounts([]uint64{1, 1}) // negative index -1 and 0 are values -1/sqrt(2), -1 at scale 1 hdp0.Negative().SetOffset(-1) - hdp0.Negative().SetBucketCounts([]uint64{1, 1}) + hdp0.Negative().SetMBucketCounts([]uint64{1, 1}) // The above will print: // Bucket (-1.414214, -1.000000], Count: 1 @@ -252,7 +252,7 @@ func initExponentialHistogramMetric(hm pmetric.Metric) { // index -1 and 0 are values 0.25, 1 at scale -1 hdp1.Positive().SetOffset(-1) - hdp1.Positive().SetBucketCounts([]uint64{1, 1}) + hdp1.Positive().SetMBucketCounts([]uint64{1, 1}) // The above will print: // Bucket [0, 0], Count: 1 diff --git a/pdata/internal/cmd/pdatagen/internal/metrics_structs.go b/pdata/internal/cmd/pdatagen/internal/metrics_structs.go index 863383bd664..a3023fc87f5 100644 --- a/pdata/internal/cmd/pdatagen/internal/metrics_structs.go +++ b/pdata/internal/cmd/pdatagen/internal/metrics_structs.go @@ -476,7 +476,7 @@ var valueFloat64Field = &primitiveField{ } var bucketCountsField = &primitiveSliceField{ - fieldName: "BucketCounts", + fieldName: "MBucketCounts", originFieldName: "BucketCounts", returnType: "[]uint64", defaultVal: "[]uint64(nil)", @@ -485,7 +485,7 @@ var bucketCountsField = &primitiveSliceField{ } var explicitBoundsField = &primitiveSliceField{ - fieldName: "ExplicitBounds", + fieldName: "MExplicitBounds", originFieldName: "ExplicitBounds", returnType: "[]float64", defaultVal: "[]float64(nil)", diff --git a/pdata/internal/common.go b/pdata/internal/common.go index ef31705553d..bc231c02e00 100644 --- a/pdata/internal/common.go +++ b/pdata/internal/common.go @@ -262,10 +262,19 @@ func (v Value) SliceVal() Slice { // If the Type() is not ValueTypeBytes then returns false. // Calling this function on zero-initialized Value will cause a panic. // Modifying the returned []byte in-place is forbidden. +// Deprecated: [0.51.0] Use MBytesVal instead. func (v Value) BytesVal() []byte { return v.orig.GetBytesValue() } +// MBytesVal returns the []byte value associated with this Value. +// If the Type() is not ValueTypeBytes then returns false. +// Calling this function on zero-initialized Value will cause a panic. +// Modifying the returned []byte in-place is forbidden. +func (v Value) MBytesVal() []byte { + return v.orig.GetBytesValue() +} + // SetStringVal replaces the string value associated with this Value, // it also changes the type to be ValueTypeString. // Calling this function on zero-initialized Value will cause a panic. @@ -299,10 +308,20 @@ func (v Value) SetBoolVal(bv bool) { // Calling this function on zero-initialized Value will cause a panic. // The caller must ensure the []byte passed in is not modified after the call is made, sharing the data // across multiple attributes is forbidden. +// Deprecated: [0.51.0] Use SetMBytesVal instead. func (v Value) SetBytesVal(bv []byte) { v.orig.Value = &otlpcommon.AnyValue_BytesValue{BytesValue: bv} } +// SetMBytesVal replaces the []byte value associated with this Value, +// it also changes the type to be ValueTypeBytes. +// Calling this function on zero-initialized Value will cause a panic. +// The caller must ensure the []byte passed in is not modified after the call is made, sharing the data +// across multiple attributes is forbidden. +func (v Value) SetMBytesVal(bv []byte) { + v.orig.Value = &otlpcommon.AnyValue_BytesValue{BytesValue: bv} +} + // copyTo copies the value to Value. Will panic if dest is nil. func (v Value) copyTo(dest *otlpcommon.AnyValue) { switch ov := v.orig.Value.(type) { @@ -709,12 +728,23 @@ func (m Map) InsertBool(k string, v bool) { // No action is applied to the map where the key already exists. // The caller must ensure the []byte passed in is not modified after the call is made, sharing the data // across multiple attributes is forbidden. +// Deprecated: [0.51.0] Use InsertMBytes instead. func (m Map) InsertBytes(k string, v []byte) { if _, existing := m.Get(k); !existing { *m.orig = append(*m.orig, newAttributeKeyValueBytes(k, v)) } } +// InsertMBytes adds the []byte Value to the map when the key does not exist. +// No action is applied to the map where the key already exists. +// The caller must ensure the []byte passed in is not modified after the call is made, sharing the data +// across multiple attributes is forbidden. +func (m Map) InsertMBytes(k string, v []byte) { + if _, existing := m.Get(k); !existing { + *m.orig = append(*m.orig, newAttributeKeyValueBytes(k, v)) + } +} + // Update updates an existing Value with a value. // No action is applied to the map where the key does not exist. // @@ -764,9 +794,20 @@ func (m Map) UpdateBool(k string, v bool) { // No action is applied to the map where the key does not exist. // The caller must ensure the []byte passed in is not modified after the call is made, sharing the data // across multiple attributes is forbidden. +// Deprecated: [0.51.0] Use UpdateMBytes instead. func (m Map) UpdateBytes(k string, v []byte) { if av, existing := m.Get(k); existing { - av.SetBytesVal(v) + av.SetMBytesVal(v) + } +} + +// UpdateMBytes updates an existing []byte Value with a value. +// No action is applied to the map where the key does not exist. +// The caller must ensure the []byte passed in is not modified after the call is made, sharing the data +// across multiple attributes is forbidden. +func (m Map) UpdateMBytes(k string, v []byte) { + if av, existing := m.Get(k); existing { + av.SetMBytesVal(v) } } @@ -835,9 +876,23 @@ func (m Map) UpsertBool(k string, v bool) { // updated to the map where the key already existed. // The caller must ensure the []byte passed in is not modified after the call is made, sharing the data // across multiple attributes is forbidden. +// Deprecated: [0.51.0] Use UpsertMBytes instead. func (m Map) UpsertBytes(k string, v []byte) { if av, existing := m.Get(k); existing { - av.SetBytesVal(v) + av.SetMBytesVal(v) + } else { + *m.orig = append(*m.orig, newAttributeKeyValueBytes(k, v)) + } +} + +// UpsertMBytes performs the Insert or Update action. The []byte Value is +// inserted to the map that did not originally have the key. The key/value is +// updated to the map where the key already existed. +// The caller must ensure the []byte passed in is not modified after the call is made, sharing the data +// across multiple attributes is forbidden. +func (m Map) UpsertMBytes(k string, v []byte) { + if av, existing := m.Get(k); existing { + av.SetMBytesVal(v) } else { *m.orig = append(*m.orig, newAttributeKeyValueBytes(k, v)) } diff --git a/pdata/internal/common_test.go b/pdata/internal/common_test.go index 73d82d56003..290bff5cbe2 100644 --- a/pdata/internal/common_test.go +++ b/pdata/internal/common_test.go @@ -298,7 +298,7 @@ func TestNilMap(t *testing.T) { assert.EqualValues(t, generateTestBoolMap(), insertMapBool) insertMapBytes := NewMap() - insertMapBytes.InsertBytes("k", []byte{1, 2, 3, 4, 5}) + insertMapBytes.InsertMBytes("k", []byte{1, 2, 3, 4, 5}) assert.EqualValues(t, generateTestBytesMap(), insertMapBytes) updateMap := NewMap() @@ -322,7 +322,7 @@ func TestNilMap(t *testing.T) { assert.EqualValues(t, NewMap(), updateMapBool) updateMapBytes := NewMap() - updateMapBytes.UpdateBytes("k", []byte{1, 2, 3}) + updateMapBytes.UpdateMBytes("k", []byte{1, 2, 3}) assert.EqualValues(t, NewMap(), updateMapBytes) upsertMap := NewMap() @@ -346,7 +346,7 @@ func TestNilMap(t *testing.T) { assert.EqualValues(t, generateTestBoolMap(), upsertMapBool) upsertMapBytes := NewMap() - upsertMapBytes.UpsertBytes("k", []byte{1, 2, 3, 4, 5}) + upsertMapBytes.UpsertMBytes("k", []byte{1, 2, 3, 4, 5}) assert.EqualValues(t, generateTestBytesMap(), upsertMapBytes) removeMap := NewMap() @@ -412,7 +412,7 @@ func TestMapWithEmpty(t *testing.T) { assert.EqualValues(t, ValueTypeBool, val.Type()) assert.True(t, val.BoolVal()) - sm.InsertBytes("other_key_bytes", []byte{1, 2, 3}) + sm.InsertMBytes("other_key_bytes", []byte{1, 2, 3}) val, exist = sm.Get("other_key_bytes") assert.True(t, exist) assert.EqualValues(t, ValueTypeBytes, val.Type()) @@ -448,7 +448,7 @@ func TestMapWithEmpty(t *testing.T) { assert.EqualValues(t, ValueTypeBool, val.Type()) assert.False(t, val.BoolVal()) - sm.UpdateBytes("other_key_bytes", []byte{4, 5, 6}) + sm.UpdateMBytes("other_key_bytes", []byte{4, 5, 6}) val, exist = sm.Get("other_key_bytes") assert.True(t, exist) assert.EqualValues(t, ValueTypeBytes, val.Type()) @@ -484,7 +484,7 @@ func TestMapWithEmpty(t *testing.T) { assert.EqualValues(t, ValueTypeBool, val.Type()) assert.True(t, val.BoolVal()) - sm.UpsertBytes("other_key_bytes", []byte{7, 8, 9}) + sm.UpsertMBytes("other_key_bytes", []byte{7, 8, 9}) val, exist = sm.Get("other_key_bytes") assert.True(t, exist) assert.EqualValues(t, ValueTypeBytes, val.Type()) @@ -520,7 +520,7 @@ func TestMapWithEmpty(t *testing.T) { assert.EqualValues(t, ValueTypeBool, val.Type()) assert.False(t, val.BoolVal()) - sm.UpsertBytes("yet_another_key_bytes", []byte{1}) + sm.UpsertMBytes("yet_another_key_bytes", []byte{1}) val, exist = sm.Get("yet_another_key_bytes") assert.True(t, exist) assert.EqualValues(t, ValueTypeBytes, val.Type()) diff --git a/pdata/internal/generated_pmetric.go b/pdata/internal/generated_pmetric.go index 4e4a4df13e4..7806df195ac 100644 --- a/pdata/internal/generated_pmetric.go +++ b/pdata/internal/generated_pmetric.go @@ -1444,23 +1444,23 @@ func (ms HistogramDataPoint) SetSum(v float64) { (*ms.orig).Sum_ = &otlpmetrics.HistogramDataPoint_Sum{Sum: v} } -// BucketCounts returns the bucketcounts associated with this HistogramDataPoint. -func (ms HistogramDataPoint) BucketCounts() []uint64 { +// MBucketCounts returns the mbucketcounts associated with this HistogramDataPoint. +func (ms HistogramDataPoint) MBucketCounts() []uint64 { return (*ms.orig).BucketCounts } -// SetBucketCounts replaces the bucketcounts associated with this HistogramDataPoint. -func (ms HistogramDataPoint) SetBucketCounts(v []uint64) { +// SetMBucketCounts replaces the mbucketcounts associated with this HistogramDataPoint. +func (ms HistogramDataPoint) SetMBucketCounts(v []uint64) { (*ms.orig).BucketCounts = v } -// ExplicitBounds returns the explicitbounds associated with this HistogramDataPoint. -func (ms HistogramDataPoint) ExplicitBounds() []float64 { +// MExplicitBounds returns the mexplicitbounds associated with this HistogramDataPoint. +func (ms HistogramDataPoint) MExplicitBounds() []float64 { return (*ms.orig).ExplicitBounds } -// SetExplicitBounds replaces the explicitbounds associated with this HistogramDataPoint. -func (ms HistogramDataPoint) SetExplicitBounds(v []float64) { +// SetMExplicitBounds replaces the mexplicitbounds associated with this HistogramDataPoint. +func (ms HistogramDataPoint) SetMExplicitBounds(v []float64) { (*ms.orig).ExplicitBounds = v } @@ -1822,13 +1822,13 @@ func (ms Buckets) SetOffset(v int32) { (*ms.orig).Offset = int32(v) } -// BucketCounts returns the bucketcounts associated with this Buckets. -func (ms Buckets) BucketCounts() []uint64 { +// MBucketCounts returns the mbucketcounts associated with this Buckets. +func (ms Buckets) MBucketCounts() []uint64 { return (*ms.orig).BucketCounts } -// SetBucketCounts replaces the bucketcounts associated with this Buckets. -func (ms Buckets) SetBucketCounts(v []uint64) { +// SetMBucketCounts replaces the mbucketcounts associated with this Buckets. +func (ms Buckets) SetMBucketCounts(v []uint64) { (*ms.orig).BucketCounts = v } diff --git a/pdata/internal/generated_pmetric_test.go b/pdata/internal/generated_pmetric_test.go index a457d7cef25..c0706d647be 100644 --- a/pdata/internal/generated_pmetric_test.go +++ b/pdata/internal/generated_pmetric_test.go @@ -1065,13 +1065,13 @@ func TestHistogramDataPoint_CopyTo(t *testing.T) { orig = generateTestHistogramDataPoint() orig.CopyTo(ms) assert.EqualValues(t, orig, ms) - orig.BucketCounts()[0] = 0 + orig.MBucketCounts()[0] = 0 assert.NotEqualValues(t, orig, ms) - orig.BucketCounts()[0] = []uint64{1, 2, 3}[0] + orig.MBucketCounts()[0] = []uint64{1, 2, 3}[0] assert.EqualValues(t, orig, ms) - orig.ExplicitBounds()[0] = 0 + orig.MExplicitBounds()[0] = 0 assert.NotEqualValues(t, orig, ms) - orig.ExplicitBounds()[0] = []float64{1, 2, 3}[0] + orig.MExplicitBounds()[0] = []float64{1, 2, 3}[0] assert.EqualValues(t, orig, ms) } @@ -1115,20 +1115,20 @@ func TestHistogramDataPoint_Sum(t *testing.T) { assert.EqualValues(t, testValSum, ms.Sum()) } -func TestHistogramDataPoint_BucketCounts(t *testing.T) { +func TestHistogramDataPoint_MBucketCounts(t *testing.T) { ms := NewHistogramDataPoint() - assert.EqualValues(t, []uint64(nil), ms.BucketCounts()) - testValBucketCounts := []uint64{1, 2, 3} - ms.SetBucketCounts(testValBucketCounts) - assert.EqualValues(t, testValBucketCounts, ms.BucketCounts()) + assert.EqualValues(t, []uint64(nil), ms.MBucketCounts()) + testValMBucketCounts := []uint64{1, 2, 3} + ms.SetMBucketCounts(testValMBucketCounts) + assert.EqualValues(t, testValMBucketCounts, ms.MBucketCounts()) } -func TestHistogramDataPoint_ExplicitBounds(t *testing.T) { +func TestHistogramDataPoint_MExplicitBounds(t *testing.T) { ms := NewHistogramDataPoint() - assert.EqualValues(t, []float64(nil), ms.ExplicitBounds()) - testValExplicitBounds := []float64{1, 2, 3} - ms.SetExplicitBounds(testValExplicitBounds) - assert.EqualValues(t, testValExplicitBounds, ms.ExplicitBounds()) + assert.EqualValues(t, []float64(nil), ms.MExplicitBounds()) + testValMExplicitBounds := []float64{1, 2, 3} + ms.SetMExplicitBounds(testValMExplicitBounds) + assert.EqualValues(t, testValMExplicitBounds, ms.MExplicitBounds()) } func TestHistogramDataPoint_Exemplars(t *testing.T) { @@ -1375,9 +1375,9 @@ func TestBuckets_CopyTo(t *testing.T) { orig = generateTestBuckets() orig.CopyTo(ms) assert.EqualValues(t, orig, ms) - orig.BucketCounts()[0] = 0 + orig.MBucketCounts()[0] = 0 assert.NotEqualValues(t, orig, ms) - orig.BucketCounts()[0] = []uint64{1, 2, 3}[0] + orig.MBucketCounts()[0] = []uint64{1, 2, 3}[0] assert.EqualValues(t, orig, ms) } @@ -1389,12 +1389,12 @@ func TestBuckets_Offset(t *testing.T) { assert.EqualValues(t, testValOffset, ms.Offset()) } -func TestBuckets_BucketCounts(t *testing.T) { +func TestBuckets_MBucketCounts(t *testing.T) { ms := NewBuckets() - assert.EqualValues(t, []uint64(nil), ms.BucketCounts()) - testValBucketCounts := []uint64{1, 2, 3} - ms.SetBucketCounts(testValBucketCounts) - assert.EqualValues(t, testValBucketCounts, ms.BucketCounts()) + assert.EqualValues(t, []uint64(nil), ms.MBucketCounts()) + testValMBucketCounts := []uint64{1, 2, 3} + ms.SetMBucketCounts(testValMBucketCounts) + assert.EqualValues(t, testValMBucketCounts, ms.MBucketCounts()) } func TestSummaryDataPointSlice(t *testing.T) { @@ -2091,8 +2091,8 @@ func fillTestHistogramDataPoint(tv HistogramDataPoint) { tv.SetTimestamp(Timestamp(1234567890)) tv.SetCount(uint64(17)) tv.SetSum(float64(17.13)) - tv.SetBucketCounts([]uint64{1, 2, 3}) - tv.SetExplicitBounds([]float64{1, 2, 3}) + tv.SetMBucketCounts([]uint64{1, 2, 3}) + tv.SetMExplicitBounds([]float64{1, 2, 3}) fillTestExemplarSlice(tv.Exemplars()) tv.SetFlags(MetricDataPointFlagsNone) } @@ -2139,7 +2139,7 @@ func generateTestBuckets() Buckets { func fillTestBuckets(tv Buckets) { tv.SetOffset(int32(909)) - tv.SetBucketCounts([]uint64{1, 2, 3}) + tv.SetMBucketCounts([]uint64{1, 2, 3}) } func generateTestSummaryDataPointSlice() SummaryDataPointSlice { diff --git a/pdata/internal/metrics.go b/pdata/internal/metrics.go index 1a032c0f716..75bbc39a384 100644 --- a/pdata/internal/metrics.go +++ b/pdata/internal/metrics.go @@ -284,3 +284,39 @@ func (ot OptionalType) String() string { } return "" } + +// BucketCounts returns the bucketcounts associated with this HistogramDataPoint. +// Deprecated: [0.51.0] Use MBucketCounts instead. +func (ms HistogramDataPoint) BucketCounts() []uint64 { + return ms.orig.BucketCounts +} + +// SetBucketCounts replaces the bucketcounts associated with this HistogramDataPoint. +// Deprecated: [0.51.0] Use SetMBucketCounts instead. +func (ms HistogramDataPoint) SetBucketCounts(v []uint64) { + ms.orig.BucketCounts = v +} + +// ExplicitBounds returns the explicitbounds associated with this HistogramDataPoint. +// Deprecated: [0.51.0] Use MExplicitBounds instead. +func (ms HistogramDataPoint) ExplicitBounds() []float64 { + return ms.orig.ExplicitBounds +} + +// SetExplicitBounds replaces the explicitbounds associated with this HistogramDataPoint. +// Deprecated: [0.51.0] Use SetMExplicitBounds instead. +func (ms HistogramDataPoint) SetExplicitBounds(v []float64) { + ms.orig.ExplicitBounds = v +} + +// BucketCounts returns the bucketcounts associated with this Buckets. +// Deprecated: [0.51.0] Use MBucketCounts instead. +func (ms Buckets) BucketCounts() []uint64 { + return ms.orig.BucketCounts +} + +// SetBucketCounts replaces the bucketcounts associated with this Buckets. +// Deprecated: [0.51.0] Use SetMBucketCounts instead. +func (ms Buckets) SetBucketCounts(v []uint64) { + ms.orig.BucketCounts = v +} diff --git a/pdata/internal/metrics_test.go b/pdata/internal/metrics_test.go index cbc6504d71a..01503603301 100644 --- a/pdata/internal/metrics_test.go +++ b/pdata/internal/metrics_test.go @@ -310,15 +310,15 @@ func TestOtlpToInternalReadOnly(t *testing.T) { // First point assert.EqualValues(t, startTime, histogramDataPoints.At(0).StartTimestamp()) assert.EqualValues(t, endTime, histogramDataPoints.At(0).Timestamp()) - assert.EqualValues(t, []float64{1, 2}, histogramDataPoints.At(0).ExplicitBounds()) + assert.EqualValues(t, []float64{1, 2}, histogramDataPoints.At(0).MExplicitBounds()) assert.EqualValues(t, NewMapFromRaw(map[string]interface{}{"key0": "value0"}), histogramDataPoints.At(0).Attributes()) - assert.EqualValues(t, []uint64{10, 15, 1}, histogramDataPoints.At(0).BucketCounts()) + assert.EqualValues(t, []uint64{10, 15, 1}, histogramDataPoints.At(0).MBucketCounts()) // Second point assert.EqualValues(t, startTime, histogramDataPoints.At(1).StartTimestamp()) assert.EqualValues(t, endTime, histogramDataPoints.At(1).Timestamp()) - assert.EqualValues(t, []float64{1}, histogramDataPoints.At(1).ExplicitBounds()) + assert.EqualValues(t, []float64{1}, histogramDataPoints.At(1).MExplicitBounds()) assert.EqualValues(t, NewMapFromRaw(map[string]interface{}{"key1": "value1"}), histogramDataPoints.At(1).Attributes()) - assert.EqualValues(t, []uint64{10, 1}, histogramDataPoints.At(1).BucketCounts()) + assert.EqualValues(t, []uint64{10, 1}, histogramDataPoints.At(1).MBucketCounts()) } func TestOtlpToFromInternalReadOnly(t *testing.T) { @@ -559,9 +559,9 @@ func TestOtlpToFromInternalHistogramMutating(t *testing.T) { histogramDataPoints.At(0).Attributes().Remove("key0") histogramDataPoints.At(0).Attributes().UpsertString("k", "v") assert.EqualValues(t, newAttributes, histogramDataPoints.At(0).Attributes()) - histogramDataPoints.At(0).SetExplicitBounds([]float64{1}) - assert.EqualValues(t, []float64{1}, histogramDataPoints.At(0).ExplicitBounds()) - histogramDataPoints.At(0).SetBucketCounts([]uint64{21, 32}) + histogramDataPoints.At(0).SetMExplicitBounds([]float64{1}) + assert.EqualValues(t, []float64{1}, histogramDataPoints.At(0).MExplicitBounds()) + histogramDataPoints.At(0).SetMBucketCounts([]uint64{21, 32}) // Test that everything is updated. assert.EqualValues(t, &otlpmetrics.MetricsData{ ResourceMetrics: []*otlpmetrics.ResourceMetrics{ diff --git a/pdata/ptrace/json_test.go b/pdata/ptrace/json_test.go index b02a10828ca..bfa2651bee3 100644 --- a/pdata/ptrace/json_test.go +++ b/pdata/ptrace/json_test.go @@ -95,7 +95,7 @@ var tracesOTLPFull = func() Traces { sp.Attributes().UpsertBool("bool", true) sp.Attributes().UpsertInt("int", 1) sp.Attributes().UpsertDouble("double", 1.1) - sp.Attributes().UpsertBytes("bytes", []byte("foo")) + sp.Attributes().UpsertMBytes("bytes", []byte("foo")) arr := internal.NewValueSlice() arr.SliceVal().AppendEmpty().SetIntVal(1) arr.SliceVal().AppendEmpty().SetStringVal("str") @@ -113,7 +113,7 @@ var tracesOTLPFull = func() Traces { event.Attributes().UpsertBool("bool", true) event.Attributes().UpsertInt("int", 1) event.Attributes().UpsertDouble("double", 1.1) - event.Attributes().UpsertBytes("bytes", []byte("foo")) + event.Attributes().UpsertMBytes("bytes", []byte("foo")) // Add links. link := sp.Links().AppendEmpty() link.SetTraceState("state") @@ -124,7 +124,7 @@ var tracesOTLPFull = func() Traces { link.Attributes().UpsertBool("bool", true) link.Attributes().UpsertInt("int", 1) link.Attributes().UpsertDouble("double", 1.1) - link.Attributes().UpsertBytes("bytes", []byte("foo")) + link.Attributes().UpsertMBytes("bytes", []byte("foo")) // Add another span. sp2 := il.Spans().AppendEmpty() sp2.SetName("testSpan2")