diff --git a/CHANGELOG.md b/CHANGELOG.md index 01a03282006..3e296ab9370 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ - Remove `configunmarshaler.Unmarshaler` interface, per deprecation comment (#5348) - Remove deprecated pdata funcs/structs from v0.50.0 (#5345) +- Remove deprecated pdata getters and setters of primitive slice values: `Value.BytesVal`, `Value.SetBytesVal`, + `Value.UpdateBytes`, `Value.InsertBytes`, `Value.UpsertBytes`, `.BucketCounts`, + `.SetBucketCounts`, `HistogramDataPoint.ExplicitBounds`, + `HistogramDataPoint.SetExplicitBounds` (#5347) - Remove derecated featuregate funcs/structs from v0.50.0 (#5346) - Remove access to deprecated members of the config.Retrieved struct (#5363) diff --git a/pdata/internal/common.go b/pdata/internal/common.go index bc231c02e00..d4800bd1439 100644 --- a/pdata/internal/common.go +++ b/pdata/internal/common.go @@ -258,15 +258,6 @@ func (v Value) SliceVal() Slice { return newSlice(&arr.Values) } -// BytesVal 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. -// 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. @@ -303,16 +294,6 @@ func (v Value) SetBoolVal(bv bool) { v.orig.Value = &otlpcommon.AnyValue_BoolValue{BoolValue: bv} } -// SetBytesVal 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. -// 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. @@ -464,7 +445,7 @@ func (v Value) AsString() string { return string(jsonStr) case ValueTypeBytes: - return base64.StdEncoding.EncodeToString(v.BytesVal()) + return base64.StdEncoding.EncodeToString(v.MBytesVal()) case ValueTypeSlice: jsonStr, _ := json.Marshal(v.SliceVal().AsRaw()) @@ -519,7 +500,7 @@ func (v Value) asRaw() interface{} { case ValueTypeInt: return v.IntVal() case ValueTypeBytes: - return v.BytesVal() + return v.MBytesVal() case ValueTypeMap: return v.MapVal().AsRaw() case ValueTypeSlice: @@ -570,7 +551,7 @@ func newAttributeKeyValue(k string, av Value) otlpcommon.KeyValue { func newAttributeKeyValueBytes(k string, v []byte) otlpcommon.KeyValue { orig := otlpcommon.KeyValue{Key: k} akv := Value{&orig.Value} - akv.SetBytesVal(v) + akv.SetMBytesVal(v) return orig } @@ -724,17 +705,6 @@ func (m Map) InsertBool(k string, v bool) { } } -// InsertBytes 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. -// 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 @@ -790,17 +760,6 @@ func (m Map) UpdateBool(k string, v bool) { } } -// UpdateBytes 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. -// Deprecated: [0.51.0] Use UpdateMBytes instead. -func (m Map) UpdateBytes(k string, v []byte) { - if av, existing := m.Get(k); existing { - 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 @@ -871,20 +830,6 @@ func (m Map) UpsertBool(k string, v bool) { } } -// UpsertBytes 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. -// Deprecated: [0.51.0] Use UpsertMBytes instead. -func (m Map) UpsertBytes(k string, v []byte) { - if av, existing := m.Get(k); existing { - 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. diff --git a/pdata/internal/common_test.go b/pdata/internal/common_test.go index 290bff5cbe2..10680b7db6e 100644 --- a/pdata/internal/common_test.go +++ b/pdata/internal/common_test.go @@ -66,7 +66,7 @@ func TestAttributeValue(t *testing.T) { bytesValue := []byte{1, 2, 3, 4} v = NewValueBytes(bytesValue) assert.EqualValues(t, ValueTypeBytes, v.Type()) - assert.EqualValues(t, bytesValue, v.BytesVal()) + assert.EqualValues(t, bytesValue, v.MBytesVal()) } func TestAttributeValueType(t *testing.T) { @@ -175,8 +175,8 @@ func TestNilOrigSetAttributeValue(t *testing.T) { assert.EqualValues(t, 1.23, av.DoubleVal()) av = NewValueEmpty() - av.SetBytesVal([]byte{1, 2, 3}) - assert.Equal(t, []byte{1, 2, 3}, av.BytesVal()) + av.SetMBytesVal([]byte{1, 2, 3}) + assert.Equal(t, []byte{1, 2, 3}, av.MBytesVal()) } func TestAttributeValueEqual(t *testing.T) { @@ -416,7 +416,7 @@ func TestMapWithEmpty(t *testing.T) { val, exist = sm.Get("other_key_bytes") assert.True(t, exist) assert.EqualValues(t, ValueTypeBytes, val.Type()) - assert.EqualValues(t, []byte{1, 2, 3}, val.BytesVal()) + assert.EqualValues(t, []byte{1, 2, 3}, val.MBytesVal()) sm.Update("other_key", NewValueString("yet_another_value")) val, exist = sm.Get("other_key") @@ -452,7 +452,7 @@ func TestMapWithEmpty(t *testing.T) { val, exist = sm.Get("other_key_bytes") assert.True(t, exist) assert.EqualValues(t, ValueTypeBytes, val.Type()) - assert.EqualValues(t, []byte{4, 5, 6}, val.BytesVal()) + assert.EqualValues(t, []byte{4, 5, 6}, val.MBytesVal()) sm.Upsert("other_key", NewValueString("other_value")) val, exist = sm.Get("other_key") @@ -488,7 +488,7 @@ func TestMapWithEmpty(t *testing.T) { val, exist = sm.Get("other_key_bytes") assert.True(t, exist) assert.EqualValues(t, ValueTypeBytes, val.Type()) - assert.EqualValues(t, []byte{7, 8, 9}, val.BytesVal()) + assert.EqualValues(t, []byte{7, 8, 9}, val.MBytesVal()) sm.Upsert("yet_another_key", NewValueString("yet_another_value")) val, exist = sm.Get("yet_another_key") @@ -524,7 +524,7 @@ func TestMapWithEmpty(t *testing.T) { val, exist = sm.Get("yet_another_key_bytes") assert.True(t, exist) assert.EqualValues(t, ValueTypeBytes, val.Type()) - assert.EqualValues(t, []byte{1}, val.BytesVal()) + assert.EqualValues(t, []byte{1}, val.MBytesVal()) assert.True(t, sm.Remove("other_key")) assert.True(t, sm.Remove("other_key_string")) @@ -669,10 +669,10 @@ func TestValueBytes_CopyTo(t *testing.T) { orig.CopyTo(dest) assert.Equal(t, orig, dest) - orig.BytesVal()[0] = 10 + orig.MBytesVal()[0] = 10 assert.NotEqual(t, orig, dest) - assert.Equal(t, []byte{1, 2, 3}, dest.BytesVal()) - assert.Equal(t, []byte{10, 2, 3}, orig.BytesVal()) + assert.Equal(t, []byte{1, 2, 3}, dest.MBytesVal()) + assert.Equal(t, []byte{10, 2, 3}, orig.MBytesVal()) } func TestMap_Update(t *testing.T) { diff --git a/pdata/internal/metrics.go b/pdata/internal/metrics.go index 75bbc39a384..1a032c0f716 100644 --- a/pdata/internal/metrics.go +++ b/pdata/internal/metrics.go @@ -284,39 +284,3 @@ 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 -}