From 940692fc976eec2f70801ceb52b5a4c1d19a41e4 Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Fri, 5 Aug 2022 15:41:45 -0600 Subject: [PATCH 1/6] Deprecate FlagsStruct in favor of Flags --- .../cmd/pdatagen/internal/metrics_structs.go | 14 ++--- pdata/internal/generated_pmetric.go | 32 +++++----- pdata/internal/generated_pmetric_test.go | 32 +++++----- pdata/internal/metrics.go | 62 ++++++++++++++++--- pdata/internal/metrics_test.go | 42 ++++++------- pdata/pmetric/alias.go | 9 +++ 6 files changed, 123 insertions(+), 68 deletions(-) diff --git a/pdata/internal/cmd/pdatagen/internal/metrics_structs.go b/pdata/internal/cmd/pdatagen/internal/metrics_structs.go index 57b7151b205..4179ed5b762 100644 --- a/pdata/internal/cmd/pdatagen/internal/metrics_structs.go +++ b/pdata/internal/cmd/pdatagen/internal/metrics_structs.go @@ -266,7 +266,7 @@ var numberDataPoint = &messageValueStruct{ }, }, exemplarsField, - dataPointFlagsFieldStruct, + dataPointFlagsField, }, } @@ -288,7 +288,7 @@ var histogramDataPoint = &messageValueStruct{ bucketCountsField, explicitBoundsField, exemplarsField, - dataPointFlagsFieldStruct, + dataPointFlagsField, &optionalPrimitiveValue{ fieldName: "Min", fieldType: "Double", @@ -363,7 +363,7 @@ var exponentialHistogramDataPoint = &messageValueStruct{ returnMessage: bucketsValues, }, exemplarsField, - dataPointFlagsFieldStruct, + dataPointFlagsField, &optionalPrimitiveValue{ fieldName: "Min", fieldType: "Double", @@ -422,7 +422,7 @@ var summaryDataPoint = &messageValueStruct{ originFieldName: "QuantileValues", returnSlice: quantileValuesSlice, }, - dataPointFlagsFieldStruct, + dataPointFlagsField, }, } @@ -489,11 +489,11 @@ var exemplar = &messageValueStruct{ }, } -var dataPointFlagsFieldStruct = &messageValueField{ - fieldName: "FlagsStruct", +var dataPointFlagsField = &messageValueField{ + fieldName: "Flags", originFieldName: "Flags", returnMessage: &messageValueStruct{ - structName: "MetricDataPointFlagsStruct", + structName: "MetricDataPointFlags", originFullName: "uint32", }, } diff --git a/pdata/internal/generated_pmetric.go b/pdata/internal/generated_pmetric.go index 21a49a8e8a7..22391d2f0f1 100644 --- a/pdata/internal/generated_pmetric.go +++ b/pdata/internal/generated_pmetric.go @@ -1212,9 +1212,9 @@ func (ms NumberDataPoint) Exemplars() ExemplarSlice { return newExemplarSlice(&(*ms.orig).Exemplars) } -// FlagsStruct returns the flagsstruct associated with this NumberDataPoint. -func (ms NumberDataPoint) FlagsStruct() MetricDataPointFlagsStruct { - return newMetricDataPointFlagsStruct(&(*ms.orig).Flags) +// Flags returns the flags associated with this NumberDataPoint. +func (ms NumberDataPoint) Flags() MetricDataPointFlags { + return newMetricDataPointFlags(&(*ms.orig).Flags) } // CopyTo copies all properties from the current struct to the dest. @@ -1230,7 +1230,7 @@ func (ms NumberDataPoint) CopyTo(dest NumberDataPoint) { } ms.Exemplars().CopyTo(dest.Exemplars()) - ms.FlagsStruct().CopyTo(dest.FlagsStruct()) + ms.Flags().CopyTo(dest.Flags()) } // HistogramDataPointSlice logically represents a slice of HistogramDataPoint. @@ -1479,9 +1479,9 @@ func (ms HistogramDataPoint) Exemplars() ExemplarSlice { return newExemplarSlice(&(*ms.orig).Exemplars) } -// FlagsStruct returns the flagsstruct associated with this HistogramDataPoint. -func (ms HistogramDataPoint) FlagsStruct() MetricDataPointFlagsStruct { - return newMetricDataPointFlagsStruct(&(*ms.orig).Flags) +// Flags returns the flags associated with this HistogramDataPoint. +func (ms HistogramDataPoint) Flags() MetricDataPointFlags { + return newMetricDataPointFlags(&(*ms.orig).Flags) } // Min returns the min associated with this HistogramDataPoint. @@ -1541,7 +1541,7 @@ func (ms HistogramDataPoint) CopyTo(dest HistogramDataPoint) { } ms.Exemplars().CopyTo(dest.Exemplars()) - ms.FlagsStruct().CopyTo(dest.FlagsStruct()) + ms.Flags().CopyTo(dest.Flags()) if ms.HasMin() { dest.SetMin(ms.Min()) } @@ -1811,9 +1811,9 @@ func (ms ExponentialHistogramDataPoint) Exemplars() ExemplarSlice { return newExemplarSlice(&(*ms.orig).Exemplars) } -// FlagsStruct returns the flagsstruct associated with this ExponentialHistogramDataPoint. -func (ms ExponentialHistogramDataPoint) FlagsStruct() MetricDataPointFlagsStruct { - return newMetricDataPointFlagsStruct(&(*ms.orig).Flags) +// Flags returns the flags associated with this ExponentialHistogramDataPoint. +func (ms ExponentialHistogramDataPoint) Flags() MetricDataPointFlags { + return newMetricDataPointFlags(&(*ms.orig).Flags) } // Min returns the min associated with this ExponentialHistogramDataPoint. @@ -1863,7 +1863,7 @@ func (ms ExponentialHistogramDataPoint) CopyTo(dest ExponentialHistogramDataPoin ms.Positive().CopyTo(dest.Positive()) ms.Negative().CopyTo(dest.Negative()) ms.Exemplars().CopyTo(dest.Exemplars()) - ms.FlagsStruct().CopyTo(dest.FlagsStruct()) + ms.Flags().CopyTo(dest.Flags()) if ms.HasMin() { dest.SetMin(ms.Min()) } @@ -2156,9 +2156,9 @@ func (ms SummaryDataPoint) QuantileValues() ValueAtQuantileSlice { return newValueAtQuantileSlice(&(*ms.orig).QuantileValues) } -// FlagsStruct returns the flagsstruct associated with this SummaryDataPoint. -func (ms SummaryDataPoint) FlagsStruct() MetricDataPointFlagsStruct { - return newMetricDataPointFlagsStruct(&(*ms.orig).Flags) +// Flags returns the flags associated with this SummaryDataPoint. +func (ms SummaryDataPoint) Flags() MetricDataPointFlags { + return newMetricDataPointFlags(&(*ms.orig).Flags) } // CopyTo copies all properties from the current struct to the dest. @@ -2169,7 +2169,7 @@ func (ms SummaryDataPoint) CopyTo(dest SummaryDataPoint) { dest.SetCount(ms.Count()) dest.SetSum(ms.Sum()) ms.QuantileValues().CopyTo(dest.QuantileValues()) - ms.FlagsStruct().CopyTo(dest.FlagsStruct()) + ms.Flags().CopyTo(dest.Flags()) } // ValueAtQuantileSlice logically represents a slice of ValueAtQuantile. diff --git a/pdata/internal/generated_pmetric_test.go b/pdata/internal/generated_pmetric_test.go index 454ef8e5d7e..1ad9c656a87 100644 --- a/pdata/internal/generated_pmetric_test.go +++ b/pdata/internal/generated_pmetric_test.go @@ -931,10 +931,10 @@ func TestNumberDataPoint_Exemplars(t *testing.T) { assert.EqualValues(t, testValExemplars, ms.Exemplars()) } -func TestNumberDataPoint_FlagsStruct(t *testing.T) { +func TestNumberDataPoint_Flags(t *testing.T) { ms := NewNumberDataPoint() - fillTestMetricDataPointFlagsStruct(ms.FlagsStruct()) - assert.EqualValues(t, generateTestMetricDataPointFlagsStruct(), ms.FlagsStruct()) + fillTestMetricDataPointFlags(ms.Flags()) + assert.EqualValues(t, generateTestMetricDataPointFlags(), ms.Flags()) } func TestHistogramDataPointSlice(t *testing.T) { @@ -1129,10 +1129,10 @@ func TestHistogramDataPoint_Exemplars(t *testing.T) { assert.EqualValues(t, testValExemplars, ms.Exemplars()) } -func TestHistogramDataPoint_FlagsStruct(t *testing.T) { +func TestHistogramDataPoint_Flags(t *testing.T) { ms := NewHistogramDataPoint() - fillTestMetricDataPointFlagsStruct(ms.FlagsStruct()) - assert.EqualValues(t, generateTestMetricDataPointFlagsStruct(), ms.FlagsStruct()) + fillTestMetricDataPointFlags(ms.Flags()) + assert.EqualValues(t, generateTestMetricDataPointFlags(), ms.Flags()) } func TestHistogramDataPoint_Min(t *testing.T) { @@ -1355,10 +1355,10 @@ func TestExponentialHistogramDataPoint_Exemplars(t *testing.T) { assert.EqualValues(t, testValExemplars, ms.Exemplars()) } -func TestExponentialHistogramDataPoint_FlagsStruct(t *testing.T) { +func TestExponentialHistogramDataPoint_Flags(t *testing.T) { ms := NewExponentialHistogramDataPoint() - fillTestMetricDataPointFlagsStruct(ms.FlagsStruct()) - assert.EqualValues(t, generateTestMetricDataPointFlagsStruct(), ms.FlagsStruct()) + fillTestMetricDataPointFlags(ms.Flags()) + assert.EqualValues(t, generateTestMetricDataPointFlags(), ms.Flags()) } func TestExponentialHistogramDataPoint_Min(t *testing.T) { @@ -1587,10 +1587,10 @@ func TestSummaryDataPoint_QuantileValues(t *testing.T) { assert.EqualValues(t, testValQuantileValues, ms.QuantileValues()) } -func TestSummaryDataPoint_FlagsStruct(t *testing.T) { +func TestSummaryDataPoint_Flags(t *testing.T) { ms := NewSummaryDataPoint() - fillTestMetricDataPointFlagsStruct(ms.FlagsStruct()) - assert.EqualValues(t, generateTestMetricDataPointFlagsStruct(), ms.FlagsStruct()) + fillTestMetricDataPointFlags(ms.Flags()) + assert.EqualValues(t, generateTestMetricDataPointFlags(), ms.Flags()) } func TestValueAtQuantileSlice(t *testing.T) { @@ -2074,7 +2074,7 @@ func fillTestNumberDataPoint(tv NumberDataPoint) { tv.SetTimestamp(Timestamp(1234567890)) tv.SetDoubleVal(float64(17.13)) fillTestExemplarSlice(tv.Exemplars()) - fillTestMetricDataPointFlagsStruct(tv.FlagsStruct()) + fillTestMetricDataPointFlags(tv.Flags()) } func generateTestHistogramDataPointSlice() HistogramDataPointSlice { @@ -2106,7 +2106,7 @@ func fillTestHistogramDataPoint(tv HistogramDataPoint) { tv.SetBucketCounts(NewImmutableUInt64Slice([]uint64{1, 2, 3})) tv.SetExplicitBounds(NewImmutableFloat64Slice([]float64{1, 2, 3})) fillTestExemplarSlice(tv.Exemplars()) - fillTestMetricDataPointFlagsStruct(tv.FlagsStruct()) + fillTestMetricDataPointFlags(tv.Flags()) tv.SetMin(float64(9.23)) tv.SetMax(float64(182.55)) } @@ -2142,7 +2142,7 @@ func fillTestExponentialHistogramDataPoint(tv ExponentialHistogramDataPoint) { fillTestBuckets(tv.Positive()) fillTestBuckets(tv.Negative()) fillTestExemplarSlice(tv.Exemplars()) - fillTestMetricDataPointFlagsStruct(tv.FlagsStruct()) + fillTestMetricDataPointFlags(tv.Flags()) tv.SetMin(float64(9.23)) tv.SetMax(float64(182.55)) } @@ -2185,7 +2185,7 @@ func fillTestSummaryDataPoint(tv SummaryDataPoint) { tv.SetCount(uint64(17)) tv.SetSum(float64(17.13)) fillTestValueAtQuantileSlice(tv.QuantileValues()) - fillTestMetricDataPointFlagsStruct(tv.FlagsStruct()) + fillTestMetricDataPointFlags(tv.Flags()) } func generateTestValueAtQuantileSlice() ValueAtQuantileSlice { diff --git a/pdata/internal/metrics.go b/pdata/internal/metrics.go index 0f571b1f1b7..ccce3807949 100644 --- a/pdata/internal/metrics.go +++ b/pdata/internal/metrics.go @@ -183,6 +183,30 @@ func (at MetricAggregationTemporality) String() string { return otlpmetrics.AggregationTemporality(at).String() } +// FlagsStruct returns the flagsstruct associated with this NumberDataPoint. +// Deprecated [0.58.0] Use Flags() instead +func (ms NumberDataPoint) FlagsStruct() MetricDataPointFlagsStruct { + return newMetricDataPointFlagsStruct(&(*ms.orig).Flags) +} + +// FlagsStruct returns the flagsstruct associated with this HistogramDataPoint. +// Deprecated [0.58.0] Use Flags() instead +func (ms HistogramDataPoint) FlagsStruct() MetricDataPointFlagsStruct { + return newMetricDataPointFlagsStruct(&(*ms.orig).Flags) +} + +// FlagsStruct returns the flagsstruct associated with this ExponentialHistogramDataPoint. +// Deprecated [0.58.0] Use Flags() instead +func (ms ExponentialHistogramDataPoint) FlagsStruct() MetricDataPointFlagsStruct { + return newMetricDataPointFlagsStruct(&(*ms.orig).Flags) +} + +// FlagsStruct returns the flagsstruct associated with this SummaryDataPoint. +// Deprecated [0.58.0] Use Flags() instead +func (ms SummaryDataPoint) FlagsStruct() MetricDataPointFlagsStruct { + return newMetricDataPointFlagsStruct(&(*ms.orig).Flags) +} + // MetricDataPointFlagsStruct defines how a metric aggregator reports aggregated values. // It describes how those values relate to the time interval over which they are aggregated. // @@ -191,9 +215,7 @@ func (at MetricAggregationTemporality) String() string { // // Must use NewMetricDataPointFlagsStruct function to create new instances. // Important: zero-initialized instance is not valid for use. -type MetricDataPointFlagsStruct struct { - orig *uint32 -} +type MetricDataPointFlagsStruct = MetricDataPointFlags func newMetricDataPointFlagsStruct(orig *uint32) MetricDataPointFlagsStruct { return MetricDataPointFlagsStruct{orig: orig} @@ -207,26 +229,50 @@ func NewMetricDataPointFlagsStruct() MetricDataPointFlagsStruct { return newMetricDataPointFlagsStruct(new(uint32)) } +// MetricDataPointFlags defines how a metric aggregator reports aggregated values. +// It describes how those values relate to the time interval over which they are aggregated. +// +// This is a reference type, if passed by value and callee modifies it the +// caller will see the modification. +// +// Must use NewMetricDataPointFlagsStruct function to create new instances. +// Important: zero-initialized instance is not valid for use. +type MetricDataPointFlags struct { + orig *uint32 +} + +func newMetricDataPointFlags(orig *uint32) MetricDataPointFlags { + return MetricDataPointFlags{orig: orig} +} + +// NewMetricDataPointFlags creates a new empty MetricDataPointFlags. +// +// This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, +// OR directly access the member if this is embedded in another struct. +func NewMetricDataPointFlags() MetricDataPointFlags { + return newMetricDataPointFlags(new(uint32)) +} + // MoveTo moves all properties from the current struct to dest // resetting the current instance to its zero value -func (ms MetricDataPointFlagsStruct) MoveTo(dest MetricDataPointFlagsStruct) { +func (ms MetricDataPointFlags) MoveTo(dest MetricDataPointFlags) { *dest.orig = *ms.orig *ms.orig = uint32(otlpmetrics.DataPointFlags_FLAG_NONE) } // CopyTo copies all properties from the current struct to the dest. -func (ms MetricDataPointFlagsStruct) CopyTo(dest MetricDataPointFlagsStruct) { +func (ms MetricDataPointFlags) CopyTo(dest MetricDataPointFlags) { *dest.orig = *ms.orig } // NoRecordedValue returns true if the MetricDataPointFlags contains the NO_RECORDED_VALUE flag. -func (ms MetricDataPointFlagsStruct) NoRecordedValue() bool { +func (ms MetricDataPointFlags) NoRecordedValue() bool { return *ms.orig&uint32(otlpmetrics.DataPointFlags_FLAG_NO_RECORDED_VALUE) != 0 } // SetNoRecordedValue sets the FLAG_NO_RECORDED_VALUE flag if true and removes it if false. // Setting this Flag when it is already set will change nothing. -func (ms MetricDataPointFlagsStruct) SetNoRecordedValue(b bool) { +func (ms MetricDataPointFlags) SetNoRecordedValue(b bool) { if b { *ms.orig |= uint32(otlpmetrics.DataPointFlags_FLAG_NO_RECORDED_VALUE) } else { @@ -235,7 +281,7 @@ func (ms MetricDataPointFlagsStruct) SetNoRecordedValue(b bool) { } // String returns the string representation of the MetricDataPointFlags. -func (ms MetricDataPointFlagsStruct) String() string { +func (ms MetricDataPointFlags) String() string { return otlpmetrics.DataPointFlags(*ms.orig).String() } diff --git a/pdata/internal/metrics_test.go b/pdata/internal/metrics_test.go index e64f49decba..f8b400f079a 100644 --- a/pdata/internal/metrics_test.go +++ b/pdata/internal/metrics_test.go @@ -691,23 +691,23 @@ func TestMetricsClone(t *testing.T) { func TestMetricsDataPointFlags(t *testing.T) { gauge := generateTestGauge() - assert.False(t, gauge.DataPoints().At(0).FlagsStruct().NoRecordedValue()) - assert.Equal(t, "FLAG_NONE", gauge.DataPoints().At(0).FlagsStruct().String()) - - gauge.DataPoints().At(1).FlagsStruct().SetNoRecordedValue(true) - assert.True(t, gauge.DataPoints().At(1).FlagsStruct().NoRecordedValue()) - assert.Equal(t, "FLAG_NO_RECORDED_VALUE", gauge.DataPoints().At(1).FlagsStruct().String()) - gauge.DataPoints().At(1).FlagsStruct().SetNoRecordedValue(false) - assert.False(t, gauge.DataPoints().At(1).FlagsStruct().NoRecordedValue()) - - gauge.DataPoints().At(1).FlagsStruct().SetNoRecordedValue(true) - gauge.DataPoints().At(1).FlagsStruct().SetNoRecordedValue(true) - assert.True(t, gauge.DataPoints().At(1).FlagsStruct().NoRecordedValue()) - - gauge.DataPoints().At(0).FlagsStruct().SetNoRecordedValue(true) - gauge.DataPoints().At(0).FlagsStruct().MoveTo(gauge.DataPoints().At(1).FlagsStruct()) - assert.False(t, gauge.DataPoints().At(0).FlagsStruct().NoRecordedValue()) - assert.True(t, gauge.DataPoints().At(1).FlagsStruct().NoRecordedValue()) + assert.False(t, gauge.DataPoints().At(0).Flags().NoRecordedValue()) + assert.Equal(t, "FLAG_NONE", gauge.DataPoints().At(0).Flags().String()) + + gauge.DataPoints().At(1).Flags().SetNoRecordedValue(true) + assert.True(t, gauge.DataPoints().At(1).Flags().NoRecordedValue()) + assert.Equal(t, "FLAG_NO_RECORDED_VALUE", gauge.DataPoints().At(1).Flags().String()) + gauge.DataPoints().At(1).Flags().SetNoRecordedValue(false) + assert.False(t, gauge.DataPoints().At(1).Flags().NoRecordedValue()) + + gauge.DataPoints().At(1).Flags().SetNoRecordedValue(true) + gauge.DataPoints().At(1).Flags().SetNoRecordedValue(true) + assert.True(t, gauge.DataPoints().At(1).Flags().NoRecordedValue()) + + gauge.DataPoints().At(0).Flags().SetNoRecordedValue(true) + gauge.DataPoints().At(0).Flags().MoveTo(gauge.DataPoints().At(1).Flags()) + assert.False(t, gauge.DataPoints().At(0).Flags().NoRecordedValue()) + assert.True(t, gauge.DataPoints().At(1).Flags().NoRecordedValue()) } func BenchmarkMetricsClone(b *testing.B) { @@ -1016,12 +1016,12 @@ func generateMetricsEmptyDataPoints() Metrics { }} } -func fillTestMetricDataPointFlagsStruct(tv MetricDataPointFlagsStruct) { +func fillTestMetricDataPointFlags(tv MetricDataPointFlags) { *tv.orig = uint32(otlpmetrics.DataPointFlags_FLAG_NONE) } -func generateTestMetricDataPointFlagsStruct() MetricDataPointFlagsStruct { - tv := NewMetricDataPointFlagsStruct() - fillTestMetricDataPointFlagsStruct(tv) +func generateTestMetricDataPointFlags() MetricDataPointFlags { + tv := NewMetricDataPointFlags() + fillTestMetricDataPointFlags(tv) return tv } diff --git a/pdata/pmetric/alias.go b/pdata/pmetric/alias.go index 1f3e1cba19a..b687d9deeed 100644 --- a/pdata/pmetric/alias.go +++ b/pdata/pmetric/alias.go @@ -52,11 +52,20 @@ const ( // MetricDataPointFlagsStruct defines how a metric aggregator reports aggregated values. // It describes how those values relate to the time interval over which they are aggregated. +// Deprecated [0.58.0] Use MetricDataPointFlags instead type MetricDataPointFlagsStruct = internal.MetricDataPointFlagsStruct // NewMetricDataPointFlagsStruct returns a new empty MetricDataPointFlagsStruct. +// Deprecated [0.58.0] Use NewMetricDataPointFlags instead var NewMetricDataPointFlagsStruct = internal.NewMetricDataPointFlagsStruct +// MetricDataPointFlags defines how a metric aggregator reports aggregated values. +// It describes how those values relate to the time interval over which they are aggregated. +type MetricDataPointFlags = internal.MetricDataPointFlags + +// NewMetricDataPointFlags returns a new empty MetricDataPointFlags. +var NewMetricDataPointFlags = internal.NewMetricDataPointFlags + // NumberDataPointValueType specifies the type of NumberDataPoint value. type NumberDataPointValueType = internal.NumberDataPointValueType From a3b144e5ae4e4ef5dd8bea71a684f44f99929fc4 Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Fri, 5 Aug 2022 15:44:37 -0600 Subject: [PATCH 2/6] Updated changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d56c4e1efb..e7f883b5ce8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,10 @@ - `component.ReceiverFactory.MetricsReceiverStability` - `component.ReceiverFactory.LogsReceiverStability` - Deprecate `obsreport.ProcessorSettings.Level` and `obsreport.ExporterSettings.Level`, use MetricsLevel from CreateSettings (#5824) +- Deprecates `FlagsStruct` in favor of `Flags` (#5842) + - `MetricDataPointFlagsStruct` -> `MetricDataPointFlags` + - `NewMetricDataPointFlagsStruct` -> `NewMetricDataPointFlags` + - `FlagsStruct` -> `Flags` ### 💡 Enhancements 💡 From d6df8019b041e2a46420e42559c4f9fa5ef20ce3 Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Fri, 5 Aug 2022 15:52:30 -0600 Subject: [PATCH 3/6] Fix lint --- pdata/internal/metrics.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pdata/internal/metrics.go b/pdata/internal/metrics.go index ccce3807949..e2d591f74ae 100644 --- a/pdata/internal/metrics.go +++ b/pdata/internal/metrics.go @@ -186,25 +186,25 @@ func (at MetricAggregationTemporality) String() string { // FlagsStruct returns the flagsstruct associated with this NumberDataPoint. // Deprecated [0.58.0] Use Flags() instead func (ms NumberDataPoint) FlagsStruct() MetricDataPointFlagsStruct { - return newMetricDataPointFlagsStruct(&(*ms.orig).Flags) + return newMetricDataPointFlagsStruct(&ms.orig.Flags) } // FlagsStruct returns the flagsstruct associated with this HistogramDataPoint. // Deprecated [0.58.0] Use Flags() instead func (ms HistogramDataPoint) FlagsStruct() MetricDataPointFlagsStruct { - return newMetricDataPointFlagsStruct(&(*ms.orig).Flags) + return newMetricDataPointFlagsStruct(&ms.orig.Flags) } // FlagsStruct returns the flagsstruct associated with this ExponentialHistogramDataPoint. // Deprecated [0.58.0] Use Flags() instead func (ms ExponentialHistogramDataPoint) FlagsStruct() MetricDataPointFlagsStruct { - return newMetricDataPointFlagsStruct(&(*ms.orig).Flags) + return newMetricDataPointFlagsStruct(&ms.orig.Flags) } // FlagsStruct returns the flagsstruct associated with this SummaryDataPoint. // Deprecated [0.58.0] Use Flags() instead func (ms SummaryDataPoint) FlagsStruct() MetricDataPointFlagsStruct { - return newMetricDataPointFlagsStruct(&(*ms.orig).Flags) + return newMetricDataPointFlagsStruct(&ms.orig.Flags) } // MetricDataPointFlagsStruct defines how a metric aggregator reports aggregated values. From dba2011c13aa6f5d3530dbbc4623bcc76098a44c Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Fri, 5 Aug 2022 16:10:25 -0600 Subject: [PATCH 4/6] Simplification --- pdata/internal/metrics.go | 38 ++++++++------------------------------ pdata/pmetric/alias.go | 4 ++-- 2 files changed, 10 insertions(+), 32 deletions(-) diff --git a/pdata/internal/metrics.go b/pdata/internal/metrics.go index e2d591f74ae..6b5dd6ec7f2 100644 --- a/pdata/internal/metrics.go +++ b/pdata/internal/metrics.go @@ -185,48 +185,26 @@ func (at MetricAggregationTemporality) String() string { // FlagsStruct returns the flagsstruct associated with this NumberDataPoint. // Deprecated [0.58.0] Use Flags() instead -func (ms NumberDataPoint) FlagsStruct() MetricDataPointFlagsStruct { - return newMetricDataPointFlagsStruct(&ms.orig.Flags) +func (ms NumberDataPoint) FlagsStruct() MetricDataPointFlags { + return ms.Flags() } // FlagsStruct returns the flagsstruct associated with this HistogramDataPoint. // Deprecated [0.58.0] Use Flags() instead -func (ms HistogramDataPoint) FlagsStruct() MetricDataPointFlagsStruct { - return newMetricDataPointFlagsStruct(&ms.orig.Flags) +func (ms HistogramDataPoint) FlagsStruct() MetricDataPointFlags { + return ms.Flags() } // FlagsStruct returns the flagsstruct associated with this ExponentialHistogramDataPoint. // Deprecated [0.58.0] Use Flags() instead -func (ms ExponentialHistogramDataPoint) FlagsStruct() MetricDataPointFlagsStruct { - return newMetricDataPointFlagsStruct(&ms.orig.Flags) +func (ms ExponentialHistogramDataPoint) FlagsStruct() MetricDataPointFlags { + return ms.Flags() } // FlagsStruct returns the flagsstruct associated with this SummaryDataPoint. // Deprecated [0.58.0] Use Flags() instead -func (ms SummaryDataPoint) FlagsStruct() MetricDataPointFlagsStruct { - return newMetricDataPointFlagsStruct(&ms.orig.Flags) -} - -// MetricDataPointFlagsStruct defines how a metric aggregator reports aggregated values. -// It describes how those values relate to the time interval over which they are aggregated. -// -// This is a reference type, if passed by value and callee modifies it the -// caller will see the modification. -// -// Must use NewMetricDataPointFlagsStruct function to create new instances. -// Important: zero-initialized instance is not valid for use. -type MetricDataPointFlagsStruct = MetricDataPointFlags - -func newMetricDataPointFlagsStruct(orig *uint32) MetricDataPointFlagsStruct { - return MetricDataPointFlagsStruct{orig: orig} -} - -// NewMetricDataPointFlagsStruct creates a new empty MetricDataPointFlagsStruct. -// -// This must be used only in testing code. Users should use "AppendEmpty" when part of a Slice, -// OR directly access the member if this is embedded in another struct. -func NewMetricDataPointFlagsStruct() MetricDataPointFlagsStruct { - return newMetricDataPointFlagsStruct(new(uint32)) +func (ms SummaryDataPoint) FlagsStruct() MetricDataPointFlags { + return ms.Flags() } // MetricDataPointFlags defines how a metric aggregator reports aggregated values. diff --git a/pdata/pmetric/alias.go b/pdata/pmetric/alias.go index b687d9deeed..b7140d4453e 100644 --- a/pdata/pmetric/alias.go +++ b/pdata/pmetric/alias.go @@ -53,11 +53,11 @@ const ( // MetricDataPointFlagsStruct defines how a metric aggregator reports aggregated values. // It describes how those values relate to the time interval over which they are aggregated. // Deprecated [0.58.0] Use MetricDataPointFlags instead -type MetricDataPointFlagsStruct = internal.MetricDataPointFlagsStruct +type MetricDataPointFlagsStruct = internal.MetricDataPointFlags // NewMetricDataPointFlagsStruct returns a new empty MetricDataPointFlagsStruct. // Deprecated [0.58.0] Use NewMetricDataPointFlags instead -var NewMetricDataPointFlagsStruct = internal.NewMetricDataPointFlagsStruct +var NewMetricDataPointFlagsStruct = internal.NewMetricDataPointFlags // MetricDataPointFlags defines how a metric aggregator reports aggregated values. // It describes how those values relate to the time interval over which they are aggregated. From 046ff357a08559d383776168380ced90f67b09a0 Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Fri, 5 Aug 2022 16:12:15 -0600 Subject: [PATCH 5/6] Update pdata/pmetric/alias.go Co-authored-by: Bogdan Drutu --- pdata/pmetric/alias.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pdata/pmetric/alias.go b/pdata/pmetric/alias.go index b7140d4453e..ea98ef54be2 100644 --- a/pdata/pmetric/alias.go +++ b/pdata/pmetric/alias.go @@ -53,7 +53,7 @@ const ( // MetricDataPointFlagsStruct defines how a metric aggregator reports aggregated values. // It describes how those values relate to the time interval over which they are aggregated. // Deprecated [0.58.0] Use MetricDataPointFlags instead -type MetricDataPointFlagsStruct = internal.MetricDataPointFlags +type MetricDataPointFlagsStruct = MetricDataPointFlags // NewMetricDataPointFlagsStruct returns a new empty MetricDataPointFlagsStruct. // Deprecated [0.58.0] Use NewMetricDataPointFlags instead From 66901a32e37e9422295124ce289bc23425df04ab Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Fri, 5 Aug 2022 16:12:20 -0600 Subject: [PATCH 6/6] Update pdata/pmetric/alias.go Co-authored-by: Bogdan Drutu --- pdata/pmetric/alias.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pdata/pmetric/alias.go b/pdata/pmetric/alias.go index ea98ef54be2..c31b817302f 100644 --- a/pdata/pmetric/alias.go +++ b/pdata/pmetric/alias.go @@ -57,7 +57,7 @@ type MetricDataPointFlagsStruct = MetricDataPointFlags // NewMetricDataPointFlagsStruct returns a new empty MetricDataPointFlagsStruct. // Deprecated [0.58.0] Use NewMetricDataPointFlags instead -var NewMetricDataPointFlagsStruct = internal.NewMetricDataPointFlags +var NewMetricDataPointFlagsStruct = NewMetricDataPointFlags // MetricDataPointFlags defines how a metric aggregator reports aggregated values. // It describes how those values relate to the time interval over which they are aggregated.