Skip to content

Commit

Permalink
Canonicalize enum names in pdata. Fix usage of uppercase names (#3208)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu authored May 17, 2021
1 parent a19d6ce commit ff91f42
Show file tree
Hide file tree
Showing 28 changed files with 257 additions and 257 deletions.
4 changes: 2 additions & 2 deletions cmd/pdatagen/internal/trace_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ var span = &messageValueStruct{
originFieldName: "Kind",
returnType: "SpanKind",
rawType: "otlptrace.Span_SpanKind",
defaultVal: "SpanKindUNSPECIFIED",
testVal: "SpanKindSERVER",
defaultVal: "SpanKindUnspecified",
testVal: "SpanKindServer",
},
startTimeField,
endTimeField,
Expand Down
68 changes: 34 additions & 34 deletions consumer/pdata/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,30 @@ import (
type AttributeValueType int32

const (
AttributeValueNULL AttributeValueType = iota
AttributeValueSTRING
AttributeValueINT
AttributeValueDOUBLE
AttributeValueBOOL
AttributeValueMAP
AttributeValueARRAY
AttributeValueTypeNull AttributeValueType = iota
AttributeValueTypeString
AttributeValueTypeInt
AttributeValueTypeDouble
AttributeValueTypeBool
AttributeValueTypeMap
AttributeValueTypeArray
)

func (avt AttributeValueType) String() string {
switch avt {
case AttributeValueNULL:
case AttributeValueTypeNull:
return "NULL"
case AttributeValueSTRING:
case AttributeValueTypeString:
return "STRING"
case AttributeValueBOOL:
case AttributeValueTypeBool:
return "BOOL"
case AttributeValueINT:
case AttributeValueTypeInt:
return "INT"
case AttributeValueDOUBLE:
case AttributeValueTypeDouble:
return "DOUBLE"
case AttributeValueMAP:
case AttributeValueTypeMap:
return "MAP"
case AttributeValueARRAY:
case AttributeValueTypeArray:
return "ARRAY"
}
return ""
Expand All @@ -67,7 +67,7 @@ func (avt AttributeValueType) String() string {
// function f2() {
// v := NewAttributeValueString("a string")
// f1(v)
// _ := v.Type() // this will return AttributeValueINT
// _ := v.Type() // this will return AttributeValueTypeInt
// }
//
// Important: zero-initialized instance is not valid for use. All AttributeValue functions bellow must
Expand Down Expand Up @@ -119,55 +119,55 @@ func NewAttributeValueArray() AttributeValue {
// Calling this function on zero-initialized AttributeValue will cause a panic.
func (a AttributeValue) Type() AttributeValueType {
if a.orig.Value == nil {
return AttributeValueNULL
return AttributeValueTypeNull
}
switch a.orig.Value.(type) {
case *otlpcommon.AnyValue_StringValue:
return AttributeValueSTRING
return AttributeValueTypeString
case *otlpcommon.AnyValue_BoolValue:
return AttributeValueBOOL
return AttributeValueTypeBool
case *otlpcommon.AnyValue_IntValue:
return AttributeValueINT
return AttributeValueTypeInt
case *otlpcommon.AnyValue_DoubleValue:
return AttributeValueDOUBLE
return AttributeValueTypeDouble
case *otlpcommon.AnyValue_KvlistValue:
return AttributeValueMAP
return AttributeValueTypeMap
case *otlpcommon.AnyValue_ArrayValue:
return AttributeValueARRAY
return AttributeValueTypeArray
}
return AttributeValueNULL
return AttributeValueTypeNull
}

// StringVal returns the string value associated with this AttributeValue.
// If the Type() is not AttributeValueSTRING then returns empty string.
// If the Type() is not AttributeValueTypeString then returns empty string.
// Calling this function on zero-initialized AttributeValue will cause a panic.
func (a AttributeValue) StringVal() string {
return a.orig.GetStringValue()
}

// IntVal returns the int64 value associated with this AttributeValue.
// If the Type() is not AttributeValueINT then returns int64(0).
// If the Type() is not AttributeValueTypeInt then returns int64(0).
// Calling this function on zero-initialized AttributeValue will cause a panic.
func (a AttributeValue) IntVal() int64 {
return a.orig.GetIntValue()
}

// DoubleVal returns the float64 value associated with this AttributeValue.
// If the Type() is not AttributeValueDOUBLE then returns float64(0).
// If the Type() is not AttributeValueTypeDouble then returns float64(0).
// Calling this function on zero-initialized AttributeValue will cause a panic.
func (a AttributeValue) DoubleVal() float64 {
return a.orig.GetDoubleValue()
}

// BoolVal returns the bool value associated with this AttributeValue.
// If the Type() is not AttributeValueBOOL then returns false.
// If the Type() is not AttributeValueTypeBool then returns false.
// Calling this function on zero-initialized AttributeValue will cause a panic.
func (a AttributeValue) BoolVal() bool {
return a.orig.GetBoolValue()
}

// MapVal returns the map value associated with this AttributeValue.
// If the Type() is not AttributeValueMAP then returns an empty map. Note that modifying
// If the Type() is not AttributeValueTypeMap then returns an empty map. Note that modifying
// such empty map has no effect on this AttributeValue.
//
// Calling this function on zero-initialized AttributeValue will cause a panic.
Expand All @@ -180,7 +180,7 @@ func (a AttributeValue) MapVal() AttributeMap {
}

// ArrayVal returns the array value associated with this AttributeValue.
// If the Type() is not AttributeValueARRAY then returns an empty array. Note that modifying
// If the Type() is not AttributeValueTypeArray then returns an empty array. Note that modifying
// such empty array has no effect on this AttributeValue.
//
// Calling this function on zero-initialized AttributeValue will cause a panic.
Expand All @@ -193,28 +193,28 @@ func (a AttributeValue) ArrayVal() AnyValueArray {
}

// SetStringVal replaces the string value associated with this AttributeValue,
// it also changes the type to be AttributeValueSTRING.
// it also changes the type to be AttributeValueTypeString.
// Calling this function on zero-initialized AttributeValue will cause a panic.
func (a AttributeValue) SetStringVal(v string) {
a.orig.Value = &otlpcommon.AnyValue_StringValue{StringValue: v}
}

// SetIntVal replaces the int64 value associated with this AttributeValue,
// it also changes the type to be AttributeValueINT.
// it also changes the type to be AttributeValueTypeInt.
// Calling this function on zero-initialized AttributeValue will cause a panic.
func (a AttributeValue) SetIntVal(v int64) {
a.orig.Value = &otlpcommon.AnyValue_IntValue{IntValue: v}
}

// SetDoubleVal replaces the float64 value associated with this AttributeValue,
// it also changes the type to be AttributeValueDOUBLE.
// it also changes the type to be AttributeValueTypeDouble.
// Calling this function on zero-initialized AttributeValue will cause a panic.
func (a AttributeValue) SetDoubleVal(v float64) {
a.orig.Value = &otlpcommon.AnyValue_DoubleValue{DoubleValue: v}
}

// SetBoolVal replaces the bool value associated with this AttributeValue,
// it also changes the type to be AttributeValueBOOL.
// it also changes the type to be AttributeValueTypeBool.
// Calling this function on zero-initialized AttributeValue will cause a panic.
func (a AttributeValue) SetBoolVal(v bool) {
a.orig.Value = &otlpcommon.AnyValue_BoolValue{BoolValue: v}
Expand Down Expand Up @@ -289,7 +289,7 @@ func (a AttributeValue) Equal(av AttributeValue) bool {
av := newAttributeValue(&vv[i])

// According to the specification, array values must be scalar.
if avType := av.Type(); avType == AttributeValueARRAY || avType == AttributeValueMAP {
if avType := av.Type(); avType == AttributeValueTypeArray || avType == AttributeValueTypeMap {
return false
}

Expand Down
Loading

0 comments on commit ff91f42

Please sign in to comment.