From 100722ef2a60c07229c3ca1e06e44b096a73e95d Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Tue, 4 Oct 2022 15:50:27 -0700 Subject: [PATCH] Change AggregationTemporality.String to simpler, easier to read (#6117) Signed-off-by: Bogdan Signed-off-by: Bogdan --- CHANGELOG.md | 1 + pdata/pmetric/metrics.go | 10 +++++++++- pdata/pmetric/metrics_test.go | 11 +++++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7cc4104183..421f7cc8b94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - Delete deprecated `pcommon.Value` getter/setter methods with `Val` suffix. (#6178) - Delete deprecated `StringVal` and `SetStringVal` methods. (#6178) - Delete deprecated `ValueTypeString` method. (#6178) +- Change AggregationTemporality.String to simpler, easier to read. (#6117) ### 🚩 Deprecations 🚩 diff --git a/pdata/pmetric/metrics.go b/pdata/pmetric/metrics.go index d5dd4825271..11b968789f3 100644 --- a/pdata/pmetric/metrics.go +++ b/pdata/pmetric/metrics.go @@ -144,7 +144,15 @@ const ( // String returns the string representation of the MetricAggregationTemporality. func (at MetricAggregationTemporality) String() string { - return otlpmetrics.AggregationTemporality(at).String() + switch at { + case MetricAggregationTemporalityUnspecified: + return "Unspecified" + case MetricAggregationTemporalityDelta: + return "Delta" + case MetricAggregationTemporalityCumulative: + return "Cumulative" + } + return "" } // NumberDataPointValueType specifies the type of NumberDataPoint value. diff --git a/pdata/pmetric/metrics_test.go b/pdata/pmetric/metrics_test.go index d4c642842cc..4579412d6b9 100644 --- a/pdata/pmetric/metrics_test.go +++ b/pdata/pmetric/metrics_test.go @@ -45,14 +45,21 @@ func TestMetricTypeString(t *testing.T) { assert.Equal(t, "", (MetricTypeSummary + 1).String()) } -func TestNumberDataPointValueTypeStr(t *testing.T) { +func TestMetricAggregationTemporalityString(t *testing.T) { + assert.Equal(t, "Unspecified", MetricAggregationTemporalityUnspecified.String()) + assert.Equal(t, "Delta", MetricAggregationTemporalityDelta.String()) + assert.Equal(t, "Cumulative", MetricAggregationTemporalityCumulative.String()) + assert.Equal(t, "", (MetricAggregationTemporalityCumulative + 1).String()) +} + +func TestNumberDataPointValueTypeString(t *testing.T) { assert.Equal(t, "None", NumberDataPointValueTypeNone.String()) assert.Equal(t, "Int", NumberDataPointValueTypeInt.String()) assert.Equal(t, "Double", NumberDataPointValueTypeDouble.String()) assert.Equal(t, "", (NumberDataPointValueTypeDouble + 1).String()) } -func TestExemplarValueTypeStr(t *testing.T) { +func TestExemplarValueTypeString(t *testing.T) { assert.Equal(t, "None", ExemplarValueTypeNone.String()) assert.Equal(t, "Int", ExemplarValueTypeInt.String()) assert.Equal(t, "Double", ExemplarValueTypeDouble.String())