Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated NewAttributeValue, update pdatagen to avoid using it #2962

Merged
merged 1 commit into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions cmd/pdatagen/internal/base_slices.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const slicePtrTestTemplate = `func Test${structName}(t *testing.T) {
assert.EqualValues(t, 0, es.Len())

es.Resize(7)
emptyVal := New${elementName}()
emptyVal := new${elementName}(&${originName}{})
testVal := generateTest${elementName}()
assert.EqualValues(t, 7, es.Len())
for i := 0; i < es.Len(); i++ {
Expand Down Expand Up @@ -192,7 +192,7 @@ func Test${structName}_CopyTo(t *testing.T) {

func Test${structName}_Resize(t *testing.T) {
es := generateTest${structName}()
emptyVal := New${elementName}()
emptyVal := new${elementName}(&${originName}{})
// Test Resize less elements.
const resizeSmallLen = 4
expectedEs := make(map[*${originName}]bool, resizeSmallLen)
Expand Down Expand Up @@ -235,12 +235,11 @@ func Test${structName}_Resize(t *testing.T) {
func Test${structName}_Append(t *testing.T) {
es := generateTest${structName}()

emptyVal := New${elementName}()
emptyVal := new${elementName}(&${originName}{})
es.Append(emptyVal)
assert.EqualValues(t, emptyVal.orig, es.At(7).orig)

value := New${elementName}()
fillTest${elementName}(value)
value := generateTest${elementName}()
es.Append(value)
assert.EqualValues(t, value.orig, es.At(8).orig)

Expand Down Expand Up @@ -376,7 +375,7 @@ const sliceValueTestTemplate = `func Test${structName}(t *testing.T) {
assert.EqualValues(t, 0, es.Len())

es.Resize(7)
emptyVal := New${elementName}()
emptyVal := new${elementName}(&${originName}{})
testVal := generateTest${elementName}()
assert.EqualValues(t, 7, es.Len())
for i := 0; i < es.Len(); i++ {
Expand Down Expand Up @@ -428,7 +427,7 @@ func Test${structName}_CopyTo(t *testing.T) {

func Test${structName}_Resize(t *testing.T) {
es := generateTest${structName}()
emptyVal := New${elementName}()
emptyVal := new${elementName}(&${originName}{})
// Test Resize less elements.
const resizeSmallLen = 4
expectedEs := make(map[*${originName}]bool, resizeSmallLen)
Expand Down Expand Up @@ -471,12 +470,11 @@ func Test${structName}_Resize(t *testing.T) {
func Test${structName}_Append(t *testing.T) {
es := generateTest${structName}()

emptyVal := New${elementName}()
emptyVal := new${elementName}(&${originName}{})
es.Append(emptyVal)
assert.EqualValues(t, emptyVal, es.At(7))

value := New${elementName}()
fillTest${elementName}(value)
value := generateTest${elementName}()
es.Append(value)
assert.EqualValues(t, value, es.At(8))

Expand Down
27 changes: 7 additions & 20 deletions consumer/pdata/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,50 +82,37 @@ func newAttributeValue(orig *otlpcommon.AnyValue) AttributeValue {

// NewAttributeValueNull creates a new AttributeValue with a null value.
func NewAttributeValueNull() AttributeValue {
orig := &otlpcommon.AnyValue{}
return AttributeValue{orig: orig}
}

// NewAttributeValue is deprecated.
// Deprecated: Use NewAttributeValueNull()
func NewAttributeValue() AttributeValue {
return NewAttributeValueNull()
return AttributeValue{orig: &otlpcommon.AnyValue{}}
}

// NewAttributeValueString creates a new AttributeValue with the given string value.
func NewAttributeValueString(v string) AttributeValue {
orig := &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: v}}
return AttributeValue{orig: orig}
return AttributeValue{orig: &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_StringValue{StringValue: v}}}
}

// NewAttributeValueInt creates a new AttributeValue with the given int64 value.
func NewAttributeValueInt(v int64) AttributeValue {
orig := &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_IntValue{IntValue: v}}
return AttributeValue{orig: orig}
return AttributeValue{orig: &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_IntValue{IntValue: v}}}
}

// NewAttributeValueDouble creates a new AttributeValue with the given float64 value.
func NewAttributeValueDouble(v float64) AttributeValue {
orig := &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_DoubleValue{DoubleValue: v}}
return AttributeValue{orig: orig}
return AttributeValue{orig: &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_DoubleValue{DoubleValue: v}}}
}

// NewAttributeValueBool creates a new AttributeValue with the given bool value.
func NewAttributeValueBool(v bool) AttributeValue {
orig := &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_BoolValue{BoolValue: v}}
return AttributeValue{orig: orig}
return AttributeValue{orig: &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_BoolValue{BoolValue: v}}}
}

// NewAttributeValueMap creates a new AttributeValue of map type.
func NewAttributeValueMap() AttributeValue {
orig := &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_KvlistValue{KvlistValue: &otlpcommon.KeyValueList{}}}
return AttributeValue{orig: orig}
return AttributeValue{orig: &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_KvlistValue{KvlistValue: &otlpcommon.KeyValueList{}}}}
}

// NewAttributeValueArray creates a new AttributeValue of array type.
func NewAttributeValueArray() AttributeValue {
orig := &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_ArrayValue{ArrayValue: &otlpcommon.ArrayValue{}}}
return AttributeValue{orig: orig}
return AttributeValue{orig: &otlpcommon.AnyValue{Value: &otlpcommon.AnyValue_ArrayValue{ArrayValue: &otlpcommon.ArrayValue{}}}}
}

// Type returns the type of the value for this AttributeValue.
Expand Down
9 changes: 4 additions & 5 deletions consumer/pdata/generated_common_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 12 additions & 15 deletions consumer/pdata/generated_log_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading