From a76b227b8c1f84ce82624c7d72d1c8245b39b004 Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Thu, 20 May 2021 13:59:18 -0400 Subject: [PATCH 01/27] Edited grammar of pdata doc.go --- consumer/pdata/doc.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/consumer/pdata/doc.go b/consumer/pdata/doc.go index 4b4ca0b041b..507fb7bf0c1 100644 --- a/consumer/pdata/doc.go +++ b/consumer/pdata/doc.go @@ -13,20 +13,20 @@ // limitations under the License. // Package pdata (pipeline data) implements data structures that represent telemetry data in-memory. -// All data received is converted into this format and travels through the pipeline -// in this format and that is converted from this format by exporters when sending. +// All data received is converted into this format, travels through the pipeline +// in this format, and is converted from this format by exporters when sending. // // Current implementation primarily uses OTLP ProtoBuf structs as the underlying data // structures for many of of the declared structs. We keep a pointer to OTLP protobuf // in the "orig" member field. This allows efficient translation to/from OTLP wire -// protocol. Note that the underlying data structure is kept private so that in the -// future we are free to make changes to it to make more optimal. +// protocol. Note that the underlying data structure is kept private so that we are +// free to make changes to it in the future. // // Most of internal data structures must be created via New* functions. Zero-initialized -// structures in most cases are not valid (read comments for each struct to know if it +// structures, in most cases, are not valid (read comments for each struct to know if that // is the case). This is a slight deviation from idiomatic Go to avoid unnecessary // pointer checks in dozens of functions which assume the invariant that "orig" member -// is non-nil. Several structures also provide New*Slice functions that allows to create +// is non-nil. Several structures also provide New*Slice functions that allow creating // more than one instance of the struct more efficiently instead of calling New* // repeatedly. Use it where appropriate. package pdata From 36e3d5c92e8e8a98d1810673fe2e55058b31b251 Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Thu, 20 May 2021 15:26:48 -0400 Subject: [PATCH 02/27] Added missing word --- consumer/simple/metrics.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consumer/simple/metrics.go b/consumer/simple/metrics.go index 7bb6eacde68..deffe31620e 100644 --- a/consumer/simple/metrics.go +++ b/consumer/simple/metrics.go @@ -352,7 +352,7 @@ func (mb *SafeMetrics) AddHistogramRawDataPoint(name string, hist pdata.IntHisto return mb } -// AddDHistogramRawDataPoint wraps AddDHistogramRawDataPoint. +// AddDHistogramRawDataPoint wraps Metrics.AddDHistogramRawDataPoint. func (mb *SafeMetrics) AddDHistogramRawDataPoint(name string, hist pdata.HistogramDataPoint) *SafeMetrics { mb.Lock() mb.Metrics.AddDHistogramRawDataPoint(name, hist) From 30666ab9ea4bc7842d16acd65c42b94e0b838af9 Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Thu, 20 May 2021 15:47:28 -0400 Subject: [PATCH 03/27] Fixed typos in pdata/common.go --- consumer/pdata/common.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consumer/pdata/common.go b/consumer/pdata/common.go index 46513dffe6f..1a1c89880c6 100644 --- a/consumer/pdata/common.go +++ b/consumer/pdata/common.go @@ -70,7 +70,7 @@ func (avt AttributeValueType) String() string { // _ := v.Type() // this will return AttributeValueTypeInt // } // -// Important: zero-initialized instance is not valid for use. All AttributeValue functions bellow must +// Important: zero-initialized instance is not valid for use. All AttributeValue functions below must // be called only on instances that are created via NewAttributeValue+ functions. type AttributeValue struct { orig *otlpcommon.AnyValue From 8530cd513371075d0eecfea00bcd5c6898618c1d Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Thu, 20 May 2021 15:52:06 -0400 Subject: [PATCH 04/27] Added missing String method docs This fix makes the pdata folder consistent in documenting the String methods. --- consumer/pdata/common.go | 1 + consumer/pdata/log.go | 1 + consumer/pdata/metric.go | 1 + consumer/pdata/trace.go | 1 + 4 files changed, 4 insertions(+) diff --git a/consumer/pdata/common.go b/consumer/pdata/common.go index 1a1c89880c6..7653ea9fb61 100644 --- a/consumer/pdata/common.go +++ b/consumer/pdata/common.go @@ -36,6 +36,7 @@ const ( AttributeValueTypeArray ) +// String returns the string representation of the AttributeValueType. func (avt AttributeValueType) String() string { switch avt { case AttributeValueTypeNull: diff --git a/consumer/pdata/log.go b/consumer/pdata/log.go index 6d528e3b58c..e18a487f2bb 100644 --- a/consumer/pdata/log.go +++ b/consumer/pdata/log.go @@ -135,4 +135,5 @@ const ( SeverityNumberFATAL4 = SeverityNumber(otlplogs.SeverityNumber_SEVERITY_NUMBER_FATAL4) ) +// String returns the string representation of the SeverityNumber. func (sn SeverityNumber) String() string { return otlplogs.SeverityNumber(sn).String() } diff --git a/consumer/pdata/metric.go b/consumer/pdata/metric.go index eafc3cae261..de08793e0c7 100644 --- a/consumer/pdata/metric.go +++ b/consumer/pdata/metric.go @@ -166,6 +166,7 @@ const ( MetricDataTypeSummary ) +// String returns the string representation of the MetricDataType. func (mdt MetricDataType) String() string { switch mdt { case MetricDataTypeNone: diff --git a/consumer/pdata/trace.go b/consumer/pdata/trace.go index a737e60e3d2..4e420ff6499 100644 --- a/consumer/pdata/trace.go +++ b/consumer/pdata/trace.go @@ -145,6 +145,7 @@ const ( StatusCodeError = StatusCode(otlptrace.Status_STATUS_CODE_ERROR) ) +// String returns the string representation of the StatusCode. func (sc StatusCode) String() string { return otlptrace.Status_StatusCode(sc).String() } // SetCode replaces the code associated with this SpanStatus. From 662c34deb7701d2a6e4d1c969b8ba803e6f7684a Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Thu, 20 May 2021 16:06:54 -0400 Subject: [PATCH 05/27] Fixed spacing in doc example --- consumer/pdata/common.go | 2 +- consumer/pdata/generated_common.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/consumer/pdata/common.go b/consumer/pdata/common.go index 7653ea9fb61..e0e6cbb07aa 100644 --- a/consumer/pdata/common.go +++ b/consumer/pdata/common.go @@ -66,7 +66,7 @@ func (avt AttributeValueType) String() string { // // function f1(val AttributeValue) { val.SetIntVal(234) } // function f2() { -// v := NewAttributeValueString("a string") +// v := NewAttributeValueString("a string") // f1(v) // _ := v.Type() // this will return AttributeValueTypeInt // } diff --git a/consumer/pdata/generated_common.go b/consumer/pdata/generated_common.go index 9c647fe97a2..afd3706267c 100644 --- a/consumer/pdata/generated_common.go +++ b/consumer/pdata/generated_common.go @@ -71,7 +71,7 @@ func (ms InstrumentationLibrary) CopyTo(dest InstrumentationLibrary) { // AnyValueArray logically represents a slice of AttributeValue. // -// This is a reference type, if passed by value and callee modifies it the +// This is a reference type, if passed by value and callee modifies, it the // caller will see the modification. // // Must use NewAnyValueArray function to create new instances. From 7d31d65f46e296b84e59c4f9b8e101308d1c15bb Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Thu, 20 May 2021 16:18:35 -0400 Subject: [PATCH 06/27] Fixed spacing issues in multiple examples This issue was causing many example snippets to show up incorrectly on the godoc --- consumer/pdata/common.go | 6 +- consumer/pdata/generated_common.go | 12 +-- consumer/pdata/generated_metrics.go | 134 ++++++++++++++-------------- 3 files changed, 76 insertions(+), 76 deletions(-) diff --git a/consumer/pdata/common.go b/consumer/pdata/common.go index e0e6cbb07aa..73c8dc7bef0 100644 --- a/consumer/pdata/common.go +++ b/consumer/pdata/common.go @@ -66,9 +66,9 @@ func (avt AttributeValueType) String() string { // // function f1(val AttributeValue) { val.SetIntVal(234) } // function f2() { -// v := NewAttributeValueString("a string") -// f1(v) -// _ := v.Type() // this will return AttributeValueTypeInt +// v := NewAttributeValueString("a string") +// f1(v) +// _ := v.Type() // this will return AttributeValueTypeInt // } // // Important: zero-initialized instance is not valid for use. All AttributeValue functions below must diff --git a/consumer/pdata/generated_common.go b/consumer/pdata/generated_common.go index afd3706267c..bde7fe64138 100644 --- a/consumer/pdata/generated_common.go +++ b/consumer/pdata/generated_common.go @@ -131,12 +131,12 @@ func (es AnyValueArray) CopyTo(dest AnyValueArray) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new AnyValueArray can be initialized: -// es := NewAnyValueArray() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewAnyValueArray() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es AnyValueArray) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) diff --git a/consumer/pdata/generated_metrics.go b/consumer/pdata/generated_metrics.go index 9e614c40ae7..7c30efed11c 100644 --- a/consumer/pdata/generated_metrics.go +++ b/consumer/pdata/generated_metrics.go @@ -88,12 +88,12 @@ func (es ResourceMetricsSlice) CopyTo(dest ResourceMetricsSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new ResourceMetricsSlice can be initialized: -// es := NewResourceMetricsSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewResourceMetricsSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es ResourceMetricsSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -267,13 +267,13 @@ func (es InstrumentationLibraryMetricsSlice) CopyTo(dest InstrumentationLibraryM // 1. If the newLen <= len then equivalent with slice[0:newLen:cap]. // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // -// Here is how a new InstrumentationLibraryMetricsSlice can be initialized: -// es := NewInstrumentationLibraryMetricsSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// Here is how a new InstrumentationLibraryMetricsSlice can be initialized: +// es := NewInstrumentationLibraryMetricsSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es InstrumentationLibraryMetricsSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -448,12 +448,12 @@ func (es MetricSlice) CopyTo(dest MetricSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new MetricSlice can be initialized: -// es := NewMetricSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewMetricSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es MetricSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -941,12 +941,12 @@ func (es IntDataPointSlice) CopyTo(dest IntDataPointSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new IntDataPointSlice can be initialized: -// es := NewIntDataPointSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewIntDataPointSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es IntDataPointSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -1154,12 +1154,12 @@ func (es DoubleDataPointSlice) CopyTo(dest DoubleDataPointSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new DoubleDataPointSlice can be initialized: -// es := NewDoubleDataPointSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewDoubleDataPointSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es DoubleDataPointSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -1367,12 +1367,12 @@ func (es IntHistogramDataPointSlice) CopyTo(dest IntHistogramDataPointSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new IntHistogramDataPointSlice can be initialized: -// es := NewIntHistogramDataPointSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewIntHistogramDataPointSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es IntHistogramDataPointSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -1613,12 +1613,12 @@ func (es HistogramDataPointSlice) CopyTo(dest HistogramDataPointSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new HistogramDataPointSlice can be initialized: -// es := NewHistogramDataPointSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewHistogramDataPointSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es HistogramDataPointSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -1859,12 +1859,12 @@ func (es SummaryDataPointSlice) CopyTo(dest SummaryDataPointSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new SummaryDataPointSlice can be initialized: -// es := NewSummaryDataPointSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewSummaryDataPointSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es SummaryDataPointSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -2083,12 +2083,12 @@ func (es ValueAtQuantileSlice) CopyTo(dest ValueAtQuantileSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new ValueAtQuantileSlice can be initialized: -// es := NewValueAtQuantileSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewValueAtQuantileSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es ValueAtQuantileSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -2268,12 +2268,12 @@ func (es IntExemplarSlice) CopyTo(dest IntExemplarSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new IntExemplarSlice can be initialized: -// es := NewIntExemplarSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewIntExemplarSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es IntExemplarSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -2462,12 +2462,12 @@ func (es ExemplarSlice) CopyTo(dest ExemplarSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new ExemplarSlice can be initialized: -// es := NewExemplarSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewExemplarSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es ExemplarSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) From 8202727b9839ede2d01a783d20fa10989d34a32a Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Thu, 20 May 2021 16:22:12 -0400 Subject: [PATCH 07/27] Fixed spacing issue on Range example --- consumer/pdata/common.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/consumer/pdata/common.go b/consumer/pdata/common.go index 73c8dc7bef0..f791a90c9dc 100644 --- a/consumer/pdata/common.go +++ b/consumer/pdata/common.go @@ -608,9 +608,9 @@ func (am AttributeMap) Len() int { // // Example: // -// it := sm.Range(func(k string, v AttributeValue) { -// ... -// }) +// it := sm.Range(func(k string, v AttributeValue) { +// ... +// }) func (am AttributeMap) Range(f func(k string, v AttributeValue) bool) { for i := range *am.orig { kv := &(*am.orig)[i] From d553a0b77dbe8d5c5a45ebcbfb5e5337b45f3993 Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Thu, 20 May 2021 17:30:17 -0400 Subject: [PATCH 08/27] Fixed spacing in At example --- consumer/pdata/generated_common.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/consumer/pdata/generated_common.go b/consumer/pdata/generated_common.go index bde7fe64138..426f980ce92 100644 --- a/consumer/pdata/generated_common.go +++ b/consumer/pdata/generated_common.go @@ -103,10 +103,10 @@ func (es AnyValueArray) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Do something with the element +// } func (es AnyValueArray) At(ix int) AttributeValue { return newAttributeValue(&(*es.orig)[ix]) } From ee177225ad379f8b320ddea8f0bdca1a86d3f650 Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Fri, 21 May 2021 10:59:22 -0400 Subject: [PATCH 09/27] Fixed more spacing errors in examples --- consumer/pdata/common.go | 6 +- consumer/pdata/generated_log.go | 60 ++++++++--------- consumer/pdata/generated_metrics.go | 88 ++++++++++++------------ consumer/pdata/generated_trace.go | 100 ++++++++++++++-------------- consumer/pdata/metric.go | 6 +- 5 files changed, 130 insertions(+), 130 deletions(-) diff --git a/consumer/pdata/common.go b/consumer/pdata/common.go index f791a90c9dc..4a8d580999c 100644 --- a/consumer/pdata/common.go +++ b/consumer/pdata/common.go @@ -363,7 +363,7 @@ func newAttributeMap(orig *[]otlpcommon.KeyValue) AttributeMap { // with values from the given map[string]string. // // Returns the same instance to allow nicer code like: -// assert.EqualValues(t, NewAttributeMap().InitFromMap(map[string]AttributeValue{...}), actual) +// assert.EqualValues(t, NewAttributeMap().InitFromMap(map[string]AttributeValue{...}), actual) func (am AttributeMap) InitFromMap(attrMap map[string]AttributeValue) AttributeMap { if len(attrMap) == 0 { *am.orig = []otlpcommon.KeyValue(nil) @@ -587,7 +587,7 @@ func (am AttributeMap) UpsertBool(k string, v bool) { // Sort sorts the entries in the AttributeMap so two instances can be compared. // Returns the same instance to allow nicer code like: -// assert.EqualValues(t, expected.Sort(), actual.Sort()) +// assert.EqualValues(t, expected.Sort(), actual.Sort()) func (am AttributeMap) Sort() AttributeMap { // Intention is to move the nil values at the end. sort.SliceStable(*am.orig, func(i, j int) bool { @@ -665,7 +665,7 @@ func newStringMap(orig *[]otlpcommon.StringKeyValue) StringMap { // with values from the given map[string]string. // // Returns the same instance to allow nicer code like: -// assert.EqualValues(t, NewStringMap().InitFromMap(map[string]string{...}), actual) +// assert.EqualValues(t, NewStringMap().InitFromMap(map[string]string{...}), actual) func (sm StringMap) InitFromMap(attrMap map[string]string) StringMap { if len(attrMap) == 0 { *sm.orig = []otlpcommon.StringKeyValue(nil) diff --git a/consumer/pdata/generated_log.go b/consumer/pdata/generated_log.go index 9662ec543f0..141c5ae0d4e 100644 --- a/consumer/pdata/generated_log.go +++ b/consumer/pdata/generated_log.go @@ -55,10 +55,10 @@ func (es ResourceLogsSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es ResourceLogsSlice) At(ix int) ResourceLogs { return newResourceLogs((*es.orig)[ix]) } @@ -88,12 +88,12 @@ func (es ResourceLogsSlice) CopyTo(dest ResourceLogsSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new ResourceLogsSlice can be initialized: -// es := NewResourceLogsSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewResourceLogsSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es ResourceLogsSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -235,10 +235,10 @@ func (es InstrumentationLibraryLogsSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es InstrumentationLibraryLogsSlice) At(ix int) InstrumentationLibraryLogs { return newInstrumentationLibraryLogs((*es.orig)[ix]) } @@ -268,12 +268,12 @@ func (es InstrumentationLibraryLogsSlice) CopyTo(dest InstrumentationLibraryLogs // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new InstrumentationLibraryLogsSlice can be initialized: -// es := NewInstrumentationLibraryLogsSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewInstrumentationLibraryLogsSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es InstrumentationLibraryLogsSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -415,10 +415,10 @@ func (es LogSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es LogSlice) At(ix int) LogRecord { return newLogRecord((*es.orig)[ix]) } @@ -448,12 +448,12 @@ func (es LogSlice) CopyTo(dest LogSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new LogSlice can be initialized: -// es := NewLogSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewLogSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es LogSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) diff --git a/consumer/pdata/generated_metrics.go b/consumer/pdata/generated_metrics.go index 7c30efed11c..a93f4e7acb9 100644 --- a/consumer/pdata/generated_metrics.go +++ b/consumer/pdata/generated_metrics.go @@ -55,10 +55,10 @@ func (es ResourceMetricsSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es ResourceMetricsSlice) At(ix int) ResourceMetrics { return newResourceMetrics((*es.orig)[ix]) } @@ -235,10 +235,10 @@ func (es InstrumentationLibraryMetricsSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es InstrumentationLibraryMetricsSlice) At(ix int) InstrumentationLibraryMetrics { return newInstrumentationLibraryMetrics((*es.orig)[ix]) } @@ -415,10 +415,10 @@ func (es MetricSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es MetricSlice) At(ix int) Metric { return newMetric((*es.orig)[ix]) } @@ -908,10 +908,10 @@ func (es IntDataPointSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es IntDataPointSlice) At(ix int) IntDataPoint { return newIntDataPoint((*es.orig)[ix]) } @@ -1121,10 +1121,10 @@ func (es DoubleDataPointSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es DoubleDataPointSlice) At(ix int) DoubleDataPoint { return newDoubleDataPoint((*es.orig)[ix]) } @@ -1334,10 +1334,10 @@ func (es IntHistogramDataPointSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es IntHistogramDataPointSlice) At(ix int) IntHistogramDataPoint { return newIntHistogramDataPoint((*es.orig)[ix]) } @@ -1580,10 +1580,10 @@ func (es HistogramDataPointSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es HistogramDataPointSlice) At(ix int) HistogramDataPoint { return newHistogramDataPoint((*es.orig)[ix]) } @@ -1826,10 +1826,10 @@ func (es SummaryDataPointSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es SummaryDataPointSlice) At(ix int) SummaryDataPoint { return newSummaryDataPoint((*es.orig)[ix]) } @@ -2050,10 +2050,10 @@ func (es ValueAtQuantileSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es ValueAtQuantileSlice) At(ix int) ValueAtQuantile { return newValueAtQuantile((*es.orig)[ix]) } @@ -2240,10 +2240,10 @@ func (es IntExemplarSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es IntExemplarSlice) At(ix int) IntExemplar { return newIntExemplar(&(*es.orig)[ix]) } @@ -2434,10 +2434,10 @@ func (es ExemplarSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es ExemplarSlice) At(ix int) Exemplar { return newExemplar(&(*es.orig)[ix]) } diff --git a/consumer/pdata/generated_trace.go b/consumer/pdata/generated_trace.go index 62adc93dcd3..7051269cffc 100644 --- a/consumer/pdata/generated_trace.go +++ b/consumer/pdata/generated_trace.go @@ -55,10 +55,10 @@ func (es ResourceSpansSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es ResourceSpansSlice) At(ix int) ResourceSpans { return newResourceSpans((*es.orig)[ix]) } @@ -88,12 +88,12 @@ func (es ResourceSpansSlice) CopyTo(dest ResourceSpansSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new ResourceSpansSlice can be initialized: -// es := NewResourceSpansSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewResourceSpansSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es ResourceSpansSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -235,10 +235,10 @@ func (es InstrumentationLibrarySpansSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es InstrumentationLibrarySpansSlice) At(ix int) InstrumentationLibrarySpans { return newInstrumentationLibrarySpans((*es.orig)[ix]) } @@ -268,12 +268,12 @@ func (es InstrumentationLibrarySpansSlice) CopyTo(dest InstrumentationLibrarySpa // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new InstrumentationLibrarySpansSlice can be initialized: -// es := NewInstrumentationLibrarySpansSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewInstrumentationLibrarySpansSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es InstrumentationLibrarySpansSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -415,10 +415,10 @@ func (es SpanSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es SpanSlice) At(ix int) Span { return newSpan((*es.orig)[ix]) } @@ -448,12 +448,12 @@ func (es SpanSlice) CopyTo(dest SpanSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new SpanSlice can be initialized: -// es := NewSpanSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewSpanSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es SpanSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -729,10 +729,10 @@ func (es SpanEventSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es SpanEventSlice) At(ix int) SpanEvent { return newSpanEvent((*es.orig)[ix]) } @@ -762,12 +762,12 @@ func (es SpanEventSlice) CopyTo(dest SpanEventSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new SpanEventSlice can be initialized: -// es := NewSpanEventSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewSpanEventSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es SpanEventSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -937,10 +937,10 @@ func (es SpanLinkSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es SpanLinkSlice) At(ix int) SpanLink { return newSpanLink((*es.orig)[ix]) } @@ -970,12 +970,12 @@ func (es SpanLinkSlice) CopyTo(dest SpanLinkSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new SpanLinkSlice can be initialized: -// es := NewSpanLinkSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewSpanLinkSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es SpanLinkSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) diff --git a/consumer/pdata/metric.go b/consumer/pdata/metric.go index de08793e0c7..9a3bc7475fc 100644 --- a/consumer/pdata/metric.go +++ b/consumer/pdata/metric.go @@ -38,10 +38,10 @@ func (at AggregationTemporality) String() string { return otlpmetrics.AggregationTemporality(at).String() } -// Metrics is an opaque interface that allows transition to the new internal Metrics data, but also facilitate the -// transition to the new components especially for traces. +// Metrics is an opaque interface that allows transition to the new internal Metrics data, but also facilitates the +// transition to the new components, especially for traces. // -// Outside of the core repository the metrics pipeline cannot be converted to the new model since data.MetricData is +// Outside of the core repository, the metrics pipeline cannot be converted to the new model since data.MetricData is // part of the internal package. type Metrics struct { orig *otlpcollectormetrics.ExportMetricsServiceRequest From db923d26d08e5bfd745ee95ce567005e47e2ff2d Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Fri, 21 May 2021 11:00:48 -0400 Subject: [PATCH 10/27] Fixed error in ResourceMetrics header describing InstrumentationLibraryMetrics --- consumer/pdata/generated_metrics.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consumer/pdata/generated_metrics.go b/consumer/pdata/generated_metrics.go index a93f4e7acb9..ce15e282412 100644 --- a/consumer/pdata/generated_metrics.go +++ b/consumer/pdata/generated_metrics.go @@ -163,7 +163,7 @@ func (es ResourceMetricsSlice) RemoveIf(f func(ResourceMetrics) bool) { *es.orig = (*es.orig)[:newLen] } -// InstrumentationLibraryMetrics is a collection of metrics from a LibraryInstrumentation. +// ResourceMetrics is a collection of metrics from a Resource. // // This is a reference type, if passed by value and callee modifies it the // caller will see the modification. From ab14f5033229f3fe62636d89917862e19f48f70d Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Fri, 21 May 2021 11:01:50 -0400 Subject: [PATCH 11/27] Fixed another header referencing wrong method --- consumer/pdata/generated_trace.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consumer/pdata/generated_trace.go b/consumer/pdata/generated_trace.go index 7051269cffc..2aa48676a5d 100644 --- a/consumer/pdata/generated_trace.go +++ b/consumer/pdata/generated_trace.go @@ -163,7 +163,7 @@ func (es ResourceSpansSlice) RemoveIf(f func(ResourceSpans) bool) { *es.orig = (*es.orig)[:newLen] } -// InstrumentationLibrarySpans is a collection of spans from a LibraryInstrumentation. +// ResourceSpans is a collection of spans from a Resource. // // This is a reference type, if passed by value and callee modifies it the // caller will see the modification. From d6343c1837d06d6a71f18c7a4ef15b37188bb2dd Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Fri, 21 May 2021 11:09:48 -0400 Subject: [PATCH 12/27] Added documentation for pdata.Resource --- consumer/pdata/generated_resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consumer/pdata/generated_resource.go b/consumer/pdata/generated_resource.go index 9e4f2cb3fd0..069e3562624 100644 --- a/consumer/pdata/generated_resource.go +++ b/consumer/pdata/generated_resource.go @@ -21,7 +21,7 @@ import ( otlpresource "go.opentelemetry.io/collector/internal/data/protogen/resource/v1" ) -// Resource information. +// Resource is a message representing the resource information. // // This is a reference type, if passed by value and callee modifies it the // caller will see the modification. From 1d360f14ab4a024932b365997d932e858684ffd6 Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Fri, 21 May 2021 11:19:58 -0400 Subject: [PATCH 13/27] Updated outdated links to Span OTLP definition --- consumer/pdata/generated_trace.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/consumer/pdata/generated_trace.go b/consumer/pdata/generated_trace.go index 2aa48676a5d..ca424f96a94 100644 --- a/consumer/pdata/generated_trace.go +++ b/consumer/pdata/generated_trace.go @@ -524,7 +524,7 @@ func (es SpanSlice) RemoveIf(f func(Span) bool) { } // Span represents a single operation within a trace. -// See Span definition in OTLP: https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto#L37 +// See Span definition in OTLP: https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto // // This is a reference type, if passed by value and callee modifies it the // caller will see the modification. @@ -1046,7 +1046,7 @@ func (es SpanLinkSlice) RemoveIf(f func(SpanLink) bool) { } // SpanLink is a pointer from the current span to another span in the same trace or in a -// different trace. See OTLP for link definition. +// different trace. See Link definition in OTLP: https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto // // This is a reference type, if passed by value and callee modifies it the // caller will see the modification. From 72f02be241f3f12ad7e3f005dc0b203ee9a4beac Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Fri, 21 May 2021 11:20:12 -0400 Subject: [PATCH 14/27] Cleaned up wording in SpanStatus doc --- consumer/pdata/generated_trace.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/consumer/pdata/generated_trace.go b/consumer/pdata/generated_trace.go index ca424f96a94..3bbffd1100e 100644 --- a/consumer/pdata/generated_trace.go +++ b/consumer/pdata/generated_trace.go @@ -1122,8 +1122,8 @@ func (ms SpanLink) CopyTo(dest SpanLink) { dest.SetDroppedAttributesCount(ms.DroppedAttributesCount()) } -// SpanStatus is an optional final status for this span. Semantically when Status wasn't set -// it is means span ended without errors and assume Status.Ok (code = 0). +// SpanStatus is an optional final status for this span. Semantically, when Status was not +// set, that means the span ended without errors and to assume Status.Ok (code = 0). // // This is a reference type, if passed by value and callee modifies it the // caller will see the modification. From c5c310b143758bb82136cc02fda1e934d1e75d4a Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Fri, 21 May 2021 11:23:34 -0400 Subject: [PATCH 15/27] Fixed more spacing errors in examples --- consumer/pdata/common.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/consumer/pdata/common.go b/consumer/pdata/common.go index 4a8d580999c..b7642b59950 100644 --- a/consumer/pdata/common.go +++ b/consumer/pdata/common.go @@ -760,9 +760,9 @@ func (sm StringMap) Len() int { // // Example: // -// it := sm.Range(func(k string, v StringValue) { -// ... -// }) +// it := sm.Range(func(k string, v StringValue) { +// ... +// }) func (sm StringMap) Range(f func(k string, v string) bool) { for i := range *sm.orig { skv := &(*sm.orig)[i] @@ -801,7 +801,7 @@ func (sm StringMap) get(k string) (*otlpcommon.StringKeyValue, bool) { // Sort sorts the entries in the StringMap so two instances can be compared. // Returns the same instance to allow nicer code like: -// assert.EqualValues(t, expected.Sort(), actual.Sort()) +// assert.EqualValues(t, expected.Sort(), actual.Sort()) func (sm StringMap) Sort() StringMap { sort.SliceStable(*sm.orig, func(i, j int) bool { // Intention is to move the nil values at the end. From de3d47350c1237afaa4021636be873f2e8eee9cb Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Fri, 21 May 2021 11:24:50 -0400 Subject: [PATCH 16/27] Fixed typos in type docs --- consumer/pdata/generated_metrics.go | 2 +- consumer/pdata/trace.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/consumer/pdata/generated_metrics.go b/consumer/pdata/generated_metrics.go index ce15e282412..1138014255e 100644 --- a/consumer/pdata/generated_metrics.go +++ b/consumer/pdata/generated_metrics.go @@ -2158,7 +2158,7 @@ func (es ValueAtQuantileSlice) RemoveIf(f func(ValueAtQuantile) bool) { *es.orig = (*es.orig)[:newLen] } -// ValueAtQuantile is a quantile value within a Summary data point +// ValueAtQuantile is a quantile value within a Summary data point. // // This is a reference type, if passed by value and callee modifies it the // caller will see the modification. diff --git a/consumer/pdata/trace.go b/consumer/pdata/trace.go index 4e420ff6499..516e1b809e4 100644 --- a/consumer/pdata/trace.go +++ b/consumer/pdata/trace.go @@ -97,7 +97,7 @@ func (td Traces) ResourceSpans() ResourceSpansSlice { return newResourceSpansSlice(&td.orig.ResourceSpans) } -// TraceState in w3c-trace-context format: https://www.w3.org/TR/trace-context/#tracestate-header +// TraceState is a message representing the tracestate in w3c-trace-context format: https://www.w3.org/TR/trace-context/#tracestate-header type TraceState string const ( From a1a9d4c26c305b6822b0f7032960fdc132f18456 Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Fri, 21 May 2021 11:33:14 -0400 Subject: [PATCH 17/27] Cleaned up formatting in consumererror --- consumer/consumererror/permanent.go | 4 ++-- consumer/consumererror/signalerrors.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/consumer/consumererror/permanent.go b/consumer/consumererror/permanent.go index d02e72a4269..b9aa478c29a 100644 --- a/consumer/consumererror/permanent.go +++ b/consumer/consumererror/permanent.go @@ -25,7 +25,7 @@ type permanent struct { err error } -// Permanent wraps an error to indicate that it is a permanent error, i.e.: an +// Permanent wraps an error to indicate that it is a permanent error, i.e. an // error that will be always returned if its source receives the same inputs. func Permanent(err error) error { return permanent{err: err} @@ -40,7 +40,7 @@ func (p permanent) Unwrap() error { return p.err } -// IsPermanent checks if an error was wrapped with the Permanent function, that +// IsPermanent checks if an error was wrapped with the Permanent function, which // is used to indicate that a given error will always be returned in the case // that its sources receives the same input. func IsPermanent(err error) bool { diff --git a/consumer/consumererror/signalerrors.go b/consumer/consumererror/signalerrors.go index f57a7281e5a..a1924f1345e 100644 --- a/consumer/consumererror/signalerrors.go +++ b/consumer/consumererror/signalerrors.go @@ -35,7 +35,7 @@ func NewTraces(err error, failed pdata.Traces) error { } } -// AsTraces finds the first error in err's chain that can be assigned to target. If such an error is found +// AsTraces finds the first error in err's chain that can be assigned to target. If such an error is found, // it is assigned to target and true is returned, otherwise false is returned. func AsTraces(err error, target *Traces) bool { if err == nil { @@ -69,7 +69,7 @@ func NewLogs(err error, failed pdata.Logs) error { } } -// AsLogs finds the first error in err's chain that can be assigned to target. If such an error is found +// AsLogs finds the first error in err's chain that can be assigned to target. If such an error is found, // it is assigned to target and true is returned, otherwise false is returned. func AsLogs(err error, target *Logs) bool { if err == nil { @@ -103,7 +103,7 @@ func NewMetrics(err error, failed pdata.Metrics) error { } } -// AsMetrics finds the first error in err's chain that can be assigned to target. If such an error is found +// AsMetrics finds the first error in err's chain that can be assigned to target. If such an error is found, // it is assigned to target and true is returned, otherwise false is returned. func AsMetrics(err error, target *Metrics) bool { if err == nil { From f25c69932352dfdfc562237836c82c9eef0c0486 Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Fri, 21 May 2021 11:35:53 -0400 Subject: [PATCH 18/27] Cleaned up consumerhelper doc typos --- consumer/consumerhelper/common.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/consumer/consumerhelper/common.go b/consumer/consumerhelper/common.go index c314a3f3c71..bce9aba07a7 100644 --- a/consumer/consumerhelper/common.go +++ b/consumer/consumerhelper/common.go @@ -26,10 +26,10 @@ type baseConsumer struct { capabilities consumer.Capabilities } -// Option apply changes to internalOptions. +// Option applies changes to internalOptions. type Option func(*baseConsumer) -// WithCapabilities overrides the default GetCapabilities function for an processor. +// WithCapabilities overrides the default GetCapabilities function for a processor. // The default GetCapabilities function returns mutable capabilities. func WithCapabilities(capabilities consumer.Capabilities) Option { return func(o *baseConsumer) { From 3c7ac3b0a45b8eedd10970356893357bf8ba9b87 Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Fri, 21 May 2021 11:50:39 -0400 Subject: [PATCH 19/27] Updated docs in consumertest - Fixed wrong description of NewErr - Added doc for Capabilities method --- consumer/consumertest/base_consumer.go | 1 + consumer/consumertest/consumer.go | 6 +++--- consumer/consumertest/err.go | 2 +- consumer/consumertest/sink.go | 6 +++--- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/consumer/consumertest/base_consumer.go b/consumer/consumertest/base_consumer.go index 02b5b827aa6..420b205d919 100644 --- a/consumer/consumertest/base_consumer.go +++ b/consumer/consumertest/base_consumer.go @@ -20,6 +20,7 @@ import ( type nonMutatingConsumer struct{} +// Capabilities returns the base consumer capabilities. func (bc nonMutatingConsumer) Capabilities() consumer.Capabilities { return consumer.Capabilities{MutatesData: false} } diff --git a/consumer/consumertest/consumer.go b/consumer/consumertest/consumer.go index b009a1d41b6..f79972ce4f2 100644 --- a/consumer/consumertest/consumer.go +++ b/consumer/consumertest/consumer.go @@ -22,9 +22,9 @@ import ( ) // Consumer is a convenience interface that implements all consumer interfaces. -// It has a private function on it to forbid external users to implement it, -// to allow us to add extra functions without breaking compatibility because -// nobody else implements this interface. +// It has a private function on it to forbid external users from implementing it +// and, as a result, to allow us to add extra functions without breaking +// compatibility. type Consumer interface { // Capabilities to implement the base consumer functionality. Capabilities() consumer.Capabilities diff --git a/consumer/consumertest/err.go b/consumer/consumertest/err.go index 58d049071b1..5d43d5f20b8 100644 --- a/consumer/consumertest/err.go +++ b/consumer/consumertest/err.go @@ -39,7 +39,7 @@ func (er *errConsumer) ConsumeLogs(context.Context, pdata.Logs) error { return er.err } -// NewErr returns a Consumer that just drops all received data and returns no error. +// NewErr returns a Consumer that just drops all received data and holds the input error. func NewErr(err error) Consumer { return &errConsumer{err: err} } diff --git a/consumer/consumertest/sink.go b/consumer/consumertest/sink.go index 06ae77fdb6f..8d0232a7b74 100644 --- a/consumer/consumertest/sink.go +++ b/consumer/consumertest/sink.go @@ -54,7 +54,7 @@ func (ste *TracesSink) AllTraces() []pdata.Traces { return copyTraces } -// SpansCount return the number of spans sent to this sink. +// SpansCount returns the number of spans sent to this sink. func (ste *TracesSink) SpansCount() int { ste.mu.Lock() defer ste.mu.Unlock() @@ -102,7 +102,7 @@ func (sme *MetricsSink) AllMetrics() []pdata.Metrics { return copyMetrics } -// MetricsCount return the number of metrics stored by this sink since last Reset. +// MetricsCount returns the number of metrics stored by this sink since last Reset. func (sme *MetricsSink) MetricsCount() int { sme.mu.Lock() defer sme.mu.Unlock() @@ -150,7 +150,7 @@ func (sle *LogsSink) AllLogs() []pdata.Logs { return copyLogs } -// LogRecordsCount return the number of log records stored by this sink since last Reset. +// LogRecordsCount returns the number of log records stored by this sink since last Reset. func (sle *LogsSink) LogRecordsCount() int { sle.mu.Lock() defer sle.mu.Unlock() From 02477bf02faebb9a64af495f43facdfa21848d44 Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Mon, 24 May 2021 10:32:14 -0400 Subject: [PATCH 20/27] Update CHANGELOG.md --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae6f21ce44d..9ab9de2bdf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ - Remove unused logstest package (#3222) +## 💡 Enhancements 💡 + +- Improve documentation of consumer package and subpackages (#3269) + ## v0.27.0 Beta ## 🛑 Breaking changes 🛑 From 843295914c50f5528e1f03700f26603a3b924679 Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Mon, 24 May 2021 14:02:43 -0400 Subject: [PATCH 21/27] Fixed formatting errors in cmd/pdatagen Changing here will ensure that the changes to consumer/pdata/generated_* files will persist after running `go run cmd/pdatagen/main.go`. --- cmd/pdatagen/internal/base_slices.go | 44 ++++++++-------- cmd/pdatagen/internal/metrics_structs.go | 4 +- cmd/pdatagen/internal/resource_structs.go | 2 +- cmd/pdatagen/internal/trace_structs.go | 11 ++-- consumer/pdata/generated_common.go | 5 +- consumer/pdata/generated_common_test.go | 5 +- consumer/pdata/generated_log.go | 10 ++-- consumer/pdata/generated_log_test.go | 15 +++--- consumer/pdata/generated_metrics.go | 37 +++++-------- consumer/pdata/generated_metrics_test.go | 64 +++++++++++++++-------- consumer/pdata/generated_resource_test.go | 1 + consumer/pdata/generated_trace.go | 20 ++++--- consumer/pdata/generated_trace_test.go | 26 +++++---- 13 files changed, 131 insertions(+), 113 deletions(-) diff --git a/cmd/pdatagen/internal/base_slices.go b/cmd/pdatagen/internal/base_slices.go index 08071b34d01..66057197bc5 100644 --- a/cmd/pdatagen/internal/base_slices.go +++ b/cmd/pdatagen/internal/base_slices.go @@ -112,7 +112,7 @@ func fillTest${structName}(tv ${structName}) { const slicePtrTemplate = `// ${structName} logically represents a slice of ${elementName}. // -// This is a reference type, if passed by value and callee modifies it the +// This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // // Must use New${structName} function to create new instances. @@ -144,10 +144,10 @@ func (es ${structName}) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es ${structName}) At(ix int) ${elementName} { return new${elementName}((*es.orig)[ix]) } @@ -177,12 +177,12 @@ func (es ${structName}) CopyTo(dest ${structName}) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new ${structName} can be initialized: -// es := New${structName}() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := New${structName}() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es ${structName}) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -309,7 +309,7 @@ func Test${structName}_Append(t *testing.T) { const sliceValueTemplate = `// ${structName} logically represents a slice of ${elementName}. // -// This is a reference type, if passed by value and callee modifies it the +// This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // // Must use New${structName} function to create new instances. @@ -341,10 +341,10 @@ func (es ${structName}) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es ${structName}) At(ix int) ${elementName} { return new${elementName}(&(*es.orig)[ix]) } @@ -369,12 +369,12 @@ func (es ${structName}) CopyTo(dest ${structName}) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new ${structName} can be initialized: -// es := New${structName}() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := New${structName}() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es ${structName}) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) diff --git a/cmd/pdatagen/internal/metrics_structs.go b/cmd/pdatagen/internal/metrics_structs.go index 97c25455284..c46e3f71e48 100644 --- a/cmd/pdatagen/internal/metrics_structs.go +++ b/cmd/pdatagen/internal/metrics_structs.go @@ -66,7 +66,7 @@ var resourceMetricsSlice = &sliceOfPtrs{ var resourceMetrics = &messageValueStruct{ structName: "ResourceMetrics", - description: "// InstrumentationLibraryMetrics is a collection of metrics from a LibraryInstrumentation.", + description: "// ResourceMetrics is a collection of metrics from a Resource.", originFullName: "otlpmetrics.ResourceMetrics", fields: []baseField{ resourceField, @@ -332,7 +332,7 @@ var quantileValuesSlice = &sliceOfPtrs{ var quantileValues = &messageValueStruct{ structName: "ValueAtQuantile", - description: "// ValueAtQuantile is a quantile value within a Summary data point", + description: "// ValueAtQuantile is a quantile value within a Summary data point.", originFullName: "otlpmetrics.DoubleSummaryDataPoint_ValueAtQuantile", fields: []baseField{ quantileField, diff --git a/cmd/pdatagen/internal/resource_structs.go b/cmd/pdatagen/internal/resource_structs.go index 98e727b5f6c..f5167e7c5d4 100644 --- a/cmd/pdatagen/internal/resource_structs.go +++ b/cmd/pdatagen/internal/resource_structs.go @@ -31,7 +31,7 @@ var resourceFile = &File{ var resource = &messageValueStruct{ structName: "Resource", - description: "// Resource information.", + description: "// Resource is a message representing the resource information.", originFullName: "otlpresource.Resource", fields: []baseField{ attributes, diff --git a/cmd/pdatagen/internal/trace_structs.go b/cmd/pdatagen/internal/trace_structs.go index ead06c68ef1..6a37353c182 100644 --- a/cmd/pdatagen/internal/trace_structs.go +++ b/cmd/pdatagen/internal/trace_structs.go @@ -50,7 +50,7 @@ var resourceSpansSlice = &sliceOfPtrs{ var resourceSpans = &messageValueStruct{ structName: "ResourceSpans", - description: "// InstrumentationLibrarySpans is a collection of spans from a LibraryInstrumentation.", + description: "// ResourceSpans is a collection of spans from a Resource.", originFullName: "otlptrace.ResourceSpans", fields: []baseField{ resourceField, @@ -89,7 +89,7 @@ var spanSlice = &sliceOfPtrs{ var span = &messageValueStruct{ structName: "Span", description: "// Span represents a single operation within a trace.\n" + - "// See Span definition in OTLP: https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto#L37", + "// See Span definition in OTLP: https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto", originFullName: "otlptrace.Span", fields: []baseField{ traceIDField, @@ -167,7 +167,8 @@ var spanLinkSlice = &sliceOfPtrs{ var spanLink = &messageValueStruct{ structName: "SpanLink", description: "// SpanLink is a pointer from the current span to another span in the same trace or in a\n" + - "// different trace. See OTLP for link definition.", + "// different trace.\n" + + "// See Link definition in OTLP: https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto", originFullName: "otlptrace.Span_Link", fields: []baseField{ traceIDField, @@ -180,8 +181,8 @@ var spanLink = &messageValueStruct{ var spanStatus = &messageValueStruct{ structName: "SpanStatus", - description: "// SpanStatus is an optional final status for this span. Semantically when Status wasn't set\n" + - "// it is means span ended without errors and assume Status.Ok (code = 0).", + description: "// SpanStatus is an optional final status for this span. Semantically, when Status was not\n" + + "// set, that means the span ended without errors and to assume Status.Ok (code = 0).", originFullName: "otlptrace.Status", fields: []baseField{ &primitiveTypedField{ diff --git a/consumer/pdata/generated_common.go b/consumer/pdata/generated_common.go index 426f980ce92..97aa287b56d 100644 --- a/consumer/pdata/generated_common.go +++ b/consumer/pdata/generated_common.go @@ -71,7 +71,7 @@ func (ms InstrumentationLibrary) CopyTo(dest InstrumentationLibrary) { // AnyValueArray logically represents a slice of AttributeValue. // -// This is a reference type, if passed by value and callee modifies, it the +// This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // // Must use NewAnyValueArray function to create new instances. @@ -105,7 +105,7 @@ func (es AnyValueArray) Len() int { // This function is used mostly for iterating over all the values in the slice: // for i := 0; i < es.Len(); i++ { // e := es.At(i) -// // Do something with the element +// ... // Do something with the element // } func (es AnyValueArray) At(ix int) AttributeValue { return newAttributeValue(&(*es.orig)[ix]) @@ -173,7 +173,6 @@ func (es AnyValueArray) AppendEmpty() AttributeValue { *es.orig = append(*es.orig, otlpcommon.AnyValue{}) return es.At(es.Len() - 1) } - // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es AnyValueArray) MoveAndAppendTo(dest AnyValueArray) { diff --git a/consumer/pdata/generated_common_test.go b/consumer/pdata/generated_common_test.go index 2ae600c96ae..17821c758d8 100644 --- a/consumer/pdata/generated_common_test.go +++ b/consumer/pdata/generated_common_test.go @@ -25,6 +25,7 @@ import ( otlpcommon "go.opentelemetry.io/collector/internal/data/protogen/common/v1" ) + func TestInstrumentationLibrary_CopyTo(t *testing.T) { ms := NewInstrumentationLibrary() generateTestInstrumentationLibrary().CopyTo(ms) @@ -162,7 +163,7 @@ func TestAnyValueArray_MoveAndAppendTo(t *testing.T) { func TestAnyValueArray_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewAnyValueArray() - emptySlice.RemoveIf(func(el AttributeValue) bool { + emptySlice.RemoveIf(func (el AttributeValue) bool { t.Fail() return false }) @@ -170,7 +171,7 @@ func TestAnyValueArray_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestAnyValueArray() pos := 0 - filtered.RemoveIf(func(el AttributeValue) bool { + filtered.RemoveIf(func (el AttributeValue) bool { pos++ return pos%3 == 0 }) diff --git a/consumer/pdata/generated_log.go b/consumer/pdata/generated_log.go index 141c5ae0d4e..c71546e4de2 100644 --- a/consumer/pdata/generated_log.go +++ b/consumer/pdata/generated_log.go @@ -18,12 +18,13 @@ package pdata import ( + otlpcommon "go.opentelemetry.io/collector/internal/data/protogen/common/v1" otlplogs "go.opentelemetry.io/collector/internal/data/protogen/logs/v1" ) // ResourceLogsSlice logically represents a slice of ResourceLogs. // -// This is a reference type, if passed by value and callee modifies it the +// This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // // Must use NewResourceLogsSlice function to create new instances. @@ -130,7 +131,6 @@ func (es ResourceLogsSlice) AppendEmpty() ResourceLogs { *es.orig = append(*es.orig, &otlplogs.ResourceLogs{}) return es.At(es.Len() - 1) } - // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es ResourceLogsSlice) MoveAndAppendTo(dest ResourceLogsSlice) { @@ -203,7 +203,7 @@ func (ms ResourceLogs) CopyTo(dest ResourceLogs) { // InstrumentationLibraryLogsSlice logically represents a slice of InstrumentationLibraryLogs. // -// This is a reference type, if passed by value and callee modifies it the +// This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // // Must use NewInstrumentationLibraryLogsSlice function to create new instances. @@ -310,7 +310,6 @@ func (es InstrumentationLibraryLogsSlice) AppendEmpty() InstrumentationLibraryLo *es.orig = append(*es.orig, &otlplogs.InstrumentationLibraryLogs{}) return es.At(es.Len() - 1) } - // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es InstrumentationLibraryLogsSlice) MoveAndAppendTo(dest InstrumentationLibraryLogsSlice) { @@ -383,7 +382,7 @@ func (ms InstrumentationLibraryLogs) CopyTo(dest InstrumentationLibraryLogs) { // LogSlice logically represents a slice of LogRecord. // -// This is a reference type, if passed by value and callee modifies it the +// This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // // Must use NewLogSlice function to create new instances. @@ -490,7 +489,6 @@ func (es LogSlice) AppendEmpty() LogRecord { *es.orig = append(*es.orig, &otlplogs.LogRecord{}) return es.At(es.Len() - 1) } - // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es LogSlice) MoveAndAppendTo(dest LogSlice) { diff --git a/consumer/pdata/generated_log_test.go b/consumer/pdata/generated_log_test.go index ae5840c277b..782381157fc 100644 --- a/consumer/pdata/generated_log_test.go +++ b/consumer/pdata/generated_log_test.go @@ -140,7 +140,7 @@ func TestResourceLogsSlice_MoveAndAppendTo(t *testing.T) { func TestResourceLogsSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewResourceLogsSlice() - emptySlice.RemoveIf(func(el ResourceLogs) bool { + emptySlice.RemoveIf(func (el ResourceLogs) bool { t.Fail() return false }) @@ -148,13 +148,14 @@ func TestResourceLogsSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestResourceLogsSlice() pos := 0 - filtered.RemoveIf(func(el ResourceLogs) bool { + filtered.RemoveIf(func (el ResourceLogs) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } + func TestResourceLogs_CopyTo(t *testing.T) { ms := NewResourceLogs() generateTestResourceLogs().CopyTo(ms) @@ -290,7 +291,7 @@ func TestInstrumentationLibraryLogsSlice_MoveAndAppendTo(t *testing.T) { func TestInstrumentationLibraryLogsSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewInstrumentationLibraryLogsSlice() - emptySlice.RemoveIf(func(el InstrumentationLibraryLogs) bool { + emptySlice.RemoveIf(func (el InstrumentationLibraryLogs) bool { t.Fail() return false }) @@ -298,13 +299,14 @@ func TestInstrumentationLibraryLogsSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestInstrumentationLibraryLogsSlice() pos := 0 - filtered.RemoveIf(func(el InstrumentationLibraryLogs) bool { + filtered.RemoveIf(func (el InstrumentationLibraryLogs) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } + func TestInstrumentationLibraryLogs_CopyTo(t *testing.T) { ms := NewInstrumentationLibraryLogs() generateTestInstrumentationLibraryLogs().CopyTo(ms) @@ -440,7 +442,7 @@ func TestLogSlice_MoveAndAppendTo(t *testing.T) { func TestLogSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewLogSlice() - emptySlice.RemoveIf(func(el LogRecord) bool { + emptySlice.RemoveIf(func (el LogRecord) bool { t.Fail() return false }) @@ -448,13 +450,14 @@ func TestLogSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestLogSlice() pos := 0 - filtered.RemoveIf(func(el LogRecord) bool { + filtered.RemoveIf(func (el LogRecord) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } + func TestLogRecord_CopyTo(t *testing.T) { ms := NewLogRecord() generateTestLogRecord().CopyTo(ms) diff --git a/consumer/pdata/generated_metrics.go b/consumer/pdata/generated_metrics.go index 1138014255e..768a6f1009b 100644 --- a/consumer/pdata/generated_metrics.go +++ b/consumer/pdata/generated_metrics.go @@ -23,7 +23,7 @@ import ( // ResourceMetricsSlice logically represents a slice of ResourceMetrics. // -// This is a reference type, if passed by value and callee modifies it the +// This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // // Must use NewResourceMetricsSlice function to create new instances. @@ -130,7 +130,6 @@ func (es ResourceMetricsSlice) AppendEmpty() ResourceMetrics { *es.orig = append(*es.orig, &otlpmetrics.ResourceMetrics{}) return es.At(es.Len() - 1) } - // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es ResourceMetricsSlice) MoveAndAppendTo(dest ResourceMetricsSlice) { @@ -203,7 +202,7 @@ func (ms ResourceMetrics) CopyTo(dest ResourceMetrics) { // InstrumentationLibraryMetricsSlice logically represents a slice of InstrumentationLibraryMetrics. // -// This is a reference type, if passed by value and callee modifies it the +// This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // // Must use NewInstrumentationLibraryMetricsSlice function to create new instances. @@ -267,7 +266,7 @@ func (es InstrumentationLibraryMetricsSlice) CopyTo(dest InstrumentationLibraryM // 1. If the newLen <= len then equivalent with slice[0:newLen:cap]. // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // -// Here is how a new InstrumentationLibraryMetricsSlice can be initialized: +// Here is how a new InstrumentationLibraryMetricsSlice can be initialized: // es := NewInstrumentationLibraryMetricsSlice() // es.Resize(4) // for i := 0; i < es.Len(); i++ { @@ -310,7 +309,6 @@ func (es InstrumentationLibraryMetricsSlice) AppendEmpty() InstrumentationLibrar *es.orig = append(*es.orig, &otlpmetrics.InstrumentationLibraryMetrics{}) return es.At(es.Len() - 1) } - // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es InstrumentationLibraryMetricsSlice) MoveAndAppendTo(dest InstrumentationLibraryMetricsSlice) { @@ -383,7 +381,7 @@ func (ms InstrumentationLibraryMetrics) CopyTo(dest InstrumentationLibraryMetric // MetricSlice logically represents a slice of Metric. // -// This is a reference type, if passed by value and callee modifies it the +// This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // // Must use NewMetricSlice function to create new instances. @@ -490,7 +488,6 @@ func (es MetricSlice) AppendEmpty() Metric { *es.orig = append(*es.orig, &otlpmetrics.Metric{}) return es.At(es.Len() - 1) } - // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es MetricSlice) MoveAndAppendTo(dest MetricSlice) { @@ -576,6 +573,8 @@ func (ms Metric) SetUnit(v string) { (*ms.orig).Unit = v } + + // CopyTo copies all properties from the current struct to the dest. func (ms Metric) CopyTo(dest Metric) { dest.SetName(ms.Name()) @@ -876,7 +875,7 @@ func (ms Summary) CopyTo(dest Summary) { // IntDataPointSlice logically represents a slice of IntDataPoint. // -// This is a reference type, if passed by value and callee modifies it the +// This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // // Must use NewIntDataPointSlice function to create new instances. @@ -983,7 +982,6 @@ func (es IntDataPointSlice) AppendEmpty() IntDataPoint { *es.orig = append(*es.orig, &otlpmetrics.IntDataPoint{}) return es.At(es.Len() - 1) } - // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es IntDataPointSlice) MoveAndAppendTo(dest IntDataPointSlice) { @@ -1089,7 +1087,7 @@ func (ms IntDataPoint) CopyTo(dest IntDataPoint) { // DoubleDataPointSlice logically represents a slice of DoubleDataPoint. // -// This is a reference type, if passed by value and callee modifies it the +// This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // // Must use NewDoubleDataPointSlice function to create new instances. @@ -1196,7 +1194,6 @@ func (es DoubleDataPointSlice) AppendEmpty() DoubleDataPoint { *es.orig = append(*es.orig, &otlpmetrics.DoubleDataPoint{}) return es.At(es.Len() - 1) } - // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es DoubleDataPointSlice) MoveAndAppendTo(dest DoubleDataPointSlice) { @@ -1302,7 +1299,7 @@ func (ms DoubleDataPoint) CopyTo(dest DoubleDataPoint) { // IntHistogramDataPointSlice logically represents a slice of IntHistogramDataPoint. // -// This is a reference type, if passed by value and callee modifies it the +// This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // // Must use NewIntHistogramDataPointSlice function to create new instances. @@ -1409,7 +1406,6 @@ func (es IntHistogramDataPointSlice) AppendEmpty() IntHistogramDataPoint { *es.orig = append(*es.orig, &otlpmetrics.IntHistogramDataPoint{}) return es.At(es.Len() - 1) } - // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es IntHistogramDataPointSlice) MoveAndAppendTo(dest IntHistogramDataPointSlice) { @@ -1548,7 +1544,7 @@ func (ms IntHistogramDataPoint) CopyTo(dest IntHistogramDataPoint) { // HistogramDataPointSlice logically represents a slice of HistogramDataPoint. // -// This is a reference type, if passed by value and callee modifies it the +// This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // // Must use NewHistogramDataPointSlice function to create new instances. @@ -1655,7 +1651,6 @@ func (es HistogramDataPointSlice) AppendEmpty() HistogramDataPoint { *es.orig = append(*es.orig, &otlpmetrics.DoubleHistogramDataPoint{}) return es.At(es.Len() - 1) } - // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es HistogramDataPointSlice) MoveAndAppendTo(dest HistogramDataPointSlice) { @@ -1794,7 +1789,7 @@ func (ms HistogramDataPoint) CopyTo(dest HistogramDataPoint) { // SummaryDataPointSlice logically represents a slice of SummaryDataPoint. // -// This is a reference type, if passed by value and callee modifies it the +// This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // // Must use NewSummaryDataPointSlice function to create new instances. @@ -1901,7 +1896,6 @@ func (es SummaryDataPointSlice) AppendEmpty() SummaryDataPoint { *es.orig = append(*es.orig, &otlpmetrics.DoubleSummaryDataPoint{}) return es.At(es.Len() - 1) } - // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es SummaryDataPointSlice) MoveAndAppendTo(dest SummaryDataPointSlice) { @@ -2018,7 +2012,7 @@ func (ms SummaryDataPoint) CopyTo(dest SummaryDataPoint) { // ValueAtQuantileSlice logically represents a slice of ValueAtQuantile. // -// This is a reference type, if passed by value and callee modifies it the +// This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // // Must use NewValueAtQuantileSlice function to create new instances. @@ -2125,7 +2119,6 @@ func (es ValueAtQuantileSlice) AppendEmpty() ValueAtQuantile { *es.orig = append(*es.orig, &otlpmetrics.DoubleSummaryDataPoint_ValueAtQuantile{}) return es.At(es.Len() - 1) } - // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es ValueAtQuantileSlice) MoveAndAppendTo(dest ValueAtQuantileSlice) { @@ -2208,7 +2201,7 @@ func (ms ValueAtQuantile) CopyTo(dest ValueAtQuantile) { // IntExemplarSlice logically represents a slice of IntExemplar. // -// This is a reference type, if passed by value and callee modifies it the +// This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // // Must use NewIntExemplarSlice function to create new instances. @@ -2310,7 +2303,6 @@ func (es IntExemplarSlice) AppendEmpty() IntExemplar { *es.orig = append(*es.orig, otlpmetrics.IntExemplar{}) return es.At(es.Len() - 1) } - // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es IntExemplarSlice) MoveAndAppendTo(dest IntExemplarSlice) { @@ -2402,7 +2394,7 @@ func (ms IntExemplar) CopyTo(dest IntExemplar) { // ExemplarSlice logically represents a slice of Exemplar. // -// This is a reference type, if passed by value and callee modifies it the +// This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // // Must use NewExemplarSlice function to create new instances. @@ -2504,7 +2496,6 @@ func (es ExemplarSlice) AppendEmpty() Exemplar { *es.orig = append(*es.orig, otlpmetrics.DoubleExemplar{}) return es.At(es.Len() - 1) } - // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es ExemplarSlice) MoveAndAppendTo(dest ExemplarSlice) { diff --git a/consumer/pdata/generated_metrics_test.go b/consumer/pdata/generated_metrics_test.go index 7b36a748454..4c405e27bde 100644 --- a/consumer/pdata/generated_metrics_test.go +++ b/consumer/pdata/generated_metrics_test.go @@ -140,7 +140,7 @@ func TestResourceMetricsSlice_MoveAndAppendTo(t *testing.T) { func TestResourceMetricsSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewResourceMetricsSlice() - emptySlice.RemoveIf(func(el ResourceMetrics) bool { + emptySlice.RemoveIf(func (el ResourceMetrics) bool { t.Fail() return false }) @@ -148,13 +148,14 @@ func TestResourceMetricsSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestResourceMetricsSlice() pos := 0 - filtered.RemoveIf(func(el ResourceMetrics) bool { + filtered.RemoveIf(func (el ResourceMetrics) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } + func TestResourceMetrics_CopyTo(t *testing.T) { ms := NewResourceMetrics() generateTestResourceMetrics().CopyTo(ms) @@ -290,7 +291,7 @@ func TestInstrumentationLibraryMetricsSlice_MoveAndAppendTo(t *testing.T) { func TestInstrumentationLibraryMetricsSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewInstrumentationLibraryMetricsSlice() - emptySlice.RemoveIf(func(el InstrumentationLibraryMetrics) bool { + emptySlice.RemoveIf(func (el InstrumentationLibraryMetrics) bool { t.Fail() return false }) @@ -298,13 +299,14 @@ func TestInstrumentationLibraryMetricsSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestInstrumentationLibraryMetricsSlice() pos := 0 - filtered.RemoveIf(func(el InstrumentationLibraryMetrics) bool { + filtered.RemoveIf(func (el InstrumentationLibraryMetrics) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } + func TestInstrumentationLibraryMetrics_CopyTo(t *testing.T) { ms := NewInstrumentationLibraryMetrics() generateTestInstrumentationLibraryMetrics().CopyTo(ms) @@ -440,7 +442,7 @@ func TestMetricSlice_MoveAndAppendTo(t *testing.T) { func TestMetricSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewMetricSlice() - emptySlice.RemoveIf(func(el Metric) bool { + emptySlice.RemoveIf(func (el Metric) bool { t.Fail() return false }) @@ -448,13 +450,14 @@ func TestMetricSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestMetricSlice() pos := 0 - filtered.RemoveIf(func(el Metric) bool { + filtered.RemoveIf(func (el Metric) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } + func TestMetric_CopyTo(t *testing.T) { ms := NewMetric() generateTestMetric().CopyTo(ms) @@ -485,6 +488,9 @@ func TestMetric_Unit(t *testing.T) { assert.EqualValues(t, testValUnit, ms.Unit()) } + + + func TestIntGauge_CopyTo(t *testing.T) { ms := NewIntGauge() generateTestIntGauge().CopyTo(ms) @@ -499,6 +505,7 @@ func TestIntGauge_DataPoints(t *testing.T) { assert.EqualValues(t, testValDataPoints, ms.DataPoints()) } + func TestDoubleGauge_CopyTo(t *testing.T) { ms := NewDoubleGauge() generateTestDoubleGauge().CopyTo(ms) @@ -513,6 +520,7 @@ func TestDoubleGauge_DataPoints(t *testing.T) { assert.EqualValues(t, testValDataPoints, ms.DataPoints()) } + func TestIntSum_CopyTo(t *testing.T) { ms := NewIntSum() generateTestIntSum().CopyTo(ms) @@ -543,6 +551,7 @@ func TestIntSum_DataPoints(t *testing.T) { assert.EqualValues(t, testValDataPoints, ms.DataPoints()) } + func TestDoubleSum_CopyTo(t *testing.T) { ms := NewDoubleSum() generateTestDoubleSum().CopyTo(ms) @@ -573,6 +582,7 @@ func TestDoubleSum_DataPoints(t *testing.T) { assert.EqualValues(t, testValDataPoints, ms.DataPoints()) } + func TestIntHistogram_CopyTo(t *testing.T) { ms := NewIntHistogram() generateTestIntHistogram().CopyTo(ms) @@ -595,6 +605,7 @@ func TestIntHistogram_DataPoints(t *testing.T) { assert.EqualValues(t, testValDataPoints, ms.DataPoints()) } + func TestHistogram_CopyTo(t *testing.T) { ms := NewHistogram() generateTestHistogram().CopyTo(ms) @@ -617,6 +628,7 @@ func TestHistogram_DataPoints(t *testing.T) { assert.EqualValues(t, testValDataPoints, ms.DataPoints()) } + func TestSummary_CopyTo(t *testing.T) { ms := NewSummary() generateTestSummary().CopyTo(ms) @@ -746,7 +758,7 @@ func TestIntDataPointSlice_MoveAndAppendTo(t *testing.T) { func TestIntDataPointSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewIntDataPointSlice() - emptySlice.RemoveIf(func(el IntDataPoint) bool { + emptySlice.RemoveIf(func (el IntDataPoint) bool { t.Fail() return false }) @@ -754,13 +766,14 @@ func TestIntDataPointSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestIntDataPointSlice() pos := 0 - filtered.RemoveIf(func(el IntDataPoint) bool { + filtered.RemoveIf(func (el IntDataPoint) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } + func TestIntDataPoint_CopyTo(t *testing.T) { ms := NewIntDataPoint() generateTestIntDataPoint().CopyTo(ms) @@ -922,7 +935,7 @@ func TestDoubleDataPointSlice_MoveAndAppendTo(t *testing.T) { func TestDoubleDataPointSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewDoubleDataPointSlice() - emptySlice.RemoveIf(func(el DoubleDataPoint) bool { + emptySlice.RemoveIf(func (el DoubleDataPoint) bool { t.Fail() return false }) @@ -930,13 +943,14 @@ func TestDoubleDataPointSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestDoubleDataPointSlice() pos := 0 - filtered.RemoveIf(func(el DoubleDataPoint) bool { + filtered.RemoveIf(func (el DoubleDataPoint) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } + func TestDoubleDataPoint_CopyTo(t *testing.T) { ms := NewDoubleDataPoint() generateTestDoubleDataPoint().CopyTo(ms) @@ -1098,7 +1112,7 @@ func TestIntHistogramDataPointSlice_MoveAndAppendTo(t *testing.T) { func TestIntHistogramDataPointSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewIntHistogramDataPointSlice() - emptySlice.RemoveIf(func(el IntHistogramDataPoint) bool { + emptySlice.RemoveIf(func (el IntHistogramDataPoint) bool { t.Fail() return false }) @@ -1106,13 +1120,14 @@ func TestIntHistogramDataPointSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestIntHistogramDataPointSlice() pos := 0 - filtered.RemoveIf(func(el IntHistogramDataPoint) bool { + filtered.RemoveIf(func (el IntHistogramDataPoint) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } + func TestIntHistogramDataPoint_CopyTo(t *testing.T) { ms := NewIntHistogramDataPoint() generateTestIntHistogramDataPoint().CopyTo(ms) @@ -1298,7 +1313,7 @@ func TestHistogramDataPointSlice_MoveAndAppendTo(t *testing.T) { func TestHistogramDataPointSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewHistogramDataPointSlice() - emptySlice.RemoveIf(func(el HistogramDataPoint) bool { + emptySlice.RemoveIf(func (el HistogramDataPoint) bool { t.Fail() return false }) @@ -1306,13 +1321,14 @@ func TestHistogramDataPointSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestHistogramDataPointSlice() pos := 0 - filtered.RemoveIf(func(el HistogramDataPoint) bool { + filtered.RemoveIf(func (el HistogramDataPoint) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } + func TestHistogramDataPoint_CopyTo(t *testing.T) { ms := NewHistogramDataPoint() generateTestHistogramDataPoint().CopyTo(ms) @@ -1498,7 +1514,7 @@ func TestSummaryDataPointSlice_MoveAndAppendTo(t *testing.T) { func TestSummaryDataPointSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewSummaryDataPointSlice() - emptySlice.RemoveIf(func(el SummaryDataPoint) bool { + emptySlice.RemoveIf(func (el SummaryDataPoint) bool { t.Fail() return false }) @@ -1506,13 +1522,14 @@ func TestSummaryDataPointSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestSummaryDataPointSlice() pos := 0 - filtered.RemoveIf(func(el SummaryDataPoint) bool { + filtered.RemoveIf(func (el SummaryDataPoint) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } + func TestSummaryDataPoint_CopyTo(t *testing.T) { ms := NewSummaryDataPoint() generateTestSummaryDataPoint().CopyTo(ms) @@ -1682,7 +1699,7 @@ func TestValueAtQuantileSlice_MoveAndAppendTo(t *testing.T) { func TestValueAtQuantileSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewValueAtQuantileSlice() - emptySlice.RemoveIf(func(el ValueAtQuantile) bool { + emptySlice.RemoveIf(func (el ValueAtQuantile) bool { t.Fail() return false }) @@ -1690,13 +1707,14 @@ func TestValueAtQuantileSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestValueAtQuantileSlice() pos := 0 - filtered.RemoveIf(func(el ValueAtQuantile) bool { + filtered.RemoveIf(func (el ValueAtQuantile) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } + func TestValueAtQuantile_CopyTo(t *testing.T) { ms := NewValueAtQuantile() generateTestValueAtQuantile().CopyTo(ms) @@ -1834,7 +1852,7 @@ func TestIntExemplarSlice_MoveAndAppendTo(t *testing.T) { func TestIntExemplarSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewIntExemplarSlice() - emptySlice.RemoveIf(func(el IntExemplar) bool { + emptySlice.RemoveIf(func (el IntExemplar) bool { t.Fail() return false }) @@ -1842,13 +1860,14 @@ func TestIntExemplarSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestIntExemplarSlice() pos := 0 - filtered.RemoveIf(func(el IntExemplar) bool { + filtered.RemoveIf(func (el IntExemplar) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } + func TestIntExemplar_CopyTo(t *testing.T) { ms := NewIntExemplar() generateTestIntExemplar().CopyTo(ms) @@ -1994,7 +2013,7 @@ func TestExemplarSlice_MoveAndAppendTo(t *testing.T) { func TestExemplarSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewExemplarSlice() - emptySlice.RemoveIf(func(el Exemplar) bool { + emptySlice.RemoveIf(func (el Exemplar) bool { t.Fail() return false }) @@ -2002,13 +2021,14 @@ func TestExemplarSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestExemplarSlice() pos := 0 - filtered.RemoveIf(func(el Exemplar) bool { + filtered.RemoveIf(func (el Exemplar) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } + func TestExemplar_CopyTo(t *testing.T) { ms := NewExemplar() generateTestExemplar().CopyTo(ms) diff --git a/consumer/pdata/generated_resource_test.go b/consumer/pdata/generated_resource_test.go index cff3992e35f..b96b74e5fa7 100644 --- a/consumer/pdata/generated_resource_test.go +++ b/consumer/pdata/generated_resource_test.go @@ -23,6 +23,7 @@ import ( "github.com/stretchr/testify/assert" ) + func TestResource_CopyTo(t *testing.T) { ms := NewResource() generateTestResource().CopyTo(ms) diff --git a/consumer/pdata/generated_trace.go b/consumer/pdata/generated_trace.go index 3bbffd1100e..aeab06fff05 100644 --- a/consumer/pdata/generated_trace.go +++ b/consumer/pdata/generated_trace.go @@ -18,12 +18,14 @@ package pdata import ( + "go.opentelemetry.io/collector/internal/data" + otlpcommon "go.opentelemetry.io/collector/internal/data/protogen/common/v1" otlptrace "go.opentelemetry.io/collector/internal/data/protogen/trace/v1" ) // ResourceSpansSlice logically represents a slice of ResourceSpans. // -// This is a reference type, if passed by value and callee modifies it the +// This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // // Must use NewResourceSpansSlice function to create new instances. @@ -130,7 +132,6 @@ func (es ResourceSpansSlice) AppendEmpty() ResourceSpans { *es.orig = append(*es.orig, &otlptrace.ResourceSpans{}) return es.At(es.Len() - 1) } - // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es ResourceSpansSlice) MoveAndAppendTo(dest ResourceSpansSlice) { @@ -203,7 +204,7 @@ func (ms ResourceSpans) CopyTo(dest ResourceSpans) { // InstrumentationLibrarySpansSlice logically represents a slice of InstrumentationLibrarySpans. // -// This is a reference type, if passed by value and callee modifies it the +// This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // // Must use NewInstrumentationLibrarySpansSlice function to create new instances. @@ -310,7 +311,6 @@ func (es InstrumentationLibrarySpansSlice) AppendEmpty() InstrumentationLibraryS *es.orig = append(*es.orig, &otlptrace.InstrumentationLibrarySpans{}) return es.At(es.Len() - 1) } - // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es InstrumentationLibrarySpansSlice) MoveAndAppendTo(dest InstrumentationLibrarySpansSlice) { @@ -383,7 +383,7 @@ func (ms InstrumentationLibrarySpans) CopyTo(dest InstrumentationLibrarySpans) { // SpanSlice logically represents a slice of Span. // -// This is a reference type, if passed by value and callee modifies it the +// This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // // Must use NewSpanSlice function to create new instances. @@ -490,7 +490,6 @@ func (es SpanSlice) AppendEmpty() Span { *es.orig = append(*es.orig, &otlptrace.Span{}) return es.At(es.Len() - 1) } - // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es SpanSlice) MoveAndAppendTo(dest SpanSlice) { @@ -697,7 +696,7 @@ func (ms Span) CopyTo(dest Span) { // SpanEventSlice logically represents a slice of SpanEvent. // -// This is a reference type, if passed by value and callee modifies it the +// This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // // Must use NewSpanEventSlice function to create new instances. @@ -804,7 +803,6 @@ func (es SpanEventSlice) AppendEmpty() SpanEvent { *es.orig = append(*es.orig, &otlptrace.Span_Event{}) return es.At(es.Len() - 1) } - // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es SpanEventSlice) MoveAndAppendTo(dest SpanEventSlice) { @@ -905,7 +903,7 @@ func (ms SpanEvent) CopyTo(dest SpanEvent) { // SpanLinkSlice logically represents a slice of SpanLink. // -// This is a reference type, if passed by value and callee modifies it the +// This is a reference type. If passed by value and callee modifies it, the // caller will see the modification. // // Must use NewSpanLinkSlice function to create new instances. @@ -1012,7 +1010,6 @@ func (es SpanLinkSlice) AppendEmpty() SpanLink { *es.orig = append(*es.orig, &otlptrace.Span_Link{}) return es.At(es.Len() - 1) } - // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es SpanLinkSlice) MoveAndAppendTo(dest SpanLinkSlice) { @@ -1046,7 +1043,8 @@ func (es SpanLinkSlice) RemoveIf(f func(SpanLink) bool) { } // SpanLink is a pointer from the current span to another span in the same trace or in a -// different trace. See Link definition in OTLP: https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto +// different trace. +// See Link definition in OTLP: https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto // // This is a reference type, if passed by value and callee modifies it the // caller will see the modification. diff --git a/consumer/pdata/generated_trace_test.go b/consumer/pdata/generated_trace_test.go index f80dae0fcfb..3a38e2b6976 100644 --- a/consumer/pdata/generated_trace_test.go +++ b/consumer/pdata/generated_trace_test.go @@ -140,7 +140,7 @@ func TestResourceSpansSlice_MoveAndAppendTo(t *testing.T) { func TestResourceSpansSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewResourceSpansSlice() - emptySlice.RemoveIf(func(el ResourceSpans) bool { + emptySlice.RemoveIf(func (el ResourceSpans) bool { t.Fail() return false }) @@ -148,13 +148,14 @@ func TestResourceSpansSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestResourceSpansSlice() pos := 0 - filtered.RemoveIf(func(el ResourceSpans) bool { + filtered.RemoveIf(func (el ResourceSpans) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } + func TestResourceSpans_CopyTo(t *testing.T) { ms := NewResourceSpans() generateTestResourceSpans().CopyTo(ms) @@ -290,7 +291,7 @@ func TestInstrumentationLibrarySpansSlice_MoveAndAppendTo(t *testing.T) { func TestInstrumentationLibrarySpansSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewInstrumentationLibrarySpansSlice() - emptySlice.RemoveIf(func(el InstrumentationLibrarySpans) bool { + emptySlice.RemoveIf(func (el InstrumentationLibrarySpans) bool { t.Fail() return false }) @@ -298,13 +299,14 @@ func TestInstrumentationLibrarySpansSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestInstrumentationLibrarySpansSlice() pos := 0 - filtered.RemoveIf(func(el InstrumentationLibrarySpans) bool { + filtered.RemoveIf(func (el InstrumentationLibrarySpans) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } + func TestInstrumentationLibrarySpans_CopyTo(t *testing.T) { ms := NewInstrumentationLibrarySpans() generateTestInstrumentationLibrarySpans().CopyTo(ms) @@ -440,7 +442,7 @@ func TestSpanSlice_MoveAndAppendTo(t *testing.T) { func TestSpanSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewSpanSlice() - emptySlice.RemoveIf(func(el Span) bool { + emptySlice.RemoveIf(func (el Span) bool { t.Fail() return false }) @@ -448,13 +450,14 @@ func TestSpanSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestSpanSlice() pos := 0 - filtered.RemoveIf(func(el Span) bool { + filtered.RemoveIf(func (el Span) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } + func TestSpan_CopyTo(t *testing.T) { ms := NewSpan() generateTestSpan().CopyTo(ms) @@ -694,7 +697,7 @@ func TestSpanEventSlice_MoveAndAppendTo(t *testing.T) { func TestSpanEventSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewSpanEventSlice() - emptySlice.RemoveIf(func(el SpanEvent) bool { + emptySlice.RemoveIf(func (el SpanEvent) bool { t.Fail() return false }) @@ -702,13 +705,14 @@ func TestSpanEventSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestSpanEventSlice() pos := 0 - filtered.RemoveIf(func(el SpanEvent) bool { + filtered.RemoveIf(func (el SpanEvent) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } + func TestSpanEvent_CopyTo(t *testing.T) { ms := NewSpanEvent() generateTestSpanEvent().CopyTo(ms) @@ -862,7 +866,7 @@ func TestSpanLinkSlice_MoveAndAppendTo(t *testing.T) { func TestSpanLinkSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewSpanLinkSlice() - emptySlice.RemoveIf(func(el SpanLink) bool { + emptySlice.RemoveIf(func (el SpanLink) bool { t.Fail() return false }) @@ -870,13 +874,14 @@ func TestSpanLinkSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestSpanLinkSlice() pos := 0 - filtered.RemoveIf(func(el SpanLink) bool { + filtered.RemoveIf(func (el SpanLink) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } + func TestSpanLink_CopyTo(t *testing.T) { ms := NewSpanLink() generateTestSpanLink().CopyTo(ms) @@ -923,6 +928,7 @@ func TestSpanLink_DroppedAttributesCount(t *testing.T) { assert.EqualValues(t, testValDroppedAttributesCount, ms.DroppedAttributesCount()) } + func TestSpanStatus_CopyTo(t *testing.T) { ms := NewSpanStatus() generateTestSpanStatus().CopyTo(ms) From d2c51e4edbb4ec1deb67a5ad7cf02e1ef2887d48 Mon Sep 17 00:00:00 2001 From: Edward Lin Date: Wed, 26 May 2021 12:45:48 -0400 Subject: [PATCH 22/27] Removed unused imports --- cmd/pdatagen/internal/log_structs.go | 1 - cmd/pdatagen/internal/trace_structs.go | 2 -- consumer/pdata/generated_log.go | 1 - consumer/pdata/generated_trace.go | 2 -- 4 files changed, 6 deletions(-) diff --git a/cmd/pdatagen/internal/log_structs.go b/cmd/pdatagen/internal/log_structs.go index e267c32cf03..08f88812a07 100644 --- a/cmd/pdatagen/internal/log_structs.go +++ b/cmd/pdatagen/internal/log_structs.go @@ -17,7 +17,6 @@ package internal var logFile = &File{ Name: "log", imports: []string{ - `otlpcommon "go.opentelemetry.io/collector/internal/data/protogen/common/v1"`, `otlplogs "go.opentelemetry.io/collector/internal/data/protogen/logs/v1"`, }, testImports: []string{ diff --git a/cmd/pdatagen/internal/trace_structs.go b/cmd/pdatagen/internal/trace_structs.go index 6a37353c182..56b9367ad99 100644 --- a/cmd/pdatagen/internal/trace_structs.go +++ b/cmd/pdatagen/internal/trace_structs.go @@ -17,8 +17,6 @@ package internal var traceFile = &File{ Name: "trace", imports: []string{ - `"go.opentelemetry.io/collector/internal/data"`, - `otlpcommon "go.opentelemetry.io/collector/internal/data/protogen/common/v1"`, `otlptrace "go.opentelemetry.io/collector/internal/data/protogen/trace/v1"`, }, testImports: []string{ diff --git a/consumer/pdata/generated_log.go b/consumer/pdata/generated_log.go index c71546e4de2..cc3810235fd 100644 --- a/consumer/pdata/generated_log.go +++ b/consumer/pdata/generated_log.go @@ -18,7 +18,6 @@ package pdata import ( - otlpcommon "go.opentelemetry.io/collector/internal/data/protogen/common/v1" otlplogs "go.opentelemetry.io/collector/internal/data/protogen/logs/v1" ) diff --git a/consumer/pdata/generated_trace.go b/consumer/pdata/generated_trace.go index aeab06fff05..2af21f75234 100644 --- a/consumer/pdata/generated_trace.go +++ b/consumer/pdata/generated_trace.go @@ -18,8 +18,6 @@ package pdata import ( - "go.opentelemetry.io/collector/internal/data" - otlpcommon "go.opentelemetry.io/collector/internal/data/protogen/common/v1" otlptrace "go.opentelemetry.io/collector/internal/data/protogen/trace/v1" ) From f4feaa9f595c582ec9706ed8cd426856646af729 Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Wed, 2 Jun 2021 17:55:57 -0400 Subject: [PATCH 23/27] Update CHANGELOG.md --- CHANGELOG.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e58419087d4..586de3fbfc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,10 +12,7 @@ ## 💡 Enhancements 💡 - Add `doc.go` files to the consumer package and its subpackages (#3270) - -## 💡 Enhancements 💡 - -- Improve documentation of consumer package and subpackages (#3269) +- Improve documentation of consumer package and subpackages (#3269, #3361) ## v0.27.0 Beta From 8409b7dcaa64e8e57a418bffd347daa1f6a9c4b1 Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Wed, 2 Jun 2021 18:06:00 -0400 Subject: [PATCH 24/27] Fixed generated code lint failures --- consumer/pdata/generated_common.go | 1 + consumer/pdata/generated_common_test.go | 5 +- consumer/pdata/generated_log.go | 3 ++ consumer/pdata/generated_log_test.go | 15 +++--- consumer/pdata/generated_metrics.go | 13 ++++- consumer/pdata/generated_metrics_test.go | 64 ++++++++--------------- consumer/pdata/generated_resource_test.go | 1 - consumer/pdata/generated_trace.go | 5 ++ consumer/pdata/generated_trace_test.go | 26 ++++----- 9 files changed, 60 insertions(+), 73 deletions(-) diff --git a/consumer/pdata/generated_common.go b/consumer/pdata/generated_common.go index 97aa287b56d..a726420ccc0 100644 --- a/consumer/pdata/generated_common.go +++ b/consumer/pdata/generated_common.go @@ -173,6 +173,7 @@ func (es AnyValueArray) AppendEmpty() AttributeValue { *es.orig = append(*es.orig, otlpcommon.AnyValue{}) return es.At(es.Len() - 1) } + // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es AnyValueArray) MoveAndAppendTo(dest AnyValueArray) { diff --git a/consumer/pdata/generated_common_test.go b/consumer/pdata/generated_common_test.go index 17821c758d8..2ae600c96ae 100644 --- a/consumer/pdata/generated_common_test.go +++ b/consumer/pdata/generated_common_test.go @@ -25,7 +25,6 @@ import ( otlpcommon "go.opentelemetry.io/collector/internal/data/protogen/common/v1" ) - func TestInstrumentationLibrary_CopyTo(t *testing.T) { ms := NewInstrumentationLibrary() generateTestInstrumentationLibrary().CopyTo(ms) @@ -163,7 +162,7 @@ func TestAnyValueArray_MoveAndAppendTo(t *testing.T) { func TestAnyValueArray_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewAnyValueArray() - emptySlice.RemoveIf(func (el AttributeValue) bool { + emptySlice.RemoveIf(func(el AttributeValue) bool { t.Fail() return false }) @@ -171,7 +170,7 @@ func TestAnyValueArray_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestAnyValueArray() pos := 0 - filtered.RemoveIf(func (el AttributeValue) bool { + filtered.RemoveIf(func(el AttributeValue) bool { pos++ return pos%3 == 0 }) diff --git a/consumer/pdata/generated_log.go b/consumer/pdata/generated_log.go index cc3810235fd..7c1ed7e1544 100644 --- a/consumer/pdata/generated_log.go +++ b/consumer/pdata/generated_log.go @@ -130,6 +130,7 @@ func (es ResourceLogsSlice) AppendEmpty() ResourceLogs { *es.orig = append(*es.orig, &otlplogs.ResourceLogs{}) return es.At(es.Len() - 1) } + // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es ResourceLogsSlice) MoveAndAppendTo(dest ResourceLogsSlice) { @@ -309,6 +310,7 @@ func (es InstrumentationLibraryLogsSlice) AppendEmpty() InstrumentationLibraryLo *es.orig = append(*es.orig, &otlplogs.InstrumentationLibraryLogs{}) return es.At(es.Len() - 1) } + // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es InstrumentationLibraryLogsSlice) MoveAndAppendTo(dest InstrumentationLibraryLogsSlice) { @@ -488,6 +490,7 @@ func (es LogSlice) AppendEmpty() LogRecord { *es.orig = append(*es.orig, &otlplogs.LogRecord{}) return es.At(es.Len() - 1) } + // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es LogSlice) MoveAndAppendTo(dest LogSlice) { diff --git a/consumer/pdata/generated_log_test.go b/consumer/pdata/generated_log_test.go index 782381157fc..ae5840c277b 100644 --- a/consumer/pdata/generated_log_test.go +++ b/consumer/pdata/generated_log_test.go @@ -140,7 +140,7 @@ func TestResourceLogsSlice_MoveAndAppendTo(t *testing.T) { func TestResourceLogsSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewResourceLogsSlice() - emptySlice.RemoveIf(func (el ResourceLogs) bool { + emptySlice.RemoveIf(func(el ResourceLogs) bool { t.Fail() return false }) @@ -148,14 +148,13 @@ func TestResourceLogsSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestResourceLogsSlice() pos := 0 - filtered.RemoveIf(func (el ResourceLogs) bool { + filtered.RemoveIf(func(el ResourceLogs) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } - func TestResourceLogs_CopyTo(t *testing.T) { ms := NewResourceLogs() generateTestResourceLogs().CopyTo(ms) @@ -291,7 +290,7 @@ func TestInstrumentationLibraryLogsSlice_MoveAndAppendTo(t *testing.T) { func TestInstrumentationLibraryLogsSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewInstrumentationLibraryLogsSlice() - emptySlice.RemoveIf(func (el InstrumentationLibraryLogs) bool { + emptySlice.RemoveIf(func(el InstrumentationLibraryLogs) bool { t.Fail() return false }) @@ -299,14 +298,13 @@ func TestInstrumentationLibraryLogsSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestInstrumentationLibraryLogsSlice() pos := 0 - filtered.RemoveIf(func (el InstrumentationLibraryLogs) bool { + filtered.RemoveIf(func(el InstrumentationLibraryLogs) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } - func TestInstrumentationLibraryLogs_CopyTo(t *testing.T) { ms := NewInstrumentationLibraryLogs() generateTestInstrumentationLibraryLogs().CopyTo(ms) @@ -442,7 +440,7 @@ func TestLogSlice_MoveAndAppendTo(t *testing.T) { func TestLogSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewLogSlice() - emptySlice.RemoveIf(func (el LogRecord) bool { + emptySlice.RemoveIf(func(el LogRecord) bool { t.Fail() return false }) @@ -450,14 +448,13 @@ func TestLogSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestLogSlice() pos := 0 - filtered.RemoveIf(func (el LogRecord) bool { + filtered.RemoveIf(func(el LogRecord) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } - func TestLogRecord_CopyTo(t *testing.T) { ms := NewLogRecord() generateTestLogRecord().CopyTo(ms) diff --git a/consumer/pdata/generated_metrics.go b/consumer/pdata/generated_metrics.go index 768a6f1009b..51cebc96931 100644 --- a/consumer/pdata/generated_metrics.go +++ b/consumer/pdata/generated_metrics.go @@ -130,6 +130,7 @@ func (es ResourceMetricsSlice) AppendEmpty() ResourceMetrics { *es.orig = append(*es.orig, &otlpmetrics.ResourceMetrics{}) return es.At(es.Len() - 1) } + // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es ResourceMetricsSlice) MoveAndAppendTo(dest ResourceMetricsSlice) { @@ -309,6 +310,7 @@ func (es InstrumentationLibraryMetricsSlice) AppendEmpty() InstrumentationLibrar *es.orig = append(*es.orig, &otlpmetrics.InstrumentationLibraryMetrics{}) return es.At(es.Len() - 1) } + // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es InstrumentationLibraryMetricsSlice) MoveAndAppendTo(dest InstrumentationLibraryMetricsSlice) { @@ -488,6 +490,7 @@ func (es MetricSlice) AppendEmpty() Metric { *es.orig = append(*es.orig, &otlpmetrics.Metric{}) return es.At(es.Len() - 1) } + // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es MetricSlice) MoveAndAppendTo(dest MetricSlice) { @@ -573,8 +576,6 @@ func (ms Metric) SetUnit(v string) { (*ms.orig).Unit = v } - - // CopyTo copies all properties from the current struct to the dest. func (ms Metric) CopyTo(dest Metric) { dest.SetName(ms.Name()) @@ -982,6 +983,7 @@ func (es IntDataPointSlice) AppendEmpty() IntDataPoint { *es.orig = append(*es.orig, &otlpmetrics.IntDataPoint{}) return es.At(es.Len() - 1) } + // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es IntDataPointSlice) MoveAndAppendTo(dest IntDataPointSlice) { @@ -1194,6 +1196,7 @@ func (es DoubleDataPointSlice) AppendEmpty() DoubleDataPoint { *es.orig = append(*es.orig, &otlpmetrics.DoubleDataPoint{}) return es.At(es.Len() - 1) } + // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es DoubleDataPointSlice) MoveAndAppendTo(dest DoubleDataPointSlice) { @@ -1406,6 +1409,7 @@ func (es IntHistogramDataPointSlice) AppendEmpty() IntHistogramDataPoint { *es.orig = append(*es.orig, &otlpmetrics.IntHistogramDataPoint{}) return es.At(es.Len() - 1) } + // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es IntHistogramDataPointSlice) MoveAndAppendTo(dest IntHistogramDataPointSlice) { @@ -1651,6 +1655,7 @@ func (es HistogramDataPointSlice) AppendEmpty() HistogramDataPoint { *es.orig = append(*es.orig, &otlpmetrics.DoubleHistogramDataPoint{}) return es.At(es.Len() - 1) } + // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es HistogramDataPointSlice) MoveAndAppendTo(dest HistogramDataPointSlice) { @@ -1896,6 +1901,7 @@ func (es SummaryDataPointSlice) AppendEmpty() SummaryDataPoint { *es.orig = append(*es.orig, &otlpmetrics.DoubleSummaryDataPoint{}) return es.At(es.Len() - 1) } + // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es SummaryDataPointSlice) MoveAndAppendTo(dest SummaryDataPointSlice) { @@ -2119,6 +2125,7 @@ func (es ValueAtQuantileSlice) AppendEmpty() ValueAtQuantile { *es.orig = append(*es.orig, &otlpmetrics.DoubleSummaryDataPoint_ValueAtQuantile{}) return es.At(es.Len() - 1) } + // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es ValueAtQuantileSlice) MoveAndAppendTo(dest ValueAtQuantileSlice) { @@ -2303,6 +2310,7 @@ func (es IntExemplarSlice) AppendEmpty() IntExemplar { *es.orig = append(*es.orig, otlpmetrics.IntExemplar{}) return es.At(es.Len() - 1) } + // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es IntExemplarSlice) MoveAndAppendTo(dest IntExemplarSlice) { @@ -2496,6 +2504,7 @@ func (es ExemplarSlice) AppendEmpty() Exemplar { *es.orig = append(*es.orig, otlpmetrics.DoubleExemplar{}) return es.At(es.Len() - 1) } + // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es ExemplarSlice) MoveAndAppendTo(dest ExemplarSlice) { diff --git a/consumer/pdata/generated_metrics_test.go b/consumer/pdata/generated_metrics_test.go index 4c405e27bde..7b36a748454 100644 --- a/consumer/pdata/generated_metrics_test.go +++ b/consumer/pdata/generated_metrics_test.go @@ -140,7 +140,7 @@ func TestResourceMetricsSlice_MoveAndAppendTo(t *testing.T) { func TestResourceMetricsSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewResourceMetricsSlice() - emptySlice.RemoveIf(func (el ResourceMetrics) bool { + emptySlice.RemoveIf(func(el ResourceMetrics) bool { t.Fail() return false }) @@ -148,14 +148,13 @@ func TestResourceMetricsSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestResourceMetricsSlice() pos := 0 - filtered.RemoveIf(func (el ResourceMetrics) bool { + filtered.RemoveIf(func(el ResourceMetrics) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } - func TestResourceMetrics_CopyTo(t *testing.T) { ms := NewResourceMetrics() generateTestResourceMetrics().CopyTo(ms) @@ -291,7 +290,7 @@ func TestInstrumentationLibraryMetricsSlice_MoveAndAppendTo(t *testing.T) { func TestInstrumentationLibraryMetricsSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewInstrumentationLibraryMetricsSlice() - emptySlice.RemoveIf(func (el InstrumentationLibraryMetrics) bool { + emptySlice.RemoveIf(func(el InstrumentationLibraryMetrics) bool { t.Fail() return false }) @@ -299,14 +298,13 @@ func TestInstrumentationLibraryMetricsSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestInstrumentationLibraryMetricsSlice() pos := 0 - filtered.RemoveIf(func (el InstrumentationLibraryMetrics) bool { + filtered.RemoveIf(func(el InstrumentationLibraryMetrics) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } - func TestInstrumentationLibraryMetrics_CopyTo(t *testing.T) { ms := NewInstrumentationLibraryMetrics() generateTestInstrumentationLibraryMetrics().CopyTo(ms) @@ -442,7 +440,7 @@ func TestMetricSlice_MoveAndAppendTo(t *testing.T) { func TestMetricSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewMetricSlice() - emptySlice.RemoveIf(func (el Metric) bool { + emptySlice.RemoveIf(func(el Metric) bool { t.Fail() return false }) @@ -450,14 +448,13 @@ func TestMetricSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestMetricSlice() pos := 0 - filtered.RemoveIf(func (el Metric) bool { + filtered.RemoveIf(func(el Metric) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } - func TestMetric_CopyTo(t *testing.T) { ms := NewMetric() generateTestMetric().CopyTo(ms) @@ -488,9 +485,6 @@ func TestMetric_Unit(t *testing.T) { assert.EqualValues(t, testValUnit, ms.Unit()) } - - - func TestIntGauge_CopyTo(t *testing.T) { ms := NewIntGauge() generateTestIntGauge().CopyTo(ms) @@ -505,7 +499,6 @@ func TestIntGauge_DataPoints(t *testing.T) { assert.EqualValues(t, testValDataPoints, ms.DataPoints()) } - func TestDoubleGauge_CopyTo(t *testing.T) { ms := NewDoubleGauge() generateTestDoubleGauge().CopyTo(ms) @@ -520,7 +513,6 @@ func TestDoubleGauge_DataPoints(t *testing.T) { assert.EqualValues(t, testValDataPoints, ms.DataPoints()) } - func TestIntSum_CopyTo(t *testing.T) { ms := NewIntSum() generateTestIntSum().CopyTo(ms) @@ -551,7 +543,6 @@ func TestIntSum_DataPoints(t *testing.T) { assert.EqualValues(t, testValDataPoints, ms.DataPoints()) } - func TestDoubleSum_CopyTo(t *testing.T) { ms := NewDoubleSum() generateTestDoubleSum().CopyTo(ms) @@ -582,7 +573,6 @@ func TestDoubleSum_DataPoints(t *testing.T) { assert.EqualValues(t, testValDataPoints, ms.DataPoints()) } - func TestIntHistogram_CopyTo(t *testing.T) { ms := NewIntHistogram() generateTestIntHistogram().CopyTo(ms) @@ -605,7 +595,6 @@ func TestIntHistogram_DataPoints(t *testing.T) { assert.EqualValues(t, testValDataPoints, ms.DataPoints()) } - func TestHistogram_CopyTo(t *testing.T) { ms := NewHistogram() generateTestHistogram().CopyTo(ms) @@ -628,7 +617,6 @@ func TestHistogram_DataPoints(t *testing.T) { assert.EqualValues(t, testValDataPoints, ms.DataPoints()) } - func TestSummary_CopyTo(t *testing.T) { ms := NewSummary() generateTestSummary().CopyTo(ms) @@ -758,7 +746,7 @@ func TestIntDataPointSlice_MoveAndAppendTo(t *testing.T) { func TestIntDataPointSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewIntDataPointSlice() - emptySlice.RemoveIf(func (el IntDataPoint) bool { + emptySlice.RemoveIf(func(el IntDataPoint) bool { t.Fail() return false }) @@ -766,14 +754,13 @@ func TestIntDataPointSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestIntDataPointSlice() pos := 0 - filtered.RemoveIf(func (el IntDataPoint) bool { + filtered.RemoveIf(func(el IntDataPoint) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } - func TestIntDataPoint_CopyTo(t *testing.T) { ms := NewIntDataPoint() generateTestIntDataPoint().CopyTo(ms) @@ -935,7 +922,7 @@ func TestDoubleDataPointSlice_MoveAndAppendTo(t *testing.T) { func TestDoubleDataPointSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewDoubleDataPointSlice() - emptySlice.RemoveIf(func (el DoubleDataPoint) bool { + emptySlice.RemoveIf(func(el DoubleDataPoint) bool { t.Fail() return false }) @@ -943,14 +930,13 @@ func TestDoubleDataPointSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestDoubleDataPointSlice() pos := 0 - filtered.RemoveIf(func (el DoubleDataPoint) bool { + filtered.RemoveIf(func(el DoubleDataPoint) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } - func TestDoubleDataPoint_CopyTo(t *testing.T) { ms := NewDoubleDataPoint() generateTestDoubleDataPoint().CopyTo(ms) @@ -1112,7 +1098,7 @@ func TestIntHistogramDataPointSlice_MoveAndAppendTo(t *testing.T) { func TestIntHistogramDataPointSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewIntHistogramDataPointSlice() - emptySlice.RemoveIf(func (el IntHistogramDataPoint) bool { + emptySlice.RemoveIf(func(el IntHistogramDataPoint) bool { t.Fail() return false }) @@ -1120,14 +1106,13 @@ func TestIntHistogramDataPointSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestIntHistogramDataPointSlice() pos := 0 - filtered.RemoveIf(func (el IntHistogramDataPoint) bool { + filtered.RemoveIf(func(el IntHistogramDataPoint) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } - func TestIntHistogramDataPoint_CopyTo(t *testing.T) { ms := NewIntHistogramDataPoint() generateTestIntHistogramDataPoint().CopyTo(ms) @@ -1313,7 +1298,7 @@ func TestHistogramDataPointSlice_MoveAndAppendTo(t *testing.T) { func TestHistogramDataPointSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewHistogramDataPointSlice() - emptySlice.RemoveIf(func (el HistogramDataPoint) bool { + emptySlice.RemoveIf(func(el HistogramDataPoint) bool { t.Fail() return false }) @@ -1321,14 +1306,13 @@ func TestHistogramDataPointSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestHistogramDataPointSlice() pos := 0 - filtered.RemoveIf(func (el HistogramDataPoint) bool { + filtered.RemoveIf(func(el HistogramDataPoint) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } - func TestHistogramDataPoint_CopyTo(t *testing.T) { ms := NewHistogramDataPoint() generateTestHistogramDataPoint().CopyTo(ms) @@ -1514,7 +1498,7 @@ func TestSummaryDataPointSlice_MoveAndAppendTo(t *testing.T) { func TestSummaryDataPointSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewSummaryDataPointSlice() - emptySlice.RemoveIf(func (el SummaryDataPoint) bool { + emptySlice.RemoveIf(func(el SummaryDataPoint) bool { t.Fail() return false }) @@ -1522,14 +1506,13 @@ func TestSummaryDataPointSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestSummaryDataPointSlice() pos := 0 - filtered.RemoveIf(func (el SummaryDataPoint) bool { + filtered.RemoveIf(func(el SummaryDataPoint) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } - func TestSummaryDataPoint_CopyTo(t *testing.T) { ms := NewSummaryDataPoint() generateTestSummaryDataPoint().CopyTo(ms) @@ -1699,7 +1682,7 @@ func TestValueAtQuantileSlice_MoveAndAppendTo(t *testing.T) { func TestValueAtQuantileSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewValueAtQuantileSlice() - emptySlice.RemoveIf(func (el ValueAtQuantile) bool { + emptySlice.RemoveIf(func(el ValueAtQuantile) bool { t.Fail() return false }) @@ -1707,14 +1690,13 @@ func TestValueAtQuantileSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestValueAtQuantileSlice() pos := 0 - filtered.RemoveIf(func (el ValueAtQuantile) bool { + filtered.RemoveIf(func(el ValueAtQuantile) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } - func TestValueAtQuantile_CopyTo(t *testing.T) { ms := NewValueAtQuantile() generateTestValueAtQuantile().CopyTo(ms) @@ -1852,7 +1834,7 @@ func TestIntExemplarSlice_MoveAndAppendTo(t *testing.T) { func TestIntExemplarSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewIntExemplarSlice() - emptySlice.RemoveIf(func (el IntExemplar) bool { + emptySlice.RemoveIf(func(el IntExemplar) bool { t.Fail() return false }) @@ -1860,14 +1842,13 @@ func TestIntExemplarSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestIntExemplarSlice() pos := 0 - filtered.RemoveIf(func (el IntExemplar) bool { + filtered.RemoveIf(func(el IntExemplar) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } - func TestIntExemplar_CopyTo(t *testing.T) { ms := NewIntExemplar() generateTestIntExemplar().CopyTo(ms) @@ -2013,7 +1994,7 @@ func TestExemplarSlice_MoveAndAppendTo(t *testing.T) { func TestExemplarSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewExemplarSlice() - emptySlice.RemoveIf(func (el Exemplar) bool { + emptySlice.RemoveIf(func(el Exemplar) bool { t.Fail() return false }) @@ -2021,14 +2002,13 @@ func TestExemplarSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestExemplarSlice() pos := 0 - filtered.RemoveIf(func (el Exemplar) bool { + filtered.RemoveIf(func(el Exemplar) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } - func TestExemplar_CopyTo(t *testing.T) { ms := NewExemplar() generateTestExemplar().CopyTo(ms) diff --git a/consumer/pdata/generated_resource_test.go b/consumer/pdata/generated_resource_test.go index b96b74e5fa7..cff3992e35f 100644 --- a/consumer/pdata/generated_resource_test.go +++ b/consumer/pdata/generated_resource_test.go @@ -23,7 +23,6 @@ import ( "github.com/stretchr/testify/assert" ) - func TestResource_CopyTo(t *testing.T) { ms := NewResource() generateTestResource().CopyTo(ms) diff --git a/consumer/pdata/generated_trace.go b/consumer/pdata/generated_trace.go index 2af21f75234..dcf52f9b834 100644 --- a/consumer/pdata/generated_trace.go +++ b/consumer/pdata/generated_trace.go @@ -130,6 +130,7 @@ func (es ResourceSpansSlice) AppendEmpty() ResourceSpans { *es.orig = append(*es.orig, &otlptrace.ResourceSpans{}) return es.At(es.Len() - 1) } + // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es ResourceSpansSlice) MoveAndAppendTo(dest ResourceSpansSlice) { @@ -309,6 +310,7 @@ func (es InstrumentationLibrarySpansSlice) AppendEmpty() InstrumentationLibraryS *es.orig = append(*es.orig, &otlptrace.InstrumentationLibrarySpans{}) return es.At(es.Len() - 1) } + // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es InstrumentationLibrarySpansSlice) MoveAndAppendTo(dest InstrumentationLibrarySpansSlice) { @@ -488,6 +490,7 @@ func (es SpanSlice) AppendEmpty() Span { *es.orig = append(*es.orig, &otlptrace.Span{}) return es.At(es.Len() - 1) } + // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es SpanSlice) MoveAndAppendTo(dest SpanSlice) { @@ -801,6 +804,7 @@ func (es SpanEventSlice) AppendEmpty() SpanEvent { *es.orig = append(*es.orig, &otlptrace.Span_Event{}) return es.At(es.Len() - 1) } + // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es SpanEventSlice) MoveAndAppendTo(dest SpanEventSlice) { @@ -1008,6 +1012,7 @@ func (es SpanLinkSlice) AppendEmpty() SpanLink { *es.orig = append(*es.orig, &otlptrace.Span_Link{}) return es.At(es.Len() - 1) } + // MoveAndAppendTo moves all elements from the current slice and appends them to the dest. // The current slice will be cleared. func (es SpanLinkSlice) MoveAndAppendTo(dest SpanLinkSlice) { diff --git a/consumer/pdata/generated_trace_test.go b/consumer/pdata/generated_trace_test.go index 3a38e2b6976..f80dae0fcfb 100644 --- a/consumer/pdata/generated_trace_test.go +++ b/consumer/pdata/generated_trace_test.go @@ -140,7 +140,7 @@ func TestResourceSpansSlice_MoveAndAppendTo(t *testing.T) { func TestResourceSpansSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewResourceSpansSlice() - emptySlice.RemoveIf(func (el ResourceSpans) bool { + emptySlice.RemoveIf(func(el ResourceSpans) bool { t.Fail() return false }) @@ -148,14 +148,13 @@ func TestResourceSpansSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestResourceSpansSlice() pos := 0 - filtered.RemoveIf(func (el ResourceSpans) bool { + filtered.RemoveIf(func(el ResourceSpans) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } - func TestResourceSpans_CopyTo(t *testing.T) { ms := NewResourceSpans() generateTestResourceSpans().CopyTo(ms) @@ -291,7 +290,7 @@ func TestInstrumentationLibrarySpansSlice_MoveAndAppendTo(t *testing.T) { func TestInstrumentationLibrarySpansSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewInstrumentationLibrarySpansSlice() - emptySlice.RemoveIf(func (el InstrumentationLibrarySpans) bool { + emptySlice.RemoveIf(func(el InstrumentationLibrarySpans) bool { t.Fail() return false }) @@ -299,14 +298,13 @@ func TestInstrumentationLibrarySpansSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestInstrumentationLibrarySpansSlice() pos := 0 - filtered.RemoveIf(func (el InstrumentationLibrarySpans) bool { + filtered.RemoveIf(func(el InstrumentationLibrarySpans) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } - func TestInstrumentationLibrarySpans_CopyTo(t *testing.T) { ms := NewInstrumentationLibrarySpans() generateTestInstrumentationLibrarySpans().CopyTo(ms) @@ -442,7 +440,7 @@ func TestSpanSlice_MoveAndAppendTo(t *testing.T) { func TestSpanSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewSpanSlice() - emptySlice.RemoveIf(func (el Span) bool { + emptySlice.RemoveIf(func(el Span) bool { t.Fail() return false }) @@ -450,14 +448,13 @@ func TestSpanSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestSpanSlice() pos := 0 - filtered.RemoveIf(func (el Span) bool { + filtered.RemoveIf(func(el Span) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } - func TestSpan_CopyTo(t *testing.T) { ms := NewSpan() generateTestSpan().CopyTo(ms) @@ -697,7 +694,7 @@ func TestSpanEventSlice_MoveAndAppendTo(t *testing.T) { func TestSpanEventSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewSpanEventSlice() - emptySlice.RemoveIf(func (el SpanEvent) bool { + emptySlice.RemoveIf(func(el SpanEvent) bool { t.Fail() return false }) @@ -705,14 +702,13 @@ func TestSpanEventSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestSpanEventSlice() pos := 0 - filtered.RemoveIf(func (el SpanEvent) bool { + filtered.RemoveIf(func(el SpanEvent) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } - func TestSpanEvent_CopyTo(t *testing.T) { ms := NewSpanEvent() generateTestSpanEvent().CopyTo(ms) @@ -866,7 +862,7 @@ func TestSpanLinkSlice_MoveAndAppendTo(t *testing.T) { func TestSpanLinkSlice_RemoveIf(t *testing.T) { // Test RemoveIf on empty slice emptySlice := NewSpanLinkSlice() - emptySlice.RemoveIf(func (el SpanLink) bool { + emptySlice.RemoveIf(func(el SpanLink) bool { t.Fail() return false }) @@ -874,14 +870,13 @@ func TestSpanLinkSlice_RemoveIf(t *testing.T) { // Test RemoveIf filtered := generateTestSpanLinkSlice() pos := 0 - filtered.RemoveIf(func (el SpanLink) bool { + filtered.RemoveIf(func(el SpanLink) bool { pos++ return pos%3 == 0 }) assert.Equal(t, 5, filtered.Len()) } - func TestSpanLink_CopyTo(t *testing.T) { ms := NewSpanLink() generateTestSpanLink().CopyTo(ms) @@ -928,7 +923,6 @@ func TestSpanLink_DroppedAttributesCount(t *testing.T) { assert.EqualValues(t, testValDroppedAttributesCount, ms.DroppedAttributesCount()) } - func TestSpanStatus_CopyTo(t *testing.T) { ms := NewSpanStatus() generateTestSpanStatus().CopyTo(ms) From 50c3ab5034f68c4bb886fa0bf6c575dd7be0b24c Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Wed, 2 Jun 2021 18:24:06 -0400 Subject: [PATCH 25/27] Revert changes in pdatagen and pdata/generated --- cmd/pdatagen/internal/base_slices.go | 44 ++-- cmd/pdatagen/internal/log_structs.go | 1 + cmd/pdatagen/internal/metrics_structs.go | 4 +- cmd/pdatagen/internal/resource_structs.go | 2 +- cmd/pdatagen/internal/trace_structs.go | 13 +- consumer/pdata/generated_common.go | 22 +- consumer/pdata/generated_log.go | 66 +++--- consumer/pdata/generated_metrics.go | 246 +++++++++++----------- consumer/pdata/generated_resource.go | 2 +- consumer/pdata/generated_trace.go | 121 ++++++----- 10 files changed, 261 insertions(+), 260 deletions(-) diff --git a/cmd/pdatagen/internal/base_slices.go b/cmd/pdatagen/internal/base_slices.go index 66057197bc5..08071b34d01 100644 --- a/cmd/pdatagen/internal/base_slices.go +++ b/cmd/pdatagen/internal/base_slices.go @@ -112,7 +112,7 @@ func fillTest${structName}(tv ${structName}) { const slicePtrTemplate = `// ${structName} logically represents a slice of ${elementName}. // -// This is a reference type. If passed by value and callee modifies it, the +// This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // // Must use New${structName} function to create new instances. @@ -144,10 +144,10 @@ func (es ${structName}) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es ${structName}) At(ix int) ${elementName} { return new${elementName}((*es.orig)[ix]) } @@ -177,12 +177,12 @@ func (es ${structName}) CopyTo(dest ${structName}) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new ${structName} can be initialized: -// es := New${structName}() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := New${structName}() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es ${structName}) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -309,7 +309,7 @@ func Test${structName}_Append(t *testing.T) { const sliceValueTemplate = `// ${structName} logically represents a slice of ${elementName}. // -// This is a reference type. If passed by value and callee modifies it, the +// This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // // Must use New${structName} function to create new instances. @@ -341,10 +341,10 @@ func (es ${structName}) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es ${structName}) At(ix int) ${elementName} { return new${elementName}(&(*es.orig)[ix]) } @@ -369,12 +369,12 @@ func (es ${structName}) CopyTo(dest ${structName}) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new ${structName} can be initialized: -// es := New${structName}() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := New${structName}() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es ${structName}) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) diff --git a/cmd/pdatagen/internal/log_structs.go b/cmd/pdatagen/internal/log_structs.go index 08f88812a07..e267c32cf03 100644 --- a/cmd/pdatagen/internal/log_structs.go +++ b/cmd/pdatagen/internal/log_structs.go @@ -17,6 +17,7 @@ package internal var logFile = &File{ Name: "log", imports: []string{ + `otlpcommon "go.opentelemetry.io/collector/internal/data/protogen/common/v1"`, `otlplogs "go.opentelemetry.io/collector/internal/data/protogen/logs/v1"`, }, testImports: []string{ diff --git a/cmd/pdatagen/internal/metrics_structs.go b/cmd/pdatagen/internal/metrics_structs.go index c46e3f71e48..97c25455284 100644 --- a/cmd/pdatagen/internal/metrics_structs.go +++ b/cmd/pdatagen/internal/metrics_structs.go @@ -66,7 +66,7 @@ var resourceMetricsSlice = &sliceOfPtrs{ var resourceMetrics = &messageValueStruct{ structName: "ResourceMetrics", - description: "// ResourceMetrics is a collection of metrics from a Resource.", + description: "// InstrumentationLibraryMetrics is a collection of metrics from a LibraryInstrumentation.", originFullName: "otlpmetrics.ResourceMetrics", fields: []baseField{ resourceField, @@ -332,7 +332,7 @@ var quantileValuesSlice = &sliceOfPtrs{ var quantileValues = &messageValueStruct{ structName: "ValueAtQuantile", - description: "// ValueAtQuantile is a quantile value within a Summary data point.", + description: "// ValueAtQuantile is a quantile value within a Summary data point", originFullName: "otlpmetrics.DoubleSummaryDataPoint_ValueAtQuantile", fields: []baseField{ quantileField, diff --git a/cmd/pdatagen/internal/resource_structs.go b/cmd/pdatagen/internal/resource_structs.go index f5167e7c5d4..98e727b5f6c 100644 --- a/cmd/pdatagen/internal/resource_structs.go +++ b/cmd/pdatagen/internal/resource_structs.go @@ -31,7 +31,7 @@ var resourceFile = &File{ var resource = &messageValueStruct{ structName: "Resource", - description: "// Resource is a message representing the resource information.", + description: "// Resource information.", originFullName: "otlpresource.Resource", fields: []baseField{ attributes, diff --git a/cmd/pdatagen/internal/trace_structs.go b/cmd/pdatagen/internal/trace_structs.go index 56b9367ad99..ead06c68ef1 100644 --- a/cmd/pdatagen/internal/trace_structs.go +++ b/cmd/pdatagen/internal/trace_structs.go @@ -17,6 +17,8 @@ package internal var traceFile = &File{ Name: "trace", imports: []string{ + `"go.opentelemetry.io/collector/internal/data"`, + `otlpcommon "go.opentelemetry.io/collector/internal/data/protogen/common/v1"`, `otlptrace "go.opentelemetry.io/collector/internal/data/protogen/trace/v1"`, }, testImports: []string{ @@ -48,7 +50,7 @@ var resourceSpansSlice = &sliceOfPtrs{ var resourceSpans = &messageValueStruct{ structName: "ResourceSpans", - description: "// ResourceSpans is a collection of spans from a Resource.", + description: "// InstrumentationLibrarySpans is a collection of spans from a LibraryInstrumentation.", originFullName: "otlptrace.ResourceSpans", fields: []baseField{ resourceField, @@ -87,7 +89,7 @@ var spanSlice = &sliceOfPtrs{ var span = &messageValueStruct{ structName: "Span", description: "// Span represents a single operation within a trace.\n" + - "// See Span definition in OTLP: https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto", + "// See Span definition in OTLP: https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto#L37", originFullName: "otlptrace.Span", fields: []baseField{ traceIDField, @@ -165,8 +167,7 @@ var spanLinkSlice = &sliceOfPtrs{ var spanLink = &messageValueStruct{ structName: "SpanLink", description: "// SpanLink is a pointer from the current span to another span in the same trace or in a\n" + - "// different trace.\n" + - "// See Link definition in OTLP: https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto", + "// different trace. See OTLP for link definition.", originFullName: "otlptrace.Span_Link", fields: []baseField{ traceIDField, @@ -179,8 +180,8 @@ var spanLink = &messageValueStruct{ var spanStatus = &messageValueStruct{ structName: "SpanStatus", - description: "// SpanStatus is an optional final status for this span. Semantically, when Status was not\n" + - "// set, that means the span ended without errors and to assume Status.Ok (code = 0).", + description: "// SpanStatus is an optional final status for this span. Semantically when Status wasn't set\n" + + "// it is means span ended without errors and assume Status.Ok (code = 0).", originFullName: "otlptrace.Status", fields: []baseField{ &primitiveTypedField{ diff --git a/consumer/pdata/generated_common.go b/consumer/pdata/generated_common.go index a726420ccc0..9c647fe97a2 100644 --- a/consumer/pdata/generated_common.go +++ b/consumer/pdata/generated_common.go @@ -71,7 +71,7 @@ func (ms InstrumentationLibrary) CopyTo(dest InstrumentationLibrary) { // AnyValueArray logically represents a slice of AttributeValue. // -// This is a reference type. If passed by value and callee modifies it, the +// This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // // Must use NewAnyValueArray function to create new instances. @@ -103,10 +103,10 @@ func (es AnyValueArray) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es AnyValueArray) At(ix int) AttributeValue { return newAttributeValue(&(*es.orig)[ix]) } @@ -131,12 +131,12 @@ func (es AnyValueArray) CopyTo(dest AnyValueArray) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new AnyValueArray can be initialized: -// es := NewAnyValueArray() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewAnyValueArray() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es AnyValueArray) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) diff --git a/consumer/pdata/generated_log.go b/consumer/pdata/generated_log.go index 7c1ed7e1544..9662ec543f0 100644 --- a/consumer/pdata/generated_log.go +++ b/consumer/pdata/generated_log.go @@ -23,7 +23,7 @@ import ( // ResourceLogsSlice logically represents a slice of ResourceLogs. // -// This is a reference type. If passed by value and callee modifies it, the +// This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // // Must use NewResourceLogsSlice function to create new instances. @@ -55,10 +55,10 @@ func (es ResourceLogsSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es ResourceLogsSlice) At(ix int) ResourceLogs { return newResourceLogs((*es.orig)[ix]) } @@ -88,12 +88,12 @@ func (es ResourceLogsSlice) CopyTo(dest ResourceLogsSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new ResourceLogsSlice can be initialized: -// es := NewResourceLogsSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewResourceLogsSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es ResourceLogsSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -203,7 +203,7 @@ func (ms ResourceLogs) CopyTo(dest ResourceLogs) { // InstrumentationLibraryLogsSlice logically represents a slice of InstrumentationLibraryLogs. // -// This is a reference type. If passed by value and callee modifies it, the +// This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // // Must use NewInstrumentationLibraryLogsSlice function to create new instances. @@ -235,10 +235,10 @@ func (es InstrumentationLibraryLogsSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es InstrumentationLibraryLogsSlice) At(ix int) InstrumentationLibraryLogs { return newInstrumentationLibraryLogs((*es.orig)[ix]) } @@ -268,12 +268,12 @@ func (es InstrumentationLibraryLogsSlice) CopyTo(dest InstrumentationLibraryLogs // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new InstrumentationLibraryLogsSlice can be initialized: -// es := NewInstrumentationLibraryLogsSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewInstrumentationLibraryLogsSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es InstrumentationLibraryLogsSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -383,7 +383,7 @@ func (ms InstrumentationLibraryLogs) CopyTo(dest InstrumentationLibraryLogs) { // LogSlice logically represents a slice of LogRecord. // -// This is a reference type. If passed by value and callee modifies it, the +// This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // // Must use NewLogSlice function to create new instances. @@ -415,10 +415,10 @@ func (es LogSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es LogSlice) At(ix int) LogRecord { return newLogRecord((*es.orig)[ix]) } @@ -448,12 +448,12 @@ func (es LogSlice) CopyTo(dest LogSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new LogSlice can be initialized: -// es := NewLogSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewLogSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es LogSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) diff --git a/consumer/pdata/generated_metrics.go b/consumer/pdata/generated_metrics.go index 51cebc96931..9e614c40ae7 100644 --- a/consumer/pdata/generated_metrics.go +++ b/consumer/pdata/generated_metrics.go @@ -23,7 +23,7 @@ import ( // ResourceMetricsSlice logically represents a slice of ResourceMetrics. // -// This is a reference type. If passed by value and callee modifies it, the +// This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // // Must use NewResourceMetricsSlice function to create new instances. @@ -55,10 +55,10 @@ func (es ResourceMetricsSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es ResourceMetricsSlice) At(ix int) ResourceMetrics { return newResourceMetrics((*es.orig)[ix]) } @@ -88,12 +88,12 @@ func (es ResourceMetricsSlice) CopyTo(dest ResourceMetricsSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new ResourceMetricsSlice can be initialized: -// es := NewResourceMetricsSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewResourceMetricsSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es ResourceMetricsSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -163,7 +163,7 @@ func (es ResourceMetricsSlice) RemoveIf(f func(ResourceMetrics) bool) { *es.orig = (*es.orig)[:newLen] } -// ResourceMetrics is a collection of metrics from a Resource. +// InstrumentationLibraryMetrics is a collection of metrics from a LibraryInstrumentation. // // This is a reference type, if passed by value and callee modifies it the // caller will see the modification. @@ -203,7 +203,7 @@ func (ms ResourceMetrics) CopyTo(dest ResourceMetrics) { // InstrumentationLibraryMetricsSlice logically represents a slice of InstrumentationLibraryMetrics. // -// This is a reference type. If passed by value and callee modifies it, the +// This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // // Must use NewInstrumentationLibraryMetricsSlice function to create new instances. @@ -235,10 +235,10 @@ func (es InstrumentationLibraryMetricsSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es InstrumentationLibraryMetricsSlice) At(ix int) InstrumentationLibraryMetrics { return newInstrumentationLibraryMetrics((*es.orig)[ix]) } @@ -268,12 +268,12 @@ func (es InstrumentationLibraryMetricsSlice) CopyTo(dest InstrumentationLibraryM // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new InstrumentationLibraryMetricsSlice can be initialized: -// es := NewInstrumentationLibraryMetricsSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewInstrumentationLibraryMetricsSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es InstrumentationLibraryMetricsSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -383,7 +383,7 @@ func (ms InstrumentationLibraryMetrics) CopyTo(dest InstrumentationLibraryMetric // MetricSlice logically represents a slice of Metric. // -// This is a reference type. If passed by value and callee modifies it, the +// This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // // Must use NewMetricSlice function to create new instances. @@ -415,10 +415,10 @@ func (es MetricSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es MetricSlice) At(ix int) Metric { return newMetric((*es.orig)[ix]) } @@ -448,12 +448,12 @@ func (es MetricSlice) CopyTo(dest MetricSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new MetricSlice can be initialized: -// es := NewMetricSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewMetricSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es MetricSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -876,7 +876,7 @@ func (ms Summary) CopyTo(dest Summary) { // IntDataPointSlice logically represents a slice of IntDataPoint. // -// This is a reference type. If passed by value and callee modifies it, the +// This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // // Must use NewIntDataPointSlice function to create new instances. @@ -908,10 +908,10 @@ func (es IntDataPointSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es IntDataPointSlice) At(ix int) IntDataPoint { return newIntDataPoint((*es.orig)[ix]) } @@ -941,12 +941,12 @@ func (es IntDataPointSlice) CopyTo(dest IntDataPointSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new IntDataPointSlice can be initialized: -// es := NewIntDataPointSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewIntDataPointSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es IntDataPointSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -1089,7 +1089,7 @@ func (ms IntDataPoint) CopyTo(dest IntDataPoint) { // DoubleDataPointSlice logically represents a slice of DoubleDataPoint. // -// This is a reference type. If passed by value and callee modifies it, the +// This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // // Must use NewDoubleDataPointSlice function to create new instances. @@ -1121,10 +1121,10 @@ func (es DoubleDataPointSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es DoubleDataPointSlice) At(ix int) DoubleDataPoint { return newDoubleDataPoint((*es.orig)[ix]) } @@ -1154,12 +1154,12 @@ func (es DoubleDataPointSlice) CopyTo(dest DoubleDataPointSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new DoubleDataPointSlice can be initialized: -// es := NewDoubleDataPointSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewDoubleDataPointSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es DoubleDataPointSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -1302,7 +1302,7 @@ func (ms DoubleDataPoint) CopyTo(dest DoubleDataPoint) { // IntHistogramDataPointSlice logically represents a slice of IntHistogramDataPoint. // -// This is a reference type. If passed by value and callee modifies it, the +// This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // // Must use NewIntHistogramDataPointSlice function to create new instances. @@ -1334,10 +1334,10 @@ func (es IntHistogramDataPointSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es IntHistogramDataPointSlice) At(ix int) IntHistogramDataPoint { return newIntHistogramDataPoint((*es.orig)[ix]) } @@ -1367,12 +1367,12 @@ func (es IntHistogramDataPointSlice) CopyTo(dest IntHistogramDataPointSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new IntHistogramDataPointSlice can be initialized: -// es := NewIntHistogramDataPointSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewIntHistogramDataPointSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es IntHistogramDataPointSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -1548,7 +1548,7 @@ func (ms IntHistogramDataPoint) CopyTo(dest IntHistogramDataPoint) { // HistogramDataPointSlice logically represents a slice of HistogramDataPoint. // -// This is a reference type. If passed by value and callee modifies it, the +// This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // // Must use NewHistogramDataPointSlice function to create new instances. @@ -1580,10 +1580,10 @@ func (es HistogramDataPointSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es HistogramDataPointSlice) At(ix int) HistogramDataPoint { return newHistogramDataPoint((*es.orig)[ix]) } @@ -1613,12 +1613,12 @@ func (es HistogramDataPointSlice) CopyTo(dest HistogramDataPointSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new HistogramDataPointSlice can be initialized: -// es := NewHistogramDataPointSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewHistogramDataPointSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es HistogramDataPointSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -1794,7 +1794,7 @@ func (ms HistogramDataPoint) CopyTo(dest HistogramDataPoint) { // SummaryDataPointSlice logically represents a slice of SummaryDataPoint. // -// This is a reference type. If passed by value and callee modifies it, the +// This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // // Must use NewSummaryDataPointSlice function to create new instances. @@ -1826,10 +1826,10 @@ func (es SummaryDataPointSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es SummaryDataPointSlice) At(ix int) SummaryDataPoint { return newSummaryDataPoint((*es.orig)[ix]) } @@ -1859,12 +1859,12 @@ func (es SummaryDataPointSlice) CopyTo(dest SummaryDataPointSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new SummaryDataPointSlice can be initialized: -// es := NewSummaryDataPointSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewSummaryDataPointSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es SummaryDataPointSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -2018,7 +2018,7 @@ func (ms SummaryDataPoint) CopyTo(dest SummaryDataPoint) { // ValueAtQuantileSlice logically represents a slice of ValueAtQuantile. // -// This is a reference type. If passed by value and callee modifies it, the +// This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // // Must use NewValueAtQuantileSlice function to create new instances. @@ -2050,10 +2050,10 @@ func (es ValueAtQuantileSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es ValueAtQuantileSlice) At(ix int) ValueAtQuantile { return newValueAtQuantile((*es.orig)[ix]) } @@ -2083,12 +2083,12 @@ func (es ValueAtQuantileSlice) CopyTo(dest ValueAtQuantileSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new ValueAtQuantileSlice can be initialized: -// es := NewValueAtQuantileSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewValueAtQuantileSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es ValueAtQuantileSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -2158,7 +2158,7 @@ func (es ValueAtQuantileSlice) RemoveIf(f func(ValueAtQuantile) bool) { *es.orig = (*es.orig)[:newLen] } -// ValueAtQuantile is a quantile value within a Summary data point. +// ValueAtQuantile is a quantile value within a Summary data point // // This is a reference type, if passed by value and callee modifies it the // caller will see the modification. @@ -2208,7 +2208,7 @@ func (ms ValueAtQuantile) CopyTo(dest ValueAtQuantile) { // IntExemplarSlice logically represents a slice of IntExemplar. // -// This is a reference type. If passed by value and callee modifies it, the +// This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // // Must use NewIntExemplarSlice function to create new instances. @@ -2240,10 +2240,10 @@ func (es IntExemplarSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es IntExemplarSlice) At(ix int) IntExemplar { return newIntExemplar(&(*es.orig)[ix]) } @@ -2268,12 +2268,12 @@ func (es IntExemplarSlice) CopyTo(dest IntExemplarSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new IntExemplarSlice can be initialized: -// es := NewIntExemplarSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewIntExemplarSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es IntExemplarSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -2402,7 +2402,7 @@ func (ms IntExemplar) CopyTo(dest IntExemplar) { // ExemplarSlice logically represents a slice of Exemplar. // -// This is a reference type. If passed by value and callee modifies it, the +// This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // // Must use NewExemplarSlice function to create new instances. @@ -2434,10 +2434,10 @@ func (es ExemplarSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es ExemplarSlice) At(ix int) Exemplar { return newExemplar(&(*es.orig)[ix]) } @@ -2462,12 +2462,12 @@ func (es ExemplarSlice) CopyTo(dest ExemplarSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new ExemplarSlice can be initialized: -// es := NewExemplarSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewExemplarSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es ExemplarSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) diff --git a/consumer/pdata/generated_resource.go b/consumer/pdata/generated_resource.go index 069e3562624..9e4f2cb3fd0 100644 --- a/consumer/pdata/generated_resource.go +++ b/consumer/pdata/generated_resource.go @@ -21,7 +21,7 @@ import ( otlpresource "go.opentelemetry.io/collector/internal/data/protogen/resource/v1" ) -// Resource is a message representing the resource information. +// Resource information. // // This is a reference type, if passed by value and callee modifies it the // caller will see the modification. diff --git a/consumer/pdata/generated_trace.go b/consumer/pdata/generated_trace.go index dcf52f9b834..62adc93dcd3 100644 --- a/consumer/pdata/generated_trace.go +++ b/consumer/pdata/generated_trace.go @@ -23,7 +23,7 @@ import ( // ResourceSpansSlice logically represents a slice of ResourceSpans. // -// This is a reference type. If passed by value and callee modifies it, the +// This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // // Must use NewResourceSpansSlice function to create new instances. @@ -55,10 +55,10 @@ func (es ResourceSpansSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es ResourceSpansSlice) At(ix int) ResourceSpans { return newResourceSpans((*es.orig)[ix]) } @@ -88,12 +88,12 @@ func (es ResourceSpansSlice) CopyTo(dest ResourceSpansSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new ResourceSpansSlice can be initialized: -// es := NewResourceSpansSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewResourceSpansSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es ResourceSpansSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -163,7 +163,7 @@ func (es ResourceSpansSlice) RemoveIf(f func(ResourceSpans) bool) { *es.orig = (*es.orig)[:newLen] } -// ResourceSpans is a collection of spans from a Resource. +// InstrumentationLibrarySpans is a collection of spans from a LibraryInstrumentation. // // This is a reference type, if passed by value and callee modifies it the // caller will see the modification. @@ -203,7 +203,7 @@ func (ms ResourceSpans) CopyTo(dest ResourceSpans) { // InstrumentationLibrarySpansSlice logically represents a slice of InstrumentationLibrarySpans. // -// This is a reference type. If passed by value and callee modifies it, the +// This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // // Must use NewInstrumentationLibrarySpansSlice function to create new instances. @@ -235,10 +235,10 @@ func (es InstrumentationLibrarySpansSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es InstrumentationLibrarySpansSlice) At(ix int) InstrumentationLibrarySpans { return newInstrumentationLibrarySpans((*es.orig)[ix]) } @@ -268,12 +268,12 @@ func (es InstrumentationLibrarySpansSlice) CopyTo(dest InstrumentationLibrarySpa // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new InstrumentationLibrarySpansSlice can be initialized: -// es := NewInstrumentationLibrarySpansSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewInstrumentationLibrarySpansSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es InstrumentationLibrarySpansSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -383,7 +383,7 @@ func (ms InstrumentationLibrarySpans) CopyTo(dest InstrumentationLibrarySpans) { // SpanSlice logically represents a slice of Span. // -// This is a reference type. If passed by value and callee modifies it, the +// This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // // Must use NewSpanSlice function to create new instances. @@ -415,10 +415,10 @@ func (es SpanSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es SpanSlice) At(ix int) Span { return newSpan((*es.orig)[ix]) } @@ -448,12 +448,12 @@ func (es SpanSlice) CopyTo(dest SpanSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new SpanSlice can be initialized: -// es := NewSpanSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewSpanSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es SpanSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -524,7 +524,7 @@ func (es SpanSlice) RemoveIf(f func(Span) bool) { } // Span represents a single operation within a trace. -// See Span definition in OTLP: https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto +// See Span definition in OTLP: https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto#L37 // // This is a reference type, if passed by value and callee modifies it the // caller will see the modification. @@ -697,7 +697,7 @@ func (ms Span) CopyTo(dest Span) { // SpanEventSlice logically represents a slice of SpanEvent. // -// This is a reference type. If passed by value and callee modifies it, the +// This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // // Must use NewSpanEventSlice function to create new instances. @@ -729,10 +729,10 @@ func (es SpanEventSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es SpanEventSlice) At(ix int) SpanEvent { return newSpanEvent((*es.orig)[ix]) } @@ -762,12 +762,12 @@ func (es SpanEventSlice) CopyTo(dest SpanEventSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new SpanEventSlice can be initialized: -// es := NewSpanEventSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewSpanEventSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es SpanEventSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -905,7 +905,7 @@ func (ms SpanEvent) CopyTo(dest SpanEvent) { // SpanLinkSlice logically represents a slice of SpanLink. // -// This is a reference type. If passed by value and callee modifies it, the +// This is a reference type, if passed by value and callee modifies it the // caller will see the modification. // // Must use NewSpanLinkSlice function to create new instances. @@ -937,10 +937,10 @@ func (es SpanLinkSlice) Len() int { // At returns the element at the given index. // // This function is used mostly for iterating over all the values in the slice: -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// ... // Do something with the element -// } +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// ... // Do something with the element +// } func (es SpanLinkSlice) At(ix int) SpanLink { return newSpanLink((*es.orig)[ix]) } @@ -970,12 +970,12 @@ func (es SpanLinkSlice) CopyTo(dest SpanLinkSlice) { // 2. If the newLen > len then (newLen - cap) empty elements will be appended to the slice. // // Here is how a new SpanLinkSlice can be initialized: -// es := NewSpanLinkSlice() -// es.Resize(4) -// for i := 0; i < es.Len(); i++ { -// e := es.At(i) -// // Here should set all the values for e. -// } +// es := NewSpanLinkSlice() +// es.Resize(4) +// for i := 0; i < es.Len(); i++ { +// e := es.At(i) +// // Here should set all the values for e. +// } func (es SpanLinkSlice) Resize(newLen int) { oldLen := len(*es.orig) oldCap := cap(*es.orig) @@ -1046,8 +1046,7 @@ func (es SpanLinkSlice) RemoveIf(f func(SpanLink) bool) { } // SpanLink is a pointer from the current span to another span in the same trace or in a -// different trace. -// See Link definition in OTLP: https://github.com/open-telemetry/opentelemetry-proto/blob/main/opentelemetry/proto/trace/v1/trace.proto +// different trace. See OTLP for link definition. // // This is a reference type, if passed by value and callee modifies it the // caller will see the modification. @@ -1123,8 +1122,8 @@ func (ms SpanLink) CopyTo(dest SpanLink) { dest.SetDroppedAttributesCount(ms.DroppedAttributesCount()) } -// SpanStatus is an optional final status for this span. Semantically, when Status was not -// set, that means the span ended without errors and to assume Status.Ok (code = 0). +// SpanStatus is an optional final status for this span. Semantically when Status wasn't set +// it is means span ended without errors and assume Status.Ok (code = 0). // // This is a reference type, if passed by value and callee modifies it the // caller will see the modification. From 2b137717d7df5e272ad56bda3ef9a013a2274ad5 Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Sat, 12 Jun 2021 14:53:01 -0400 Subject: [PATCH 26/27] Update NewErr docstring For func defined in consumer/consumertest/err.go Co-authored-by: Tigran Najaryan <4194920+tigrannajaryan@users.noreply.github.com> --- consumer/consumertest/err.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consumer/consumertest/err.go b/consumer/consumertest/err.go index 5d43d5f20b8..12abb5bb05f 100644 --- a/consumer/consumertest/err.go +++ b/consumer/consumertest/err.go @@ -39,7 +39,7 @@ func (er *errConsumer) ConsumeLogs(context.Context, pdata.Logs) error { return er.err } -// NewErr returns a Consumer that just drops all received data and holds the input error. +// NewErr returns a Consumer that just drops all received data and returns the specified error to Consume* callers. func NewErr(err error) Consumer { return &errConsumer{err: err} } From d9f542c13b278001747f85f93325c8e4ea46e7c4 Mon Sep 17 00:00:00 2001 From: Eddy Lin Date: Sat, 12 Jun 2021 14:56:35 -0400 Subject: [PATCH 27/27] Updated docstring for TraceState Renamed "message" to "string" --- consumer/pdata/traces.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consumer/pdata/traces.go b/consumer/pdata/traces.go index 516e1b809e4..02e97d68ebe 100644 --- a/consumer/pdata/traces.go +++ b/consumer/pdata/traces.go @@ -97,7 +97,7 @@ func (td Traces) ResourceSpans() ResourceSpansSlice { return newResourceSpansSlice(&td.orig.ResourceSpans) } -// TraceState is a message representing the tracestate in w3c-trace-context format: https://www.w3.org/TR/trace-context/#tracestate-header +// TraceState is a string representing the tracestate in w3c-trace-context format: https://www.w3.org/TR/trace-context/#tracestate-header type TraceState string const (