Skip to content

Commit

Permalink
Remove deprecated funcs from pdata related to mutable slices (#5754)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu authored Jul 27, 2022
1 parent 06599bc commit 73b7320
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 117 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### 🛑 Breaking changes 🛑

- Change`confighttp.ToClient` to accept a `component.Host` (#5737)
- Remove deprecated funcs from pdata related to mutable slices (#5754)

### 🚩 Deprecations 🚩

Expand Down
63 changes: 0 additions & 63 deletions pdata/internal/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,6 @@ func NewValueSlice() Value {
return Value{orig: &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_ArrayValue{ArrayValue: &otlpcommon.ArrayValue{}}}}
}

// NewValueMBytes creates a new Value with the given []byte value.
// 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.54.0] Use NewValueBytes instead.
func NewValueMBytes(v []byte) Value {
return Value{orig: &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_BytesValue{BytesValue: v}}}
}

// NewValueBytes creates a new Value with the given ImmutableByteSlice value.
func NewValueBytes(v ImmutableByteSlice) Value {
return Value{orig: &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_BytesValue{BytesValue: v.value}}}
Expand Down Expand Up @@ -264,15 +256,6 @@ func (v Value) SliceVal() Slice {
return newSlice(&arr.Values)
}

// MBytesVal returns the []byte value associated with this Value.
// If the Type() is not ValueTypeBytes then returns an empty slice.
// Calling this function on zero-initialized Value will cause a panic.
// Modifying the returned []byte in-place is forbidden.
// Deprecated: [0.54.0] Use BytesVal() instead.
func (v Value) MBytesVal() []byte {
return v.orig.GetBytesValue()
}

// BytesVal returns the ImmutableByteSlice value associated with this Value.
// If the Type() is not ValueTypeBytes then returns an empty slice.
// Calling this function on zero-initialized Value will cause a panic.
Expand Down Expand Up @@ -308,16 +291,6 @@ func (v Value) SetBoolVal(bv bool) {
v.orig.Value = &otlpcommon.AnyValue_BoolValue{BoolValue: 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.
// Deprecated: [0.54.0] Use SetBytesVal() instead.
func (v Value) SetMBytesVal(bv []byte) {
v.orig.Value = &otlpcommon.AnyValue_BytesValue{BytesValue: bv}
}

// SetBytesVal replaces the ImmutableByteSlice value associated with this Value,
// it also changes the type to be ValueTypeBytes.
// Calling this function on zero-initialized Value will cause a panic.
Expand Down Expand Up @@ -727,17 +700,6 @@ func (m Map) InsertBool(k string, v bool) {
}
}

// 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.
// Deprecated: [0.54.0] Use InsertBytes instead.
func (m Map) InsertMBytes(k string, v []byte) {
if _, existing := m.Get(k); !existing {
*m.orig = append(*m.orig, newAttributeKeyValueBytes(k, ImmutableByteSlice{value: v}))
}
}

// InsertBytes adds the ImmutableByteSlice Value to the map when the key does not exist.
// No action is applied to the map where the key already exists.
func (m Map) InsertBytes(k string, v ImmutableByteSlice) {
Expand Down Expand Up @@ -791,17 +753,6 @@ func (m Map) UpdateBool(k string, v bool) {
}
}

// 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.
// Deprecated: [0.54.0] Use UpdateBytes instead.
func (m Map) UpdateMBytes(k string, v []byte) {
if av, existing := m.Get(k); existing {
av.SetBytesVal(ImmutableByteSlice{value: v})
}
}

// UpdateBytes updates an existing ImmutableByteSlice Value with a value.
// No action is applied to the map where the key does not exist.
func (m Map) UpdateBytes(k string, v ImmutableByteSlice) {
Expand Down Expand Up @@ -870,20 +821,6 @@ func (m Map) UpsertBool(k string, v bool) {
}
}

// 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.
// Deprecated: [0.54.0] Use UpsertBytes instead.
func (m Map) UpsertMBytes(k string, v []byte) {
if av, existing := m.Get(k); existing {
av.SetBytesVal(ImmutableByteSlice{value: v})
} else {
*m.orig = append(*m.orig, newAttributeKeyValueBytes(k, ImmutableByteSlice{value: v}))
}
}

// UpsertBytes performs the Insert or Update action. The ImmutableByteSlice 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.
Expand Down
12 changes: 0 additions & 12 deletions pdata/internal/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,18 +662,6 @@ func TestAttributeValue_copyTo(t *testing.T) {
assert.EqualValues(t, nil, destVal.Value)
}

func TestValueBytes_CopyTo_Deprecated(t *testing.T) {
orig := NewValueMBytes([]byte{1, 2, 3})
dest := NewValueEmpty()
orig.CopyTo(dest)
assert.Equal(t, orig, dest)

orig.MBytesVal()[0] = 10
assert.NotEqual(t, orig, dest)
assert.Equal(t, []byte{1, 2, 3}, dest.MBytesVal())
assert.Equal(t, []byte{10, 2, 3}, orig.MBytesVal())
}

func TestMap_Update(t *testing.T) {
origWithNil := []otlpcommon.KeyValue{
{
Expand Down
36 changes: 0 additions & 36 deletions pdata/internal/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,39 +284,3 @@ func (ot OptionalType) String() string {
}
return ""
}

// MBucketCounts returns the bucketcounts associated with this HistogramDataPoint.
// Deprecated: [0.54.0] Use BucketCounts instead.
func (ms HistogramDataPoint) MBucketCounts() []uint64 {
return ms.orig.BucketCounts
}

// SetMBucketCounts replaces the bucketcounts associated with this HistogramDataPoint.
// Deprecated: [0.54.0] Use SetBucketCounts instead.
func (ms HistogramDataPoint) SetMBucketCounts(v []uint64) {
ms.orig.BucketCounts = v
}

// MExplicitBounds returns the explicitbounds associated with this HistogramDataPoint.
// Deprecated: [0.54.0] Use ExplicitBounds instead.
func (ms HistogramDataPoint) MExplicitBounds() []float64 {
return ms.orig.ExplicitBounds
}

// SetMExplicitBounds replaces the explicitbounds associated with this HistogramDataPoint.
// Deprecated: [0.54.0] Use SetExplicitBounds instead.
func (ms HistogramDataPoint) SetMExplicitBounds(v []float64) {
ms.orig.ExplicitBounds = v
}

// MBucketCounts returns the bucketcounts associated with this Buckets.
// Deprecated: [0.54.0] Use BucketCounts instead.
func (ms Buckets) MBucketCounts() []uint64 {
return ms.orig.BucketCounts
}

// SetMBucketCounts replaces the bucketcounts associated with this Buckets.
// Deprecated: [0.54.0] Use SetBucketCounts instead.
func (ms Buckets) SetMBucketCounts(v []uint64) {
ms.orig.BucketCounts = v
}
6 changes: 0 additions & 6 deletions pdata/pcommon/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ var (

// NewValueBytes creates a new Value with the given ImmutableByteSlice value.
NewValueBytes = internal.NewValueBytes

// NewValueMBytes creates a new Value with the given []byte value.
// 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.54.0] Use NewValueBytes instead.
NewValueMBytes = internal.NewValueMBytes
)

// Map stores a map of string keys to elements of Value type.
Expand Down

0 comments on commit 73b7320

Please sign in to comment.