From 3bbc91968ac106a1b9ddbf2131dd46af58337e7d Mon Sep 17 00:00:00 2001 From: Tigran Najaryan Date: Mon, 8 Jun 2020 18:09:24 -0400 Subject: [PATCH] Add support for arrays and maps for attribute values ## Summary This adds support for arrays and maps to attribute values, including support for nested values. This is a breaking protocol change. Resolves: https://github.com/open-telemetry/opentelemetry-specification/issues/376 Resolves: https://github.com/open-telemetry/opentelemetry-proto/issues/106 ## Motivation There are several reasons for this change: - The API defines that attributes values [may contain arrays of values](https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/api.md#set-attributes). However the protocol has no way of representing array values. We need to add such capability. - We intend to support Log data type in the protocol, which also requires array values (it is a Log Data Model requirement). In addition, Log data type requires support of key-value lists (maps) as attribute values, including nested values. - There are long-standing requests to support nested values, arrays and maps for attributes: https://github.com/open-telemetry/opentelemetry-specification/issues/376 https://github.com/open-telemetry/opentelemetry-specification/pull/596 This change introduces AnyValue. AnyValue can represent arbitrary numeric, boolean, string, arrays or maps of values and allows nesting. AnyValue can represent any data that can be represented in JSON. AttributeKeyValue now uses AnyValue to store the "value" part. Note: below "Current" refers to the state of the "master" branch before this PR/commit is merged. "Proposed" refers to the schema suggested in this PR/commit. ## Performance This change has a negative impact on the performance when using canonical Go ProtoBuf compiler (compared to current OTLP state): ``` BenchmarkEncode/Current/Trace/Attribs-8 813 1479588 ns/op BenchmarkEncode/Proposed/Trace/Attribs-8 417 2873476 ns/op BenchmarkEncode/OpenCensus/Trace/Attribs-8 162 7354799 ns/op BenchmarkDecode/Current/Trace/Attribs-8 460 2646059 ns/op 1867627 B/op 36201 allocs/op BenchmarkDecode/Proposed/Trace/Attribs-8 246 4827671 ns/op 2171734 B/op 56209 allocs/op BenchmarkDecode/OpenCensus/Trace/Attribs-8 154 7560952 ns/op 2775949 B/op 76166 allocs/op ``` However, I do not think this is important for most applications. Serialization CPU and Memory usage is going to be a tiny portion of consumed resources for most applications, except certain specialized ones. For the perspective I am also showing OpenCensus in the benchmark to make it clear that we are still significantly faster than it despite becoming slower compared to the current state. More importantly, performance critical applications can use Gogo ProtoBuf compiler (Collector does use it), which _gains_ performance due to this change: ``` BenchmarkEncode/Current(Gogo)/Trace/Attribs-8 1645 705385 ns/op BenchmarkEncode/Proposed(Gogo)/Trace/Attribs-8 1555 698771 ns/op BenchmarkDecode/Current(Gogo)/Trace/Attribs-8 537 2241570 ns/op 2139634 B/op 36201 allocs/op BenchmarkDecode/Proposed(Gogo)/Trace/Attribs-8 600 2053120 ns/op 1323287 B/op 46205 allocs/op ``` With Gogo compiler proposed approach uses 40% less memory than the current schema. After considering all tradeoffs and alternates (see below) I believe this proposal is the best overall approach for OTLP. It is idiomatic ProtoBuf, easy to read and understand, is future-proof to adding new attribute types, has enough flexibility to represent simple and complex attribute values for all telemetry types and can be made fast by custom code generation for applications where it matters using Gogo ProtoBuf compiler. Note: all performance measurements are done for Go implementation only (although it is expected that other languages should exhibit somewhat similar behavior). ## Alternates Considered I also designed and benchmarked several alternate schemas, see below. ### Adding array value to AttributeKeyValue This is the simplest approach. It doubles down on the current OTLP protocol approach and simply adds "array_values" field to AttributeKeyValue, e.g.: ```proto message AttributeKeyValue { // all existing fields here. // A list of values. "key" field of each element in the list is ignored. repeated AttributeKeyValue array_values = 7; } ``` This eliminates the need to have a separate AnyValue message and has lower CPU usage because it requires less indirections and less memory allocations per value. However, this is semantically incorrect since the elements of the array must actually be values not key-value pairs, which this schema violates. It also uses more memory than the proposed approach: ```proto BenchmarkEncode/Proposed/Trace/Attribs-8 400 2869055 ns/op BenchmarkEncode/MoreFieldsinAKV/Trace/Attribs-8 754 1540978 ns/op BenchmarkDecode/Proposed/Trace/Attribs-8 250 4790010 ns/op 2171741 B/op 56209 allocs/op BenchmarkDecode/MoreFieldsinAKV/Trace/Attribs-8 420 2806918 ns/op 2347827 B/op 36201 allocs/op ``` It will become even worse memory-wise if in the future we need to add more data types to attributes. This approach is not scalable for future needs and is semantically wrong. ### Fat AnyValue instead of oneof. In this approach AnyValue contains all possible field values (similarly to how AttributeKeyValue is currently): ```proto message AnyValue { ValueType type = 1; bool bool_value = 2; string string_value = 3; int64 int_value = 4; double double_value = 5; repeated AnyValue list_values = 6; repeated AttributeKeyValue kvlist_values = 7; } message AttributeKeyValue { string key = 1; AnyValue value = 2; } ``` This results in significantly bigger AnyValue in-memory. In vast majority of cases attribute values of produced telemetry are strings (see e.g. semantic conventions for proof). Integer and boolean values are also used, although significantly less frequently than strings. Floating point number, arrays and maps are likely going to be diminishingly rare in the attributes. If we keep all these value types in AnyValue we will pay the cost for all these fields although almost always only string value would be present. Here are benchmarks comparing proposed schema and schema with fat AnyValue and using string and integer attributes in spans: ``` BenchmarkEncode/Proposed/Trace/Attribs-8 415 2894513 ns/op 456866 B/op 10005 allocs/op BenchmarkEncode/FatAnyValue/Trace/Attribs-8 646 1885003 ns/op 385024 B/op 1 allocs/op BenchmarkDecode/Proposed/Trace/Attribs-8 247 4872270 ns/op 2171746 B/op 56209 allocs/op BenchmarkDecode/FatAnyValue/Trace/Attribs-8 343 3423494 ns/op 2988081 B/op 46205 allocs/op ``` Memory usage with this approach is much higher and it also will become worse as we add more types. ### AnyValue plus ExoticValue This is based on fat AnyValue approach but rarely used value types are moved to a separate ExoticValue message that may be referenced from AnyValue if needed: ```proto message AnyValue { ValueType type = 1; bool bool_value = 2; string string_value = 3; int64 int_value = 4; ExoticValue exotic_value = 5; } message ExoticValue { double double_value = 1; repeated AnyValue array_values = 2; repeated AttributeKeyValue kvlist_values = 3; } message AttributeKeyValue { string key = 1; AnyValue value = 2; } ``` While this improves the performance (particularly lowers memory usage for most frequently used types of attributes) it is awkward and sacrifices too much readability and usability for small performance gains. Also for the rare cases it is slow and uses even more memory so its edge case behavior is not desirable. ### Using different schema for log data type I also considered using a different message definition for LogRecord attributes and Spans. This would allow to eliminate some of the requirements that we do not yet formally have for Span attributes (particularly the need to have maps of nested values). However, this does not help much in terms of performance, makes Span and LogRecord attributes non-interchangeable and significantly increases the bloat of code in applications that need to work with both Spans and Log records. --- gen/go/common/v1/common.pb.go | 354 +++++++++++++++------ opentelemetry/proto/common/v1/common.proto | 48 +-- 2 files changed, 288 insertions(+), 114 deletions(-) diff --git a/gen/go/common/v1/common.pb.go b/gen/go/common/v1/common.pb.go index 3930f913..e934278b 100644 --- a/gen/go/common/v1/common.pb.go +++ b/gen/go/common/v1/common.pb.go @@ -20,59 +20,248 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package -// ValueType is the enumeration of possible types that value can have. -type AttributeKeyValue_ValueType int32 - -const ( - AttributeKeyValue_STRING AttributeKeyValue_ValueType = 0 - AttributeKeyValue_INT AttributeKeyValue_ValueType = 1 - AttributeKeyValue_DOUBLE AttributeKeyValue_ValueType = 2 - AttributeKeyValue_BOOL AttributeKeyValue_ValueType = 3 -) +// AnyValue is used to represent any type of attribute value. AnyValue may contain a +// primitive value such as a string or integer or it may contain an arbitrary nested +// object containing arrays, key-value lists and primitives. AnyValue can represent +// any data that JSON can represent. +type AnyValue struct { + // The value is one of the listed fields. It is valid for all values to be unspecified + // in which case this AnyValue is considered to be "null". + // + // Types that are valid to be assigned to Value: + // *AnyValue_StringValue + // *AnyValue_BoolValue + // *AnyValue_IntValue + // *AnyValue_DoubleValue + // *AnyValue_ArrayValues + // *AnyValue_KvlistValues + Value isAnyValue_Value `protobuf_oneof:"value"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *AnyValue) Reset() { *m = AnyValue{} } +func (m *AnyValue) String() string { return proto.CompactTextString(m) } +func (*AnyValue) ProtoMessage() {} +func (*AnyValue) Descriptor() ([]byte, []int) { + return fileDescriptor_62ba46dcb97aa817, []int{0} +} + +func (m *AnyValue) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_AnyValue.Unmarshal(m, b) +} +func (m *AnyValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_AnyValue.Marshal(b, m, deterministic) +} +func (m *AnyValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_AnyValue.Merge(m, src) +} +func (m *AnyValue) XXX_Size() int { + return xxx_messageInfo_AnyValue.Size(m) +} +func (m *AnyValue) XXX_DiscardUnknown() { + xxx_messageInfo_AnyValue.DiscardUnknown(m) +} + +var xxx_messageInfo_AnyValue proto.InternalMessageInfo + +type isAnyValue_Value interface { + isAnyValue_Value() +} + +type AnyValue_StringValue struct { + StringValue string `protobuf:"bytes,1,opt,name=string_value,json=stringValue,proto3,oneof"` +} + +type AnyValue_BoolValue struct { + BoolValue bool `protobuf:"varint,2,opt,name=bool_value,json=boolValue,proto3,oneof"` +} + +type AnyValue_IntValue struct { + IntValue int64 `protobuf:"varint,3,opt,name=int_value,json=intValue,proto3,oneof"` +} + +type AnyValue_DoubleValue struct { + DoubleValue float64 `protobuf:"fixed64,4,opt,name=double_value,json=doubleValue,proto3,oneof"` +} + +type AnyValue_ArrayValues struct { + ArrayValues *ArrayValue `protobuf:"bytes,5,opt,name=array_values,json=arrayValues,proto3,oneof"` +} + +type AnyValue_KvlistValues struct { + KvlistValues *AttributeKeyValueList `protobuf:"bytes,6,opt,name=kvlist_values,json=kvlistValues,proto3,oneof"` +} + +func (*AnyValue_StringValue) isAnyValue_Value() {} + +func (*AnyValue_BoolValue) isAnyValue_Value() {} + +func (*AnyValue_IntValue) isAnyValue_Value() {} + +func (*AnyValue_DoubleValue) isAnyValue_Value() {} + +func (*AnyValue_ArrayValues) isAnyValue_Value() {} + +func (*AnyValue_KvlistValues) isAnyValue_Value() {} + +func (m *AnyValue) GetValue() isAnyValue_Value { + if m != nil { + return m.Value + } + return nil +} + +func (m *AnyValue) GetStringValue() string { + if x, ok := m.GetValue().(*AnyValue_StringValue); ok { + return x.StringValue + } + return "" +} + +func (m *AnyValue) GetBoolValue() bool { + if x, ok := m.GetValue().(*AnyValue_BoolValue); ok { + return x.BoolValue + } + return false +} + +func (m *AnyValue) GetIntValue() int64 { + if x, ok := m.GetValue().(*AnyValue_IntValue); ok { + return x.IntValue + } + return 0 +} + +func (m *AnyValue) GetDoubleValue() float64 { + if x, ok := m.GetValue().(*AnyValue_DoubleValue); ok { + return x.DoubleValue + } + return 0 +} + +func (m *AnyValue) GetArrayValues() *ArrayValue { + if x, ok := m.GetValue().(*AnyValue_ArrayValues); ok { + return x.ArrayValues + } + return nil +} -var AttributeKeyValue_ValueType_name = map[int32]string{ - 0: "STRING", - 1: "INT", - 2: "DOUBLE", - 3: "BOOL", +func (m *AnyValue) GetKvlistValues() *AttributeKeyValueList { + if x, ok := m.GetValue().(*AnyValue_KvlistValues); ok { + return x.KvlistValues + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*AnyValue) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*AnyValue_StringValue)(nil), + (*AnyValue_BoolValue)(nil), + (*AnyValue_IntValue)(nil), + (*AnyValue_DoubleValue)(nil), + (*AnyValue_ArrayValues)(nil), + (*AnyValue_KvlistValues)(nil), + } } -var AttributeKeyValue_ValueType_value = map[string]int32{ - "STRING": 0, - "INT": 1, - "DOUBLE": 2, - "BOOL": 3, +type ArrayValue struct { + // Array of values. The array may be empty (contain 0 elements). + ArrayValues []*AnyValue `protobuf:"bytes,1,rep,name=array_values,json=arrayValues,proto3" json:"array_values,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } -func (x AttributeKeyValue_ValueType) String() string { - return proto.EnumName(AttributeKeyValue_ValueType_name, int32(x)) +func (m *ArrayValue) Reset() { *m = ArrayValue{} } +func (m *ArrayValue) String() string { return proto.CompactTextString(m) } +func (*ArrayValue) ProtoMessage() {} +func (*ArrayValue) Descriptor() ([]byte, []int) { + return fileDescriptor_62ba46dcb97aa817, []int{1} +} + +func (m *ArrayValue) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_ArrayValue.Unmarshal(m, b) +} +func (m *ArrayValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_ArrayValue.Marshal(b, m, deterministic) } +func (m *ArrayValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_ArrayValue.Merge(m, src) +} +func (m *ArrayValue) XXX_Size() int { + return xxx_messageInfo_ArrayValue.Size(m) +} +func (m *ArrayValue) XXX_DiscardUnknown() { + xxx_messageInfo_ArrayValue.DiscardUnknown(m) +} + +var xxx_messageInfo_ArrayValue proto.InternalMessageInfo -func (AttributeKeyValue_ValueType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_62ba46dcb97aa817, []int{0, 0} +func (m *ArrayValue) GetArrayValues() []*AnyValue { + if m != nil { + return m.ArrayValues + } + return nil +} + +type AttributeKeyValueList struct { + // List of key-value pairs. The list may be empty (contain 0 elements). + KvlistValues []*AttributeKeyValue `protobuf:"bytes,1,rep,name=kvlist_values,json=kvlistValues,proto3" json:"kvlist_values,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *AttributeKeyValueList) Reset() { *m = AttributeKeyValueList{} } +func (m *AttributeKeyValueList) String() string { return proto.CompactTextString(m) } +func (*AttributeKeyValueList) ProtoMessage() {} +func (*AttributeKeyValueList) Descriptor() ([]byte, []int) { + return fileDescriptor_62ba46dcb97aa817, []int{2} +} + +func (m *AttributeKeyValueList) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_AttributeKeyValueList.Unmarshal(m, b) +} +func (m *AttributeKeyValueList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_AttributeKeyValueList.Marshal(b, m, deterministic) +} +func (m *AttributeKeyValueList) XXX_Merge(src proto.Message) { + xxx_messageInfo_AttributeKeyValueList.Merge(m, src) +} +func (m *AttributeKeyValueList) XXX_Size() int { + return xxx_messageInfo_AttributeKeyValueList.Size(m) +} +func (m *AttributeKeyValueList) XXX_DiscardUnknown() { + xxx_messageInfo_AttributeKeyValueList.DiscardUnknown(m) +} + +var xxx_messageInfo_AttributeKeyValueList proto.InternalMessageInfo + +func (m *AttributeKeyValueList) GetKvlistValues() []*AttributeKeyValue { + if m != nil { + return m.KvlistValues + } + return nil } // AttributeKeyValue is a key-value pair that is used to store Span attributes, Link // attributes, etc. type AttributeKeyValue struct { - // key part of the key-value pair. - Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - // type of the value. - Type AttributeKeyValue_ValueType `protobuf:"varint,2,opt,name=type,proto3,enum=opentelemetry.proto.common.v1.AttributeKeyValue_ValueType" json:"type,omitempty"` - StringValue string `protobuf:"bytes,3,opt,name=string_value,json=stringValue,proto3" json:"string_value,omitempty"` - IntValue int64 `protobuf:"varint,4,opt,name=int_value,json=intValue,proto3" json:"int_value,omitempty"` - DoubleValue float64 `protobuf:"fixed64,5,opt,name=double_value,json=doubleValue,proto3" json:"double_value,omitempty"` - BoolValue bool `protobuf:"varint,6,opt,name=bool_value,json=boolValue,proto3" json:"bool_value,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Value *AnyValue `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *AttributeKeyValue) Reset() { *m = AttributeKeyValue{} } func (m *AttributeKeyValue) String() string { return proto.CompactTextString(m) } func (*AttributeKeyValue) ProtoMessage() {} func (*AttributeKeyValue) Descriptor() ([]byte, []int) { - return fileDescriptor_62ba46dcb97aa817, []int{0} + return fileDescriptor_62ba46dcb97aa817, []int{3} } func (m *AttributeKeyValue) XXX_Unmarshal(b []byte) error { @@ -100,39 +289,11 @@ func (m *AttributeKeyValue) GetKey() string { return "" } -func (m *AttributeKeyValue) GetType() AttributeKeyValue_ValueType { - if m != nil { - return m.Type - } - return AttributeKeyValue_STRING -} - -func (m *AttributeKeyValue) GetStringValue() string { - if m != nil { - return m.StringValue - } - return "" -} - -func (m *AttributeKeyValue) GetIntValue() int64 { - if m != nil { - return m.IntValue - } - return 0 -} - -func (m *AttributeKeyValue) GetDoubleValue() float64 { +func (m *AttributeKeyValue) GetValue() *AnyValue { if m != nil { - return m.DoubleValue - } - return 0 -} - -func (m *AttributeKeyValue) GetBoolValue() bool { - if m != nil { - return m.BoolValue + return m.Value } - return false + return nil } // StringKeyValue is a pair of key/value strings. This is the simpler (and faster) version @@ -149,7 +310,7 @@ func (m *StringKeyValue) Reset() { *m = StringKeyValue{} } func (m *StringKeyValue) String() string { return proto.CompactTextString(m) } func (*StringKeyValue) ProtoMessage() {} func (*StringKeyValue) Descriptor() ([]byte, []int) { - return fileDescriptor_62ba46dcb97aa817, []int{1} + return fileDescriptor_62ba46dcb97aa817, []int{4} } func (m *StringKeyValue) XXX_Unmarshal(b []byte) error { @@ -198,7 +359,7 @@ func (m *InstrumentationLibrary) Reset() { *m = InstrumentationLibrary{} func (m *InstrumentationLibrary) String() string { return proto.CompactTextString(m) } func (*InstrumentationLibrary) ProtoMessage() {} func (*InstrumentationLibrary) Descriptor() ([]byte, []int) { - return fileDescriptor_62ba46dcb97aa817, []int{2} + return fileDescriptor_62ba46dcb97aa817, []int{5} } func (m *InstrumentationLibrary) XXX_Unmarshal(b []byte) error { @@ -234,7 +395,9 @@ func (m *InstrumentationLibrary) GetVersion() string { } func init() { - proto.RegisterEnum("opentelemetry.proto.common.v1.AttributeKeyValue_ValueType", AttributeKeyValue_ValueType_name, AttributeKeyValue_ValueType_value) + proto.RegisterType((*AnyValue)(nil), "opentelemetry.proto.common.v1.AnyValue") + proto.RegisterType((*ArrayValue)(nil), "opentelemetry.proto.common.v1.ArrayValue") + proto.RegisterType((*AttributeKeyValueList)(nil), "opentelemetry.proto.common.v1.AttributeKeyValueList") proto.RegisterType((*AttributeKeyValue)(nil), "opentelemetry.proto.common.v1.AttributeKeyValue") proto.RegisterType((*StringKeyValue)(nil), "opentelemetry.proto.common.v1.StringKeyValue") proto.RegisterType((*InstrumentationLibrary)(nil), "opentelemetry.proto.common.v1.InstrumentationLibrary") @@ -245,29 +408,32 @@ func init() { } var fileDescriptor_62ba46dcb97aa817 = []byte{ - // 377 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xdb, 0x8b, 0x9b, 0x40, - 0x18, 0xc5, 0x3b, 0x6a, 0x2e, 0x7e, 0x09, 0xc1, 0x0e, 0xa5, 0x08, 0x25, 0x60, 0x7c, 0x92, 0x42, - 0x94, 0xb4, 0x50, 0x4a, 0x1f, 0x0a, 0xb5, 0x37, 0x42, 0x43, 0x12, 0x4c, 0xda, 0x87, 0xbe, 0x14, - 0x6d, 0x07, 0x3b, 0xac, 0xce, 0xb8, 0x93, 0x51, 0xf0, 0xaf, 0xda, 0x7f, 0x71, 0x71, 0xc6, 0xbd, - 0x84, 0x85, 0xbc, 0xc8, 0x99, 0xdf, 0x39, 0x9e, 0xf9, 0xd0, 0x0f, 0x5e, 0xf3, 0x8a, 0x30, 0x49, - 0x0a, 0x52, 0x12, 0x29, 0xda, 0xa8, 0x12, 0x5c, 0xf2, 0xe8, 0x2f, 0x2f, 0x4b, 0xce, 0xa2, 0x66, - 0xd5, 0xab, 0x50, 0x61, 0x3c, 0x3f, 0xcb, 0x6a, 0x18, 0xf6, 0x89, 0x66, 0xe5, 0xdf, 0x18, 0xf0, - 0xfc, 0x93, 0x94, 0x82, 0x66, 0xb5, 0x24, 0x3f, 0x48, 0xfb, 0x2b, 0x2d, 0x6a, 0x82, 0x1d, 0x30, - 0xaf, 0x48, 0xeb, 0x22, 0x0f, 0x05, 0x76, 0xd2, 0x49, 0xbc, 0x05, 0x4b, 0xb6, 0x15, 0x71, 0x0d, - 0x0f, 0x05, 0xb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, 0xee, 0x3b, 0xbc, 0x47, 0xbf, 0x3f, 0xe6, - 0x54, 0xfe, 0xaf, 0xb3, 0x2e, 0x10, 0x75, 0x2f, 0x2e, 0x1f, 0xb6, 0xe7, 0xac, 0x67, 0xa9, 0x77, - 0x29, 0x27, 0x2c, 0xca, 0x1f, 0xad, 0x54, 0x36, 0x54, 0xfc, 0xed, 0x6d, 0x00, 0x00, 0x00, 0xff, - 0xff, 0x84, 0x93, 0x08, 0x5f, 0x7a, 0x02, 0x00, 0x00, + // 429 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x5d, 0x8b, 0xd3, 0x40, + 0x14, 0xcd, 0x6c, 0xf6, 0xa3, 0xb9, 0xa9, 0xa2, 0x83, 0x4a, 0x5f, 0x16, 0x43, 0x7c, 0x30, 0x0a, + 0x9b, 0xb8, 0xab, 0x0f, 0xbe, 0x28, 0x6c, 0x05, 0x89, 0xba, 0xc8, 0x12, 0x51, 0x44, 0x1f, 0x24, + 0x71, 0x87, 0x38, 0x34, 0x99, 0xa9, 0x93, 0x49, 0x20, 0x7f, 0xd1, 0x5f, 0x25, 0xf3, 0xd1, 0x8f, + 0x54, 0x69, 0xe9, 0xdb, 0x9d, 0xd3, 0x73, 0xcf, 0xb9, 0xa7, 0xb9, 0x17, 0x9e, 0xf2, 0x39, 0x61, + 0x92, 0x54, 0xa4, 0x26, 0x52, 0xf4, 0xc9, 0x5c, 0x70, 0xc9, 0x93, 0x9f, 0xbc, 0xae, 0x39, 0x4b, + 0xba, 0x73, 0x5b, 0xc5, 0x1a, 0xc6, 0xa7, 0x03, 0xae, 0x01, 0x63, 0xcb, 0xe8, 0xce, 0xc3, 0x3f, + 0x07, 0x30, 0xba, 0x64, 0xfd, 0x97, 0xbc, 0x6a, 0x09, 0x7e, 0x04, 0xe3, 0x46, 0x0a, 0xca, 0xca, + 0x1f, 0x9d, 0x7a, 0x4f,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9b, 0xfd, 0xbf, 0x5e, 0xc2, + 0xed, 0x4f, 0x7a, 0xb3, 0xb6, 0x58, 0xdc, 0x5b, 0xb7, 0xf0, 0x16, 0x9d, 0x6f, 0xe1, 0xc1, 0x3b, + 0xd6, 0x48, 0xd1, 0xd6, 0x84, 0xc9, 0x5c, 0x52, 0xce, 0xae, 0x68, 0x21, 0x72, 0xd1, 0x63, 0x0c, + 0x87, 0x2c, 0xaf, 0xed, 0xee, 0x66, 0xba, 0xc6, 0x13, 0x38, 0xe9, 0x88, 0x68, 0x28, 0x67, 0x56, + 0x65, 0xf1, 0x9c, 0xfe, 0x86, 0x80, 0xf2, 0xed, 0x53, 0x4f, 0xfd, 0x37, 0xba, 0xbc, 0x56, 0xf0, + 0x35, 0xfa, 0xf6, 0xba, 0xa4, 0xf2, 0x57, 0x5b, 0x28, 0x42, 0xa2, 0x1a, 0xcf, 0x56, 0x87, 0x38, + 0xd0, 0x39, 0x33, 0x67, 0x59, 0x12, 0x96, 0x94, 0x6b, 0xd7, 0x59, 0x1c, 0x6b, 0xfc, 0xf9, 0xdf, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x58, 0x84, 0xf2, 0xe3, 0xc5, 0x03, 0x00, 0x00, } diff --git a/opentelemetry/proto/common/v1/common.proto b/opentelemetry/proto/common/v1/common.proto index 45fbcdb7..8f307890 100644 --- a/opentelemetry/proto/common/v1/common.proto +++ b/opentelemetry/proto/common/v1/common.proto @@ -21,30 +21,38 @@ option java_package = "io.opentelemetry.proto.common.v1"; option java_outer_classname = "CommonProto"; option go_package = "github.com/open-telemetry/opentelemetry-proto/gen/go/common/v1"; +// AnyValue is used to represent any type of attribute value. AnyValue may contain a +// primitive value such as a string or integer or it may contain an arbitrary nested +// object containing arrays, key-value lists and primitives. AnyValue can represent +// any data that JSON can represent. +message AnyValue { + // The value is one of the listed fields. It is valid for all values to be unspecified + // in which case this AnyValue is considered to be "null". + oneof value { + string string_value = 1; + bool bool_value = 2; + int64 int_value = 3; + double double_value = 4; + ArrayValue array_values = 5; + AttributeKeyValueList kvlist_values = 6; + } +} + +message ArrayValue { + // Array of values. The array may be empty (contain 0 elements). + repeated AnyValue array_values = 1; +} + +message AttributeKeyValueList { + // List of key-value pairs. The list may be empty (contain 0 elements). + repeated AttributeKeyValue kvlist_values = 1; +} + // AttributeKeyValue is a key-value pair that is used to store Span attributes, Link // attributes, etc. message AttributeKeyValue { - // ValueType is the enumeration of possible types that value can have. - enum ValueType { - STRING = 0; - INT = 1; - DOUBLE = 2; - BOOL = 3; - }; - - // key part of the key-value pair. string key = 1; - - // type of the value. - ValueType type = 2; - - // Only one of the following fields is supposed to contain data (determined by `type` field). - // This is deliberately not using Protobuf `oneof` for performance reasons (verified by benchmarks). - - string string_value = 3; - int64 int_value = 4; - double double_value = 5; - bool bool_value = 6; + AnyValue value = 2; } // StringKeyValue is a pair of key/value strings. This is the simpler (and faster) version