diff --git a/go.mod b/go.mod index 36ad210e8e0..dcdc03abbb9 100644 --- a/go.mod +++ b/go.mod @@ -34,6 +34,7 @@ require ( github.com/orijtech/prometheus-go-metrics-exporter v0.0.5 github.com/ory/go-acc v0.2.5 github.com/pavius/impi v0.0.3 + github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.7.1 github.com/prometheus/common v0.11.1 github.com/prometheus/prometheus v1.8.2-0.20200626085723-c448ada63d83 diff --git a/internal/data/testdata/metric.go b/internal/data/testdata/metric.go index c0155a23be4..6c5605810b2 100644 --- a/internal/data/testdata/metric.go +++ b/internal/data/testdata/metric.go @@ -228,6 +228,7 @@ func GenerateMetricsOneMetricNoLabels() data.MetricData { md := GenerateMetricsOneMetric() dps := md.ResourceMetrics().At(0).InstrumentationLibraryMetrics().At(0).Metrics().At(0).IntSumData().DataPoints() dps.At(0).LabelsMap().InitFromMap(map[string]string{}) + dps.At(1).LabelsMap().InitFromMap(map[string]string{}) return md } @@ -235,6 +236,7 @@ func generateMetricsOtlpOneMetricNoLabels() []*otlpmetrics.ResourceMetrics { md := generateMetricsOtlpOneMetric() mis := md[0].InstrumentationLibraryMetrics[0].Metrics[0].Data.(*otlpmetrics.Metric_IntSum).IntSum mis.DataPoints[0].Labels = nil + mis.DataPoints[1].Labels = nil return md } @@ -326,7 +328,7 @@ func GenerateMetricsMetricTypeInvalid() data.MetricData { ms := ilm0.Metrics() ms.Resize(1) - initMetric(ms.At(0), TestGaugeDoubleMetricName, pdata.MetricDataNone) + initMetric(ms.At(0), TestCounterIntMetricName, pdata.MetricDataNone) return md } @@ -350,26 +352,26 @@ func generateMetricsOtlpAllTypesNoDataPoints() []*otlpmetrics.ResourceMetrics { } } -func GenerateMetricsWithCountersHistogram() data.MetricData { +func GenerateMetricsWithCountersHistograms() data.MetricData { metricData := data.NewMetricData() metricData.ResourceMetrics().Resize(1) rms := metricData.ResourceMetrics() - - rms.At(0).InstrumentationLibraryMetrics().Resize(1) initResource1(rms.At(0).Resource()) + rms.At(0).InstrumentationLibraryMetrics().Resize(1) ilms := rms.At(0).InstrumentationLibraryMetrics() - ilms.At(0).Metrics().Resize(3) + ilms.At(0).Metrics().Resize(4) ms := ilms.At(0).Metrics() initCounterIntMetric(ms.At(0)) initSumDoubleMetric(ms.At(1)) initDoubleHistogramMetric(ms.At(2)) + initIntHistogramMetric(ms.At(3)) return metricData } -func generateMetricsOtlpWithCountersHistogram() []*otlpmetrics.ResourceMetrics { +func generateMetricsOtlpWithCountersHistograms() []*otlpmetrics.ResourceMetrics { return []*otlpmetrics.ResourceMetrics{ { Resource: generateOtlpResource1(), @@ -379,6 +381,7 @@ func generateMetricsOtlpWithCountersHistogram() []*otlpmetrics.ResourceMetrics { generateOtlpCounterIntMetric(), generateOtlpSumDoubleMetric(), generateOtlpDoubleHistogramMetric(), + generateOtlpIntHistogramMetric(), }, }, }, @@ -531,6 +534,64 @@ func generateOtlpDoubleHistogramMetric() *otlpmetrics.Metric { return m } +func initIntHistogramMetric(hm pdata.Metric) { + initMetric(hm, TestIntHistogramMetricName, pdata.MetricDataIntHistogram) + + hdps := hm.IntHistogramData().DataPoints() + hdps.Resize(2) + hdp0 := hdps.At(0) + initMetricLabels13(hdp0.LabelsMap()) + hdp0.SetStartTime(TestMetricStartTimestamp) + hdp0.SetTimestamp(TestMetricTimestamp) + hdp0.SetCount(1) + hdp0.SetSum(15) + hdp1 := hdps.At(1) + initMetricLabels2(hdp1.LabelsMap()) + hdp1.SetStartTime(TestMetricStartTimestamp) + hdp1.SetTimestamp(TestMetricTimestamp) + hdp1.SetCount(1) + hdp1.SetSum(15) + hdp1.SetBucketCounts([]uint64{0, 1}) + exemplars := hdp1.Exemplars() + exemplars.Resize(1) + exemplar := exemplars.At(0) + exemplar.SetTimestamp(TestMetricExemplarTimestamp) + exemplar.SetValue(15) + initMetricAttachment(exemplar.FilteredLabels()) + hdp1.SetExplicitBounds([]float64{1}) +} + +func generateOtlpIntHistogramMetric() *otlpmetrics.Metric { + m := generateOtlpMetric(TestIntHistogramMetricName, pdata.MetricDataIntHistogram) + m.Data.(*otlpmetrics.Metric_IntHistogram).IntHistogram.DataPoints = + []*otlpmetrics.IntHistogramDataPoint{ + { + Labels: generateOtlpMetricLabels13(), + StartTimeUnixNano: uint64(TestMetricStartTimestamp), + TimeUnixNano: uint64(TestMetricTimestamp), + Count: 1, + Sum: 15, + }, + { + Labels: generateOtlpMetricLabels2(), + StartTimeUnixNano: uint64(TestMetricStartTimestamp), + TimeUnixNano: uint64(TestMetricTimestamp), + Count: 1, + Sum: 15, + BucketCounts: []uint64{0, 1}, + ExplicitBounds: []float64{1}, + Exemplars: []*otlpmetrics.IntExemplar{ + { + FilteredLabels: generateOtlpMetricAttachment(), + TimeUnixNano: uint64(TestMetricExemplarTimestamp), + Value: 15, + }, + }, + }, + } + return m +} + func initMetric(m pdata.Metric, name string, ty pdata.MetricDataType) { m.InitEmpty() m.SetName(name) @@ -548,18 +609,24 @@ func initMetric(m pdata.Metric, name string, ty pdata.MetricDataType) { case pdata.MetricDataIntSum: md := pdata.NewIntSum() md.InitEmpty() + md.SetIsMonotonic(true) + md.SetAggregationTemporality(pdata.AggregationTemporalityCumulative) m.SetIntSumData(md) case pdata.MetricDataDoubleSum: md := pdata.NewDoubleSum() md.InitEmpty() + md.SetIsMonotonic(true) + md.SetAggregationTemporality(pdata.AggregationTemporalityCumulative) m.SetDoubleSumData(md) case pdata.MetricDataIntHistogram: md := pdata.NewIntHistogram() md.InitEmpty() + md.SetAggregationTemporality(pdata.AggregationTemporalityCumulative) m.SetIntHistogramData(md) case pdata.MetricDataDoubleHistogram: md := pdata.NewDoubleHistogram() md.InitEmpty() + md.SetAggregationTemporality(pdata.AggregationTemporalityCumulative) m.SetDoubleHistogramData(md) } } @@ -576,13 +643,23 @@ func generateOtlpMetric(name string, ty pdata.MetricDataType) *otlpmetrics.Metri case pdata.MetricDataDoubleGauge: m.Data = &otlpmetrics.Metric_DoubleGauge{DoubleGauge: &otlpmetrics.DoubleGauge{}} case pdata.MetricDataIntSum: - m.Data = &otlpmetrics.Metric_IntSum{IntSum: &otlpmetrics.IntSum{}} + m.Data = &otlpmetrics.Metric_IntSum{IntSum: &otlpmetrics.IntSum{ + IsMonotonic: true, + AggregationTemporality: otlpmetrics.AggregationTemporality_AGGREGATION_TEMPORALITY_CUMULATIVE, + }} case pdata.MetricDataDoubleSum: - m.Data = &otlpmetrics.Metric_DoubleSum{DoubleSum: &otlpmetrics.DoubleSum{}} + m.Data = &otlpmetrics.Metric_DoubleSum{DoubleSum: &otlpmetrics.DoubleSum{ + IsMonotonic: true, + AggregationTemporality: otlpmetrics.AggregationTemporality_AGGREGATION_TEMPORALITY_CUMULATIVE, + }} case pdata.MetricDataIntHistogram: - m.Data = &otlpmetrics.Metric_IntHistogram{IntHistogram: &otlpmetrics.IntHistogram{}} + m.Data = &otlpmetrics.Metric_IntHistogram{IntHistogram: &otlpmetrics.IntHistogram{ + AggregationTemporality: otlpmetrics.AggregationTemporality_AGGREGATION_TEMPORALITY_CUMULATIVE, + }} case pdata.MetricDataDoubleHistogram: - m.Data = &otlpmetrics.Metric_DoubleHistogram{DoubleHistogram: &otlpmetrics.DoubleHistogram{}} + m.Data = &otlpmetrics.Metric_DoubleHistogram{DoubleHistogram: &otlpmetrics.DoubleHistogram{ + AggregationTemporality: otlpmetrics.AggregationTemporality_AGGREGATION_TEMPORALITY_CUMULATIVE, + }} } return m } diff --git a/internal/data/testdata/metric_test.go b/internal/data/testdata/metric_test.go index 5c7a21f9432..86e1e91a605 100644 --- a/internal/data/testdata/metric_test.go +++ b/internal/data/testdata/metric_test.go @@ -98,8 +98,8 @@ func generateAllMetricsTestCases() []traceMetricsCase { }, { name: "counters-histogram", - td: GenerateMetricsWithCountersHistogram(), - otlp: generateMetricsOtlpWithCountersHistogram(), + td: GenerateMetricsWithCountersHistograms(), + otlp: generateMetricsOtlpWithCountersHistograms(), }, } } diff --git a/internal/dataold/testdataold/metric.go b/internal/dataold/testdataold/metric.go index 62ebd8d791e..4f7aa4f6432 100644 --- a/internal/dataold/testdataold/metric.go +++ b/internal/dataold/testdataold/metric.go @@ -19,6 +19,7 @@ import ( "go.opentelemetry.io/collector/consumer/pdata" otlpmetrics "go.opentelemetry.io/collector/internal/data/opentelemetry-proto-gen/metrics/v1old" + "go.opentelemetry.io/collector/internal/data/testdata" "go.opentelemetry.io/collector/internal/dataold" ) @@ -34,13 +35,8 @@ var ( ) const ( - TestGaugeDoubleMetricName = "gauge-double" - TestGaugeIntMetricName = "gauge-int" - TestCounterDoubleMetricName = "counter-double" - TestCounterIntMetricName = "counter-int" - TestCumulativeHistogramMetricName = "cumulative-histogram" - TestSummaryMetricName = "summary" - NumMetricTests = 14 + TestSummaryMetricName = "summary" + NumMetricTests = 14 ) func GenerateMetricDataEmpty() dataold.MetricData { @@ -257,15 +253,15 @@ func GenerateMetricDataAllTypesNoDataPoints() dataold.MetricData { ms := ilm0.Metrics() ms.Resize(6) initMetricDescriptor( - ms.At(0).MetricDescriptor(), TestGaugeDoubleMetricName, dataold.MetricTypeDouble) + ms.At(0).MetricDescriptor(), testdata.TestGaugeDoubleMetricName, dataold.MetricTypeDouble) initMetricDescriptor( - ms.At(1).MetricDescriptor(), TestGaugeIntMetricName, dataold.MetricTypeInt64) + ms.At(1).MetricDescriptor(), testdata.TestGaugeIntMetricName, dataold.MetricTypeInt64) initMetricDescriptor( - ms.At(2).MetricDescriptor(), TestCounterDoubleMetricName, dataold.MetricTypeMonotonicDouble) + ms.At(2).MetricDescriptor(), testdata.TestCounterDoubleMetricName, dataold.MetricTypeMonotonicDouble) initMetricDescriptor( - ms.At(3).MetricDescriptor(), TestCounterIntMetricName, dataold.MetricTypeMonotonicInt64) + ms.At(3).MetricDescriptor(), testdata.TestCounterIntMetricName, dataold.MetricTypeMonotonicInt64) initMetricDescriptor( - ms.At(4).MetricDescriptor(), TestCumulativeHistogramMetricName, dataold.MetricTypeHistogram) + ms.At(4).MetricDescriptor(), testdata.TestDoubleHistogramMetricName, dataold.MetricTypeHistogram) initMetricDescriptor( ms.At(5).MetricDescriptor(), TestSummaryMetricName, dataold.MetricTypeSummary) return md @@ -283,19 +279,19 @@ func GenerateMetricDataAllTypesNilDataPoint() dataold.MetricData { nilSummary := dataold.NewSummaryDataPoint() initMetricDescriptor( - ms.At(0).MetricDescriptor(), TestGaugeDoubleMetricName, dataold.MetricTypeDouble) + ms.At(0).MetricDescriptor(), testdata.TestGaugeDoubleMetricName, dataold.MetricTypeDouble) ms.At(0).DoubleDataPoints().Append(&nilDouble) initMetricDescriptor( - ms.At(1).MetricDescriptor(), TestGaugeIntMetricName, dataold.MetricTypeInt64) + ms.At(1).MetricDescriptor(), testdata.TestGaugeIntMetricName, dataold.MetricTypeInt64) ms.At(1).Int64DataPoints().Append(&nilInt64) initMetricDescriptor( - ms.At(2).MetricDescriptor(), TestCounterDoubleMetricName, dataold.MetricTypeMonotonicDouble) + ms.At(2).MetricDescriptor(), testdata.TestCounterDoubleMetricName, dataold.MetricTypeMonotonicDouble) ms.At(2).DoubleDataPoints().Append(&nilDouble) initMetricDescriptor( - ms.At(3).MetricDescriptor(), TestCounterIntMetricName, dataold.MetricTypeMonotonicInt64) + ms.At(3).MetricDescriptor(), testdata.TestCounterIntMetricName, dataold.MetricTypeMonotonicInt64) ms.At(3).Int64DataPoints().Append(&nilInt64) initMetricDescriptor( - ms.At(4).MetricDescriptor(), TestCumulativeHistogramMetricName, dataold.MetricTypeHistogram) + ms.At(4).MetricDescriptor(), testdata.TestDoubleHistogramMetricName, dataold.MetricTypeHistogram) ms.At(4).HistogramDataPoints().Append(&nilHistogram) initMetricDescriptor( ms.At(5).MetricDescriptor(), TestSummaryMetricName, dataold.MetricTypeSummary) @@ -319,19 +315,19 @@ func GenerateMetricDataAllTypesEmptyDataPoint() dataold.MetricData { emptySummary.InitEmpty() initMetricDescriptor( - ms.At(0).MetricDescriptor(), TestGaugeDoubleMetricName, dataold.MetricTypeDouble) + ms.At(0).MetricDescriptor(), testdata.TestGaugeDoubleMetricName, dataold.MetricTypeDouble) ms.At(0).DoubleDataPoints().Append(&emptyDouble) initMetricDescriptor( - ms.At(1).MetricDescriptor(), TestGaugeIntMetricName, dataold.MetricTypeInt64) + ms.At(1).MetricDescriptor(), testdata.TestGaugeIntMetricName, dataold.MetricTypeInt64) ms.At(1).Int64DataPoints().Append(&emptyInt64) initMetricDescriptor( - ms.At(2).MetricDescriptor(), TestCounterDoubleMetricName, dataold.MetricTypeMonotonicDouble) + ms.At(2).MetricDescriptor(), testdata.TestCounterDoubleMetricName, dataold.MetricTypeMonotonicDouble) ms.At(2).DoubleDataPoints().Append(&emptyDouble) initMetricDescriptor( - ms.At(3).MetricDescriptor(), TestCounterIntMetricName, dataold.MetricTypeMonotonicInt64) + ms.At(3).MetricDescriptor(), testdata.TestCounterIntMetricName, dataold.MetricTypeMonotonicInt64) ms.At(3).Int64DataPoints().Append(&emptyInt64) initMetricDescriptor( - ms.At(4).MetricDescriptor(), TestCumulativeHistogramMetricName, dataold.MetricTypeHistogram) + ms.At(4).MetricDescriptor(), testdata.TestDoubleHistogramMetricName, dataold.MetricTypeHistogram) ms.At(4).HistogramDataPoints().Append(&emptyHistogram) initMetricDescriptor( ms.At(5).MetricDescriptor(), TestSummaryMetricName, dataold.MetricTypeSummary) @@ -354,7 +350,7 @@ func GenerateMetricDataMetricTypeInvalid() dataold.MetricData { ms.Resize(1) initMetricDescriptor( - ms.At(0).MetricDescriptor(), TestGaugeDoubleMetricName, dataold.MetricTypeInvalid) + ms.At(0).MetricDescriptor(), testdata.TestGaugeDoubleMetricName, dataold.MetricTypeInvalid) return md } @@ -366,19 +362,19 @@ func generateMetricOtlpAllTypesNoDataPoints() []*otlpmetrics.ResourceMetrics { { Metrics: []*otlpmetrics.Metric{ { - MetricDescriptor: generateOtlpMetricDescriptor(TestGaugeDoubleMetricName, dataold.MetricTypeDouble), + MetricDescriptor: generateOtlpMetricDescriptor(testdata.TestGaugeDoubleMetricName, dataold.MetricTypeDouble), }, { - MetricDescriptor: generateOtlpMetricDescriptor(TestGaugeIntMetricName, dataold.MetricTypeInt64), + MetricDescriptor: generateOtlpMetricDescriptor(testdata.TestGaugeIntMetricName, dataold.MetricTypeInt64), }, { - MetricDescriptor: generateOtlpMetricDescriptor(TestCounterDoubleMetricName, dataold.MetricTypeMonotonicDouble), + MetricDescriptor: generateOtlpMetricDescriptor(testdata.TestCounterDoubleMetricName, dataold.MetricTypeMonotonicDouble), }, { - MetricDescriptor: generateOtlpMetricDescriptor(TestCounterIntMetricName, dataold.MetricTypeMonotonicInt64), + MetricDescriptor: generateOtlpMetricDescriptor(testdata.TestCounterIntMetricName, dataold.MetricTypeMonotonicInt64), }, { - MetricDescriptor: generateOtlpMetricDescriptor(TestCumulativeHistogramMetricName, dataold.MetricTypeHistogram), + MetricDescriptor: generateOtlpMetricDescriptor(testdata.TestDoubleHistogramMetricName, dataold.MetricTypeHistogram), }, { MetricDescriptor: generateOtlpMetricDescriptor(TestSummaryMetricName, dataold.MetricTypeSummary), @@ -429,7 +425,7 @@ func generateMetricOtlpWithCountersHistogramAndSummary() []*otlpmetrics.Resource } func initCounterIntMetric(im dataold.Metric) { - initMetricDescriptor(im.MetricDescriptor(), TestCounterIntMetricName, dataold.MetricTypeMonotonicInt64) + initMetricDescriptor(im.MetricDescriptor(), testdata.TestCounterIntMetricName, dataold.MetricTypeMonotonicInt64) idps := im.Int64DataPoints() idps.Resize(2) @@ -446,7 +442,7 @@ func initCounterIntMetric(im dataold.Metric) { } func initGaugeIntMetricOneDataPoint(im dataold.Metric) { - initMetricDescriptor(im.MetricDescriptor(), TestCounterIntMetricName, dataold.MetricTypeInt64) + initMetricDescriptor(im.MetricDescriptor(), testdata.TestCounterIntMetricName, dataold.MetricTypeInt64) idps := im.Int64DataPoints() idps.Resize(1) idp0 := idps.At(0) @@ -458,7 +454,7 @@ func initGaugeIntMetricOneDataPoint(im dataold.Metric) { func generateOtlpCounterIntMetric() *otlpmetrics.Metric { return &otlpmetrics.Metric{ - MetricDescriptor: generateOtlpMetricDescriptor(TestCounterIntMetricName, dataold.MetricTypeMonotonicInt64), + MetricDescriptor: generateOtlpMetricDescriptor(testdata.TestCounterIntMetricName, dataold.MetricTypeMonotonicInt64), Int64DataPoints: []*otlpmetrics.Int64DataPoint{ { Labels: generateOtlpMetricLabels1(), @@ -477,7 +473,7 @@ func generateOtlpCounterIntMetric() *otlpmetrics.Metric { } func initCounterDoubleMetric(dm dataold.Metric) { - initMetricDescriptor(dm.MetricDescriptor(), TestCounterDoubleMetricName, dataold.MetricTypeMonotonicDouble) + initMetricDescriptor(dm.MetricDescriptor(), testdata.TestCounterDoubleMetricName, dataold.MetricTypeMonotonicDouble) ddps := dm.DoubleDataPoints() ddps.Resize(2) @@ -497,7 +493,7 @@ func initCounterDoubleMetric(dm dataold.Metric) { func generateOtlpCounterDoubleMetric() *otlpmetrics.Metric { return &otlpmetrics.Metric{ - MetricDescriptor: generateOtlpMetricDescriptor(TestCounterDoubleMetricName, dataold.MetricTypeMonotonicDouble), + MetricDescriptor: generateOtlpMetricDescriptor(testdata.TestCounterDoubleMetricName, dataold.MetricTypeMonotonicDouble), DoubleDataPoints: []*otlpmetrics.DoubleDataPoint{ { Labels: generateOtlpMetricLabels12(), @@ -516,7 +512,7 @@ func generateOtlpCounterDoubleMetric() *otlpmetrics.Metric { } func initCumulativeHistogramMetric(hm dataold.Metric) { - initMetricDescriptor(hm.MetricDescriptor(), TestCumulativeHistogramMetricName, dataold.MetricTypeHistogram) + initMetricDescriptor(hm.MetricDescriptor(), testdata.TestDoubleHistogramMetricName, dataold.MetricTypeHistogram) hdps := hm.HistogramDataPoints() hdps.Resize(2) @@ -545,7 +541,7 @@ func initCumulativeHistogramMetric(hm dataold.Metric) { func generateOtlpCumulativeHistogramMetric() *otlpmetrics.Metric { return &otlpmetrics.Metric{ - MetricDescriptor: generateOtlpMetricDescriptor(TestCumulativeHistogramMetricName, dataold.MetricTypeHistogram), + MetricDescriptor: generateOtlpMetricDescriptor(testdata.TestDoubleHistogramMetricName, dataold.MetricTypeHistogram), HistogramDataPoints: []*otlpmetrics.HistogramDataPoint{ { Labels: generateOtlpMetricLabels13(), diff --git a/translator/internaldata/oc_testdata_test.go b/translator/internaldata/oc_testdata_test.go index fe85c044880..ba9a414cdf8 100644 --- a/translator/internaldata/oc_testdata_test.go +++ b/translator/internaldata/oc_testdata_test.go @@ -39,7 +39,7 @@ func generateOCTestDataNoMetrics() consumerdata.MetricsData { } } -func generateOCTestDataNoPoints() consumerdata.MetricsData { +func generateOCTestDataNoPointsOld() consumerdata.MetricsData { return consumerdata.MetricsData{ Node: &occommon.Node{}, Resource: &ocresource.Resource{ @@ -48,7 +48,7 @@ func generateOCTestDataNoPoints() consumerdata.MetricsData { Metrics: []*ocmetrics.Metric{ { MetricDescriptor: &ocmetrics.MetricDescriptor{ - Name: "gauge-double", + Name: testdata.TestGaugeDoubleMetricName, Description: "", Unit: "1", Type: ocmetrics.MetricDescriptor_GAUGE_DOUBLE, @@ -56,7 +56,7 @@ func generateOCTestDataNoPoints() consumerdata.MetricsData { }, { MetricDescriptor: &ocmetrics.MetricDescriptor{ - Name: "gauge-int", + Name: testdata.TestGaugeIntMetricName, Description: "", Unit: "1", Type: ocmetrics.MetricDescriptor_GAUGE_INT64, @@ -64,7 +64,7 @@ func generateOCTestDataNoPoints() consumerdata.MetricsData { }, { MetricDescriptor: &ocmetrics.MetricDescriptor{ - Name: "counter-double", + Name: testdata.TestCounterDoubleMetricName, Description: "", Unit: "1", Type: ocmetrics.MetricDescriptor_CUMULATIVE_DOUBLE, @@ -72,7 +72,7 @@ func generateOCTestDataNoPoints() consumerdata.MetricsData { }, { MetricDescriptor: &ocmetrics.MetricDescriptor{ - Name: "counter-int", + Name: testdata.TestCounterIntMetricName, Description: "", Unit: "1", Type: ocmetrics.MetricDescriptor_CUMULATIVE_INT64, @@ -80,7 +80,7 @@ func generateOCTestDataNoPoints() consumerdata.MetricsData { }, { MetricDescriptor: &ocmetrics.MetricDescriptor{ - Name: "cumulative-histogram", + Name: testdata.TestDoubleHistogramMetricName, Description: "", Unit: "1", Type: ocmetrics.MetricDescriptor_CUMULATIVE_DISTRIBUTION, @@ -159,7 +159,7 @@ func generateOCTestDataMetricsOneMetricOneNilPoint() consumerdata.MetricsData { func generateOCTestMetricInt() *ocmetrics.Metric { return &ocmetrics.Metric{ MetricDescriptor: &ocmetrics.MetricDescriptor{ - Name: testdataold.TestCounterIntMetricName, + Name: testdata.TestCounterIntMetricName, Description: "", Unit: "1", Type: ocmetrics.MetricDescriptor_CUMULATIVE_INT64, @@ -170,7 +170,7 @@ func generateOCTestMetricInt() *ocmetrics.Metric { }, Timeseries: []*ocmetrics.TimeSeries{ { - StartTimestamp: timestamppb.New(testdataold.TestMetricStartTime), + StartTimestamp: timestamppb.New(testdata.TestMetricStartTime), LabelValues: []*ocmetrics.LabelValue{ { // key1 @@ -184,7 +184,7 @@ func generateOCTestMetricInt() *ocmetrics.Metric { }, Points: []*ocmetrics.Point{ { - Timestamp: timestamppb.New(testdataold.TestMetricTime), + Timestamp: timestamppb.New(testdata.TestMetricTime), Value: &ocmetrics.Point_Int64Value{ Int64Value: 123, }, @@ -192,7 +192,7 @@ func generateOCTestMetricInt() *ocmetrics.Metric { }, }, { - StartTimestamp: timestamppb.New(testdataold.TestMetricStartTime), + StartTimestamp: timestamppb.New(testdata.TestMetricStartTime), LabelValues: []*ocmetrics.LabelValue{ { // key1 @@ -206,7 +206,7 @@ func generateOCTestMetricInt() *ocmetrics.Metric { }, Points: []*ocmetrics.Point{ { - Timestamp: timestamppb.New(testdataold.TestMetricTime), + Timestamp: timestamppb.New(testdata.TestMetricTime), Value: &ocmetrics.Point_Int64Value{ Int64Value: 456, }, @@ -231,7 +231,7 @@ func generateOCTestMetricDouble() *ocmetrics.Metric { }, Timeseries: []*ocmetrics.TimeSeries{ { - StartTimestamp: timestamppb.New(testdataold.TestMetricStartTime), + StartTimestamp: timestamppb.New(testdata.TestMetricStartTime), LabelValues: []*ocmetrics.LabelValue{ { // key1 @@ -250,7 +250,7 @@ func generateOCTestMetricDouble() *ocmetrics.Metric { }, Points: []*ocmetrics.Point{ { - Timestamp: timestamppb.New(testdataold.TestMetricTime), + Timestamp: timestamppb.New(testdata.TestMetricTime), Value: &ocmetrics.Point_DoubleValue{ DoubleValue: 1.23, }, @@ -258,7 +258,7 @@ func generateOCTestMetricDouble() *ocmetrics.Metric { }, }, { - StartTimestamp: timestamppb.New(testdataold.TestMetricStartTime), + StartTimestamp: timestamppb.New(testdata.TestMetricStartTime), LabelValues: []*ocmetrics.LabelValue{ { // key1 @@ -277,7 +277,7 @@ func generateOCTestMetricDouble() *ocmetrics.Metric { }, Points: []*ocmetrics.Point{ { - Timestamp: timestamppb.New(testdataold.TestMetricTime), + Timestamp: timestamppb.New(testdata.TestMetricTime), Value: &ocmetrics.Point_DoubleValue{ DoubleValue: 4.56, }, @@ -288,10 +288,10 @@ func generateOCTestMetricDouble() *ocmetrics.Metric { } } -func generateOCTestMetricHistogram() *ocmetrics.Metric { +func generateOCTestMetricDoubleHistogram() *ocmetrics.Metric { return &ocmetrics.Metric{ MetricDescriptor: &ocmetrics.MetricDescriptor{ - Name: testdataold.TestCumulativeHistogramMetricName, + Name: testdata.TestDoubleHistogramMetricName, Description: "", Unit: "1", Type: ocmetrics.MetricDescriptor_CUMULATIVE_DISTRIBUTION, @@ -303,7 +303,7 @@ func generateOCTestMetricHistogram() *ocmetrics.Metric { }, Timeseries: []*ocmetrics.TimeSeries{ { - StartTimestamp: timestamppb.New(testdataold.TestMetricStartTime), + StartTimestamp: timestamppb.New(testdata.TestMetricStartTime), LabelValues: []*ocmetrics.LabelValue{ { // key1 @@ -322,7 +322,7 @@ func generateOCTestMetricHistogram() *ocmetrics.Metric { }, Points: []*ocmetrics.Point{ { - Timestamp: timestamppb.New(testdataold.TestMetricTime), + Timestamp: timestamppb.New(testdata.TestMetricTime), Value: &ocmetrics.Point_DistributionValue{ DistributionValue: &ocmetrics.DistributionValue{ Count: 1, @@ -333,7 +333,7 @@ func generateOCTestMetricHistogram() *ocmetrics.Metric { }, }, { - StartTimestamp: timestamppb.New(testdataold.TestMetricStartTime), + StartTimestamp: timestamppb.New(testdata.TestMetricStartTime), LabelValues: []*ocmetrics.LabelValue{ { // key1 @@ -351,7 +351,7 @@ func generateOCTestMetricHistogram() *ocmetrics.Metric { }, Points: []*ocmetrics.Point{ { - Timestamp: timestamppb.New(testdataold.TestMetricTime), + Timestamp: timestamppb.New(testdata.TestMetricTime), Value: &ocmetrics.Point_DistributionValue{ DistributionValue: &ocmetrics.DistributionValue{ Count: 1, @@ -370,7 +370,7 @@ func generateOCTestMetricHistogram() *ocmetrics.Metric { { Count: 1, Exemplar: &ocmetrics.DistributionValue_Exemplar{ - Timestamp: timestamppb.New(testdataold.TestMetricExemplarTime), + Timestamp: timestamppb.New(testdata.TestMetricExemplarTime), Value: 15, Attachments: map[string]string{testdata.TestAttachmentKey: testdata.TestAttachmentValue}, }, @@ -398,7 +398,7 @@ func generateOCTestMetricSummary() *ocmetrics.Metric { }, Timeseries: []*ocmetrics.TimeSeries{ { - StartTimestamp: timestamppb.New(testdataold.TestMetricStartTime), + StartTimestamp: timestamppb.New(testdata.TestMetricStartTime), LabelValues: []*ocmetrics.LabelValue{ { // key1 @@ -408,7 +408,7 @@ func generateOCTestMetricSummary() *ocmetrics.Metric { }, Points: []*ocmetrics.Point{ { - Timestamp: timestamppb.New(testdataold.TestMetricTime), + Timestamp: timestamppb.New(testdata.TestMetricTime), Value: &ocmetrics.Point_SummaryValue{ SummaryValue: &ocmetrics.SummaryValue{ Count: &wrapperspb.Int64Value{ @@ -423,7 +423,7 @@ func generateOCTestMetricSummary() *ocmetrics.Metric { }, }, { - StartTimestamp: timestamppb.New(testdataold.TestMetricStartTime), + StartTimestamp: timestamppb.New(testdata.TestMetricStartTime), LabelValues: []*ocmetrics.LabelValue{ { // key1 @@ -433,7 +433,7 @@ func generateOCTestMetricSummary() *ocmetrics.Metric { }, Points: []*ocmetrics.Point{ { - Timestamp: timestamppb.New(testdataold.TestMetricTime), + Timestamp: timestamppb.New(testdata.TestMetricTime), Value: &ocmetrics.Point_SummaryValue{ SummaryValue: &ocmetrics.SummaryValue{ Count: &wrapperspb.Int64Value{ diff --git a/translator/internaldata/oc_to_old_metrics_test.go b/translator/internaldata/oc_to_old_metrics_test.go index 1852962ce27..7af5c05a2b5 100644 --- a/translator/internaldata/oc_to_old_metrics_test.go +++ b/translator/internaldata/oc_to_old_metrics_test.go @@ -56,7 +56,7 @@ func TestOCToMetricData(t *testing.T) { { name: "all-types-no-points", - oc: generateOCTestDataNoPoints(), + oc: generateOCTestDataNoPointsOld(), internal: testdataold.GenerateMetricDataAllTypesNoDataPoints(), }, @@ -97,7 +97,7 @@ func TestOCToMetricData(t *testing.T) { Metrics: []*ocmetrics.Metric{ generateOCTestMetricInt(), generateOCTestMetricDouble(), - generateOCTestMetricHistogram(), + generateOCTestMetricDoubleHistogram(), generateOCTestMetricSummary(), }, }, @@ -168,9 +168,9 @@ func BenchmarkMetricHistogramOCToInternal(b *testing.B) { ocMetric := consumerdata.MetricsData{ Resource: generateOCTestResource(), Metrics: []*ocmetrics.Metric{ - generateOCTestMetricHistogram(), - generateOCTestMetricHistogram(), - generateOCTestMetricHistogram(), + generateOCTestMetricDoubleHistogram(), + generateOCTestMetricDoubleHistogram(), + generateOCTestMetricDoubleHistogram(), }, } diff --git a/translator/internaldata/old_metrics_to_oc_test.go b/translator/internaldata/old_metrics_to_oc_test.go index fc93368da8b..b6b4efd810a 100644 --- a/translator/internaldata/old_metrics_to_oc_test.go +++ b/translator/internaldata/old_metrics_to_oc_test.go @@ -141,7 +141,7 @@ func TestMetricsDataToOC(t *testing.T) { name: "all-types-no-data-points", internal: testdataold.GenerateMetricDataAllTypesNoDataPoints(), oc: []consumerdata.MetricsData{ - generateOCTestDataNoPoints(), + generateOCTestDataNoPointsOld(), }, }, @@ -186,7 +186,7 @@ func generateOCTestData() consumerdata.MetricsData { Metrics: []*ocmetrics.Metric{ generateOCTestMetricInt(), generateOCTestMetricDouble(), - generateOCTestMetricHistogram(), + generateOCTestMetricDoubleHistogram(), generateOCTestMetricSummary(), }, }