Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pdata] Rename MetricAggregationTemporality to AggregationTemporality #6253

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
- Deprecate `p[metric|log|trace]otlp.RegiserServer` in favor of `p[metric|log|trace]otlp.RegiserGRPCServer` (#6180)
- Deprecate `pcommon.Map.PutString` in favor of `pcommon.Map.PutStr` (#6210)
- Deprecate `pcommon.NewValueString` in favor of `pcommon.NewValueStr` (#6209)
- Deprecate `pmetric.MetricAggregationTemporality` enum type in favor of `pmetric.AggregationTemporality` (#6249)

### 💡 Enhancements 💡

Expand Down
6 changes: 3 additions & 3 deletions internal/testdata/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,13 @@ func initMetric(m pmetric.Metric, name string, ty pmetric.MetricType) {
case pmetric.MetricTypeSum:
sum := m.SetEmptySum()
sum.SetIsMonotonic(true)
sum.SetAggregationTemporality(pmetric.MetricAggregationTemporalityCumulative)
sum.SetAggregationTemporality(pmetric.AggregationTemporalityCumulative)
case pmetric.MetricTypeHistogram:
histo := m.SetEmptyHistogram()
histo.SetAggregationTemporality(pmetric.MetricAggregationTemporalityCumulative)
histo.SetAggregationTemporality(pmetric.AggregationTemporalityCumulative)
case pmetric.MetricTypeExponentialHistogram:
histo := m.SetEmptyExponentialHistogram()
histo.SetAggregationTemporality(pmetric.MetricAggregationTemporalityDelta)
histo.SetAggregationTemporality(pmetric.AggregationTemporalityDelta)
case pmetric.MetricTypeSummary:
m.SetEmptySummary()
}
Expand Down
2 changes: 1 addition & 1 deletion pdata/internal/cmd/pdatagen/internal/metrics_structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ var aggregationTemporalityField = &primitiveTypedField{
fieldName: "AggregationTemporality",
originFieldName: "AggregationTemporality",
returnType: &primitiveType{
structName: "MetricAggregationTemporality",
structName: "AggregationTemporality",
rawType: "otlpmetrics.AggregationTemporality",
defaultVal: "otlpmetrics.AggregationTemporality(0)",
testVal: "otlpmetrics.AggregationTemporality(1)",
Expand Down
18 changes: 9 additions & 9 deletions pdata/pmetric/generated_metrics.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions pdata/pmetric/generated_metrics_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pdata/pmetric/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ var metricsSumOTLPFull = func() Metrics {
sumMetric.SetDescription("test sum")
sumMetric.SetUnit("unit")
sum := sumMetric.SetEmptySum()
sum.SetAggregationTemporality(MetricAggregationTemporalityCumulative)
sum.SetAggregationTemporality(AggregationTemporalityCumulative)
sum.SetIsMonotonic(true)
datapoint := sum.DataPoints().AppendEmpty()
datapoint.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now()))
Expand Down Expand Up @@ -157,7 +157,7 @@ var metricsHistogramOTLPFull = func() Metrics {
histogramMetric.SetDescription("test Histogram")
histogramMetric.SetUnit("unit")
histogram := histogramMetric.SetEmptyHistogram()
histogram.SetAggregationTemporality(MetricAggregationTemporalityCumulative)
histogram.SetAggregationTemporality(AggregationTemporalityCumulative)
datapoint := histogram.DataPoints().AppendEmpty()
datapoint.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now()))
datapoint.Attributes().PutStr("string", "value")
Expand Down Expand Up @@ -202,7 +202,7 @@ var metricsExponentialHistogramOTLPFull = func() Metrics {
histogramMetric.SetDescription("test ExponentialHistogram")
histogramMetric.SetUnit("unit")
histogram := histogramMetric.SetEmptyExponentialHistogram()
histogram.SetAggregationTemporality(MetricAggregationTemporalityCumulative)
histogram.SetAggregationTemporality(AggregationTemporalityCumulative)
datapoint := histogram.DataPoints().AppendEmpty()
datapoint.SetScale(1)
datapoint.SetStartTimestamp(pcommon.NewTimestampFromTime(time.Now()))
Expand Down
40 changes: 27 additions & 13 deletions pdata/pmetric/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,32 +129,46 @@ func (mdt MetricType) String() string {
return ""
}

// MetricAggregationTemporality defines how a metric aggregator reports aggregated values.
// AggregationTemporality defines how a metric aggregator reports aggregated values.
// It describes how those values relate to the time interval over which they are aggregated.
type MetricAggregationTemporality int32
type AggregationTemporality int32

const (
// MetricAggregationTemporalityUnspecified is the default MetricAggregationTemporality, it MUST NOT be used.
MetricAggregationTemporalityUnspecified = MetricAggregationTemporality(otlpmetrics.AggregationTemporality_AGGREGATION_TEMPORALITY_UNSPECIFIED)
// MetricAggregationTemporalityDelta is a MetricAggregationTemporality for a metric aggregator which reports changes since last report time.
MetricAggregationTemporalityDelta = MetricAggregationTemporality(otlpmetrics.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA)
// MetricAggregationTemporalityCumulative is a MetricAggregationTemporality for a metric aggregator which reports changes since a fixed start time.
MetricAggregationTemporalityCumulative = MetricAggregationTemporality(otlpmetrics.AggregationTemporality_AGGREGATION_TEMPORALITY_CUMULATIVE)
// AggregationTemporalityUnspecified is the default AggregationTemporality, it MUST NOT be used.
AggregationTemporalityUnspecified = AggregationTemporality(otlpmetrics.AggregationTemporality_AGGREGATION_TEMPORALITY_UNSPECIFIED)
// AggregationTemporalityDelta is a AggregationTemporality for a metric aggregator which reports changes since last report time.
AggregationTemporalityDelta = AggregationTemporality(otlpmetrics.AggregationTemporality_AGGREGATION_TEMPORALITY_DELTA)
// AggregationTemporalityCumulative is a AggregationTemporality for a metric aggregator which reports changes since a fixed start time.
AggregationTemporalityCumulative = AggregationTemporality(otlpmetrics.AggregationTemporality_AGGREGATION_TEMPORALITY_CUMULATIVE)
)

// String returns the string representation of the MetricAggregationTemporality.
func (at MetricAggregationTemporality) String() string {
// String returns the string representation of the AggregationTemporality.
func (at AggregationTemporality) String() string {
switch at {
case MetricAggregationTemporalityUnspecified:
case AggregationTemporalityUnspecified:
return "Unspecified"
case MetricAggregationTemporalityDelta:
case AggregationTemporalityDelta:
return "Delta"
case MetricAggregationTemporalityCumulative:
case AggregationTemporalityCumulative:
return "Cumulative"
}
return ""
}

// Deprecated: [0.62.0] Use AggregationTemporality instead.
type MetricAggregationTemporality = AggregationTemporality

const (
// Deprecated: [0.62.0] Use AggregationTemporalityUnspecified instead.
MetricAggregationTemporalityUnspecified = AggregationTemporalityUnspecified

// Deprecated: [0.62.0] Use AggregationTemporalityDelta instead.
MetricAggregationTemporalityDelta = AggregationTemporalityDelta

// Deprecated: [0.62.0] Use AggregationTemporalityCumulative instead.
MetricAggregationTemporalityCumulative = AggregationTemporalityCumulative
)

// NumberDataPointValueType specifies the type of NumberDataPoint value.
type NumberDataPointValueType int32

Expand Down
20 changes: 10 additions & 10 deletions pdata/pmetric/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ func TestMetricTypeString(t *testing.T) {
assert.Equal(t, "", (MetricTypeSummary + 1).String())
}

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 TestAggregationTemporalityString(t *testing.T) {
assert.Equal(t, "Unspecified", AggregationTemporalityUnspecified.String())
assert.Equal(t, "Delta", AggregationTemporalityDelta.String())
assert.Equal(t, "Cumulative", AggregationTemporalityCumulative.String())
assert.Equal(t, "", (AggregationTemporalityCumulative + 1).String())
}

func TestNumberDataPointValueTypeString(t *testing.T) {
Expand Down Expand Up @@ -284,7 +284,7 @@ func TestOtlpToInternalReadOnly(t *testing.T) {
assert.EqualValues(t, "ms", metricDouble.Unit())
assert.EqualValues(t, MetricTypeSum, metricDouble.Type())
dsd := metricDouble.Sum()
assert.EqualValues(t, MetricAggregationTemporalityCumulative, dsd.AggregationTemporality())
assert.EqualValues(t, AggregationTemporalityCumulative, dsd.AggregationTemporality())
sumDataPoints := dsd.DataPoints()
assert.EqualValues(t, 2, sumDataPoints.Len())
// First point
Expand All @@ -305,7 +305,7 @@ func TestOtlpToInternalReadOnly(t *testing.T) {
assert.EqualValues(t, "ms", metricHistogram.Unit())
assert.EqualValues(t, MetricTypeHistogram, metricHistogram.Type())
dhd := metricHistogram.Histogram()
assert.EqualValues(t, MetricAggregationTemporalityDelta, dhd.AggregationTemporality())
assert.EqualValues(t, AggregationTemporalityDelta, dhd.AggregationTemporality())
histogramDataPoints := dhd.DataPoints()
assert.EqualValues(t, 2, histogramDataPoints.Len())
// First point
Expand Down Expand Up @@ -462,7 +462,7 @@ func TestOtlpToFromInternalSumMutating(t *testing.T) {
// Mutate DataPoints
dsd := metric.Sum()
assert.EqualValues(t, 2, dsd.DataPoints().Len())
metric.SetEmptySum().SetAggregationTemporality(MetricAggregationTemporalityCumulative)
metric.SetEmptySum().SetAggregationTemporality(AggregationTemporalityCumulative)
doubleDataPoints := metric.Sum().DataPoints()
doubleDataPoints.AppendEmpty()
assert.EqualValues(t, 1, doubleDataPoints.Len())
Expand Down Expand Up @@ -546,7 +546,7 @@ func TestOtlpToFromInternalHistogramMutating(t *testing.T) {
// Mutate DataPoints
dhd := metric.Histogram()
assert.EqualValues(t, 2, dhd.DataPoints().Len())
metric.SetEmptyHistogram().SetAggregationTemporality(MetricAggregationTemporalityDelta)
metric.SetEmptyHistogram().SetAggregationTemporality(AggregationTemporalityDelta)
histogramDataPoints := metric.Histogram().DataPoints()
histogramDataPoints.AppendEmpty()
assert.EqualValues(t, 1, histogramDataPoints.Len())
Expand Down Expand Up @@ -629,7 +629,7 @@ func TestOtlpToFromInternalExponentialHistogramMutating(t *testing.T) {
// Mutate DataPoints
dhd := metric.Histogram()
assert.EqualValues(t, 2, dhd.DataPoints().Len())
metric.SetEmptyExponentialHistogram().SetAggregationTemporality(MetricAggregationTemporalityDelta)
metric.SetEmptyExponentialHistogram().SetAggregationTemporality(AggregationTemporalityDelta)
histogramDataPoints := metric.ExponentialHistogram().DataPoints()
histogramDataPoints.AppendEmpty()
assert.EqualValues(t, 1, histogramDataPoints.Len())
Expand Down
16 changes: 8 additions & 8 deletions processor/batchprocessor/splitmetrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func TestSplitMetricsAllTypes(t *testing.T) {
assert.Equal(t, 1, gaugeDouble.Gauge().DataPoints().Len())
assert.Equal(t, "test-metric-int-0-1", gaugeDouble.Name())
assert.Equal(t, 1, sumInt.Sum().DataPoints().Len())
assert.Equal(t, pmetric.MetricAggregationTemporalityCumulative, sumInt.Sum().AggregationTemporality())
assert.Equal(t, pmetric.AggregationTemporalityCumulative, sumInt.Sum().AggregationTemporality())
assert.Equal(t, true, sumInt.Sum().IsMonotonic())
assert.Equal(t, "test-metric-int-0-2", sumInt.Name())

Expand All @@ -212,11 +212,11 @@ func TestSplitMetricsAllTypes(t *testing.T) {
sumInt = split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0)
sumDouble := split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(1)
assert.Equal(t, 1, sumInt.Sum().DataPoints().Len())
assert.Equal(t, pmetric.MetricAggregationTemporalityCumulative, sumInt.Sum().AggregationTemporality())
assert.Equal(t, pmetric.AggregationTemporalityCumulative, sumInt.Sum().AggregationTemporality())
assert.Equal(t, true, sumInt.Sum().IsMonotonic())
assert.Equal(t, "test-metric-int-0-2", sumInt.Name())
assert.Equal(t, 1, sumDouble.Sum().DataPoints().Len())
assert.Equal(t, pmetric.MetricAggregationTemporalityCumulative, sumDouble.Sum().AggregationTemporality())
assert.Equal(t, pmetric.AggregationTemporalityCumulative, sumDouble.Sum().AggregationTemporality())
assert.Equal(t, true, sumDouble.Sum().IsMonotonic())
assert.Equal(t, "test-metric-int-0-3", sumDouble.Name())

Expand All @@ -226,11 +226,11 @@ func TestSplitMetricsAllTypes(t *testing.T) {
sumDouble = split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0)
histogram := split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(1)
assert.Equal(t, 1, sumDouble.Sum().DataPoints().Len())
assert.Equal(t, pmetric.MetricAggregationTemporalityCumulative, sumDouble.Sum().AggregationTemporality())
assert.Equal(t, pmetric.AggregationTemporalityCumulative, sumDouble.Sum().AggregationTemporality())
assert.Equal(t, true, sumDouble.Sum().IsMonotonic())
assert.Equal(t, "test-metric-int-0-3", sumDouble.Name())
assert.Equal(t, 1, histogram.Histogram().DataPoints().Len())
assert.Equal(t, pmetric.MetricAggregationTemporalityCumulative, histogram.Histogram().AggregationTemporality())
assert.Equal(t, pmetric.AggregationTemporalityCumulative, histogram.Histogram().AggregationTemporality())
assert.Equal(t, "test-metric-int-0-4", histogram.Name())

split = splitMetrics(splitSize, md)
Expand All @@ -239,10 +239,10 @@ func TestSplitMetricsAllTypes(t *testing.T) {
histogram = split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0)
exponentialHistogram := split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(1)
assert.Equal(t, 1, histogram.Histogram().DataPoints().Len())
assert.Equal(t, pmetric.MetricAggregationTemporalityCumulative, histogram.Histogram().AggregationTemporality())
assert.Equal(t, pmetric.AggregationTemporalityCumulative, histogram.Histogram().AggregationTemporality())
assert.Equal(t, "test-metric-int-0-4", histogram.Name())
assert.Equal(t, 1, exponentialHistogram.ExponentialHistogram().DataPoints().Len())
assert.Equal(t, pmetric.MetricAggregationTemporalityDelta, exponentialHistogram.ExponentialHistogram().AggregationTemporality())
assert.Equal(t, pmetric.AggregationTemporalityDelta, exponentialHistogram.ExponentialHistogram().AggregationTemporality())
assert.Equal(t, "test-metric-int-0-5", exponentialHistogram.Name())

split = splitMetrics(splitSize, md)
Expand All @@ -251,7 +251,7 @@ func TestSplitMetricsAllTypes(t *testing.T) {
exponentialHistogram = split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(0)
summary := split.ResourceMetrics().At(0).ScopeMetrics().At(0).Metrics().At(1)
assert.Equal(t, 1, exponentialHistogram.ExponentialHistogram().DataPoints().Len())
assert.Equal(t, pmetric.MetricAggregationTemporalityDelta, exponentialHistogram.ExponentialHistogram().AggregationTemporality())
assert.Equal(t, pmetric.AggregationTemporalityDelta, exponentialHistogram.ExponentialHistogram().AggregationTemporality())
assert.Equal(t, "test-metric-int-0-5", exponentialHistogram.Name())
assert.Equal(t, 1, summary.Summary().DataPoints().Len())
assert.Equal(t, "test-metric-int-0-6", summary.Name())
Expand Down