diff --git a/.chloggen/prometheus-remove-starttimeadjustment.yaml b/.chloggen/prometheus-remove-starttimeadjustment.yaml new file mode 100644 index 0000000000000..5c416fa98d625 --- /dev/null +++ b/.chloggen/prometheus-remove-starttimeadjustment.yaml @@ -0,0 +1,30 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: breaking + +# The name of the component, or a single word describing the area of concern, (e.g. receiver/filelog) +component: receiver/prometheus + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: The prometheus receiver no longer adjusts the start time of metrics by default. + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [43656] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: Disable the receiver.prometheusreceiver.RemoveStartTimeAdjustment | + feature gate to temporarily re-enable this functionality. Users that need | + this functionality should migrate to the metricstarttime processor, | + and use the true_reset strategy for equivalent behavior. + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [] diff --git a/receiver/prometheusreceiver/internal/metricfamily_test.go b/receiver/prometheusreceiver/internal/metricfamily_test.go index 243ea0180c4ab..61a4b1900f9f3 100644 --- a/receiver/prometheusreceiver/internal/metricfamily_test.go +++ b/receiver/prometheusreceiver/internal/metricfamily_test.go @@ -120,7 +120,7 @@ func TestMetricGroupData_toDistributionUnitTest(t *testing.T) { intervalStartTimeMs int64 }{ { - name: "histogram with startTimestamp", + name: "histogram with no startTimestamp", metricName: "histogram", intervalStartTimeMs: 11, labels: labels.FromMap(map[string]string{"a": "A", "b": "B"}), @@ -138,7 +138,6 @@ func TestMetricGroupData_toDistributionUnitTest(t *testing.T) { point.SetTimestamp(pcommon.Timestamp(11 * time.Millisecond)) // the time in milliseconds -> nanoseconds. point.ExplicitBounds().FromRaw([]float64{0.75, 2.75}) point.BucketCounts().FromRaw([]uint64{33, 22, 11}) - point.SetStartTimestamp(pcommon.Timestamp(11 * time.Millisecond)) // the time in milliseconds -> nanoseconds. attributes := point.Attributes() attributes.PutStr("a", "A") attributes.PutStr("b", "B") @@ -207,7 +206,6 @@ func TestMetricGroupData_toDistributionUnitTest(t *testing.T) { point.SetFlags(pmetric.DefaultDataPointFlags.WithNoRecordedValue(true)) point.ExplicitBounds().FromRaw([]float64{0.75, 2.75}) point.BucketCounts().FromRaw([]uint64{0, 0, 0}) - point.SetStartTimestamp(pcommon.Timestamp(11 * time.Millisecond)) // the time in milliseconds -> nanoseconds. attributes := point.Attributes() attributes.PutStr("a", "A") attributes.PutStr("b", "B") @@ -239,8 +237,7 @@ func TestMetricGroupData_toDistributionUnitTest(t *testing.T) { point := pmetric.NewHistogramDataPoint() point.SetCount(66) point.SetSum(1004.78) - point.SetTimestamp(pcommon.Timestamp(11 * time.Millisecond)) // the time in milliseconds -> nanoseconds. - point.SetStartTimestamp(pcommon.Timestamp(11 * time.Millisecond)) // the time in milliseconds -> nanoseconds. + point.SetTimestamp(pcommon.Timestamp(11 * time.Millisecond)) // the time in milliseconds -> nanoseconds. point.BucketCounts().FromRaw([]uint64{66}) attributes := point.Attributes() attributes.PutStr("a", "A") @@ -323,7 +320,6 @@ func TestMetricGroupData_toNHCBDistributionUnitTest(t *testing.T) { point.SetCount(180) point.SetSum(100.5) point.SetTimestamp(pcommon.Timestamp(11 * time.Millisecond)) - point.SetStartTimestamp(pcommon.Timestamp(11 * time.Millisecond)) point.ExplicitBounds().FromRaw([]float64{1.0, 2.0, 5.0, 10.0}) point.BucketCounts().FromRaw([]uint64{10, 25, 45, 50, 50}) attributes := point.Attributes() @@ -347,7 +343,6 @@ func TestMetricGroupData_toNHCBDistributionUnitTest(t *testing.T) { point := pmetric.NewHistogramDataPoint() point.SetTimestamp(pcommon.Timestamp(11 * time.Millisecond)) point.SetFlags(pmetric.DefaultDataPointFlags.WithNoRecordedValue(true)) - point.SetStartTimestamp(pcommon.Timestamp(11 * time.Millisecond)) point.ExplicitBounds().FromRaw([]float64{1.0, 2.0, 5.0, 10.0}) point.BucketCounts().FromRaw([]uint64{0, 0, 0, 0, 0}) attributes := point.Attributes() @@ -374,7 +369,6 @@ func TestMetricGroupData_toNHCBDistributionUnitTest(t *testing.T) { point.SetCount(50) point.SetSum(125.25) point.SetTimestamp(pcommon.Timestamp(12 * time.Millisecond)) - point.SetStartTimestamp(pcommon.Timestamp(12 * time.Millisecond)) point.ExplicitBounds().FromRaw([]float64{0.5, 2.0}) point.BucketCounts().FromRaw([]uint64{15, 20, 15}) attributes := point.Attributes() @@ -400,7 +394,6 @@ func TestMetricGroupData_toNHCBDistributionUnitTest(t *testing.T) { point.SetCount(16) point.SetSum(10.0) point.SetTimestamp(pcommon.Timestamp(30 * time.Millisecond)) - point.SetStartTimestamp(pcommon.Timestamp(30 * time.Millisecond)) point.ExplicitBounds().FromRaw([]float64{-5.0, 0.0, 5.0}) point.BucketCounts().FromRaw([]uint64{5, 10, 15, 16}) point.Attributes().PutStr("a", "A") @@ -455,7 +448,7 @@ func TestMetricGroupData_toExponentialDistributionUnitTest(t *testing.T) { intervalStartTimeMs int64 }{ { - name: "integer histogram with startTimestamp", + name: "integer histogram without startTimestamp", metricName: "request_duration_seconds", intervalStartTimeMs: 11, labels: labels.FromMap(map[string]string{"a": "A", "b": "B"}), @@ -481,8 +474,7 @@ func TestMetricGroupData_toExponentialDistributionUnitTest(t *testing.T) { point := pmetric.NewExponentialHistogramDataPoint() point.SetCount(66) point.SetSum(1004.78) - point.SetTimestamp(pcommon.Timestamp(11 * time.Millisecond)) // the time in milliseconds -> nanoseconds. - point.SetStartTimestamp(pcommon.Timestamp(11 * time.Millisecond)) // the time in milliseconds -> nanoseconds. + point.SetTimestamp(pcommon.Timestamp(11 * time.Millisecond)) // the time in milliseconds -> nanoseconds. point.SetScale(1) point.SetZeroThreshold(0.42) point.SetZeroCount(1) @@ -560,7 +552,6 @@ func TestMetricGroupData_toExponentialDistributionUnitTest(t *testing.T) { point := pmetric.NewExponentialHistogramDataPoint() point.SetTimestamp(pcommon.Timestamp(11 * time.Millisecond)) // the time in milliseconds -> nanoseconds. point.SetFlags(pmetric.DefaultDataPointFlags.WithNoRecordedValue(true)) - point.SetStartTimestamp(pcommon.Timestamp(11 * time.Millisecond)) // the time in milliseconds -> nanoseconds. attributes := point.Attributes() attributes.PutStr("a", "A") attributes.PutStr("b", "B") @@ -704,8 +695,7 @@ func TestMetricGroupData_toSummaryUnitTest(t *testing.T) { qn99 := qtL.AppendEmpty() qn99.SetQuantile(.99) qn99.SetValue(82) - point.SetTimestamp(pcommon.Timestamp(14 * time.Millisecond)) // the time in milliseconds -> nanoseconds. - point.SetStartTimestamp(pcommon.Timestamp(14 * time.Millisecond)) // the time in milliseconds -> nanoseconds + point.SetTimestamp(pcommon.Timestamp(14 * time.Millisecond)) // the time in milliseconds -> nanoseconds. attributes := point.Attributes() attributes.PutStr("a", "A") attributes.PutStr("b", "B") @@ -848,8 +838,7 @@ func TestMetricGroupData_toSummaryUnitTest(t *testing.T) { qn99 := qtL.AppendEmpty() qn99.SetQuantile(.99) qn99.SetValue(0) - point.SetTimestamp(pcommon.Timestamp(14 * time.Millisecond)) // the time in milliseconds -> nanoseconds. - point.SetStartTimestamp(pcommon.Timestamp(14 * time.Millisecond)) // the time in milliseconds -> nanoseconds + point.SetTimestamp(pcommon.Timestamp(14 * time.Millisecond)) // the time in milliseconds -> nanoseconds. attributes := point.Attributes() attributes.PutStr("a", "A") attributes.PutStr("b", "B") @@ -942,7 +931,6 @@ func TestMetricGroupData_toNumberDataUnitTest(t *testing.T) { // the time in milliseconds -> nanoseconds. point.SetTimestamp(pcommon.Timestamp(13 * time.Millisecond)) - point.SetStartTimestamp(pcommon.Timestamp(13 * time.Millisecond)) attributes := point.Attributes() attributes.PutStr("a", "A") @@ -984,8 +972,7 @@ func TestMetricGroupData_toNumberDataUnitTest(t *testing.T) { want: func() pmetric.NumberDataPoint { point := pmetric.NewNumberDataPoint() point.SetDoubleValue(33.7) - point.SetTimestamp(pcommon.Timestamp(13 * time.Millisecond)) // the time in milliseconds -> nanoseconds. - point.SetStartTimestamp(pcommon.Timestamp(13 * time.Millisecond)) // the time in milliseconds -> nanoseconds. + point.SetTimestamp(pcommon.Timestamp(13 * time.Millisecond)) // the time in milliseconds -> nanoseconds. attributes := point.Attributes() attributes.PutStr("a", "A") attributes.PutStr("b", "B") @@ -1003,8 +990,7 @@ func TestMetricGroupData_toNumberDataUnitTest(t *testing.T) { want: func() pmetric.NumberDataPoint { point := pmetric.NewNumberDataPoint() point.SetDoubleValue(99.9) - point.SetTimestamp(pcommon.Timestamp(28 * time.Millisecond)) // the time in milliseconds -> nanoseconds. - point.SetStartTimestamp(pcommon.Timestamp(28 * time.Millisecond)) // the time in milliseconds -> nanoseconds. + point.SetTimestamp(pcommon.Timestamp(28 * time.Millisecond)) // the time in milliseconds -> nanoseconds. attributes := point.Attributes() attributes.PutStr("a", "A") attributes.PutStr("b", "B") diff --git a/receiver/prometheusreceiver/internal/metrics_adjuster_test.go b/receiver/prometheusreceiver/internal/metrics_adjuster_test.go index 455926f2c1484..343ac9dd7ec29 100644 --- a/receiver/prometheusreceiver/internal/metrics_adjuster_test.go +++ b/receiver/prometheusreceiver/internal/metrics_adjuster_test.go @@ -12,6 +12,8 @@ import ( "go.opentelemetry.io/collector/pdata/pmetric" semconv "go.opentelemetry.io/otel/semconv/v1.27.0" "go.uber.org/zap" + + "github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/testutil" ) var ( @@ -740,6 +742,7 @@ type metricsAdjusterTest struct { func runScript(t *testing.T, ma MetricsAdjuster, job, instance string, tests []*metricsAdjusterTest) { for _, test := range tests { t.Run(test.description, func(t *testing.T) { + defer testutil.SetFeatureGateForTest(t, removeStartTimeAdjustment, false)() adjusted := pmetric.NewMetrics() test.metrics.CopyTo(adjusted) // Add the instance/job to the input metrics if they aren't already present. diff --git a/receiver/prometheusreceiver/internal/starttimemetricadjuster_test.go b/receiver/prometheusreceiver/internal/starttimemetricadjuster_test.go index fa90c6083a320..859c0db42fe80 100644 --- a/receiver/prometheusreceiver/internal/starttimemetricadjuster_test.go +++ b/receiver/prometheusreceiver/internal/starttimemetricadjuster_test.go @@ -167,6 +167,7 @@ func TestStartTimeMetricMatch(t *testing.T) { } func TestStartTimeMetricFallback(t *testing.T) { + defer testutil.SetFeatureGateForTest(t, removeStartTimeAdjustment, false)() const startTime = pcommon.Timestamp(123 * 1e9) const currentTime = pcommon.Timestamp(126 * 1e9) mockStartTime := time.Now().Add(-10 * time.Hour) diff --git a/receiver/prometheusreceiver/internal/transaction.go b/receiver/prometheusreceiver/internal/transaction.go index c861fecf2408b..dc50cf2261dc1 100644 --- a/receiver/prometheusreceiver/internal/transaction.go +++ b/receiver/prometheusreceiver/internal/transaction.go @@ -32,7 +32,7 @@ import ( var removeStartTimeAdjustment = featuregate.GlobalRegistry().MustRegister( "receiver.prometheusreceiver.RemoveStartTimeAdjustment", - featuregate.StageAlpha, + featuregate.StageBeta, featuregate.WithRegisterDescription("When enabled, the Prometheus receiver will"+ " leave the start time unset. Use the new metricstarttime processor instead."), ) diff --git a/receiver/prometheusreceiver/internal/transaction_test.go b/receiver/prometheusreceiver/internal/transaction_test.go index e5d022a5684b8..6ba12ed8c7cb9 100644 --- a/receiver/prometheusreceiver/internal/transaction_test.go +++ b/receiver/prometheusreceiver/internal/transaction_test.go @@ -266,6 +266,7 @@ func testReceiverVersionAndNameAreAttached(t *testing.T, enableNativeHistograms func TestTransactionCommitErrorWhenAdjusterError(t *testing.T) { for _, enableNativeHistograms := range []bool{true, false} { t.Run(fmt.Sprintf("enableNativeHistograms=%v", enableNativeHistograms), func(t *testing.T) { + defer testutil.SetFeatureGateForTest(t, removeStartTimeAdjustment, false)() testTransactionCommitErrorWhenAdjusterError(t, enableNativeHistograms) }) } @@ -1329,668 +1330,602 @@ func TestMetricBuilderUntyped(t *testing.T) { } func TestMetricBuilderHistogram(t *testing.T) { - tests := []buildTestData{ - { - name: "single item", - inputs: []*testScrapedPage{ - { - pts: []*testDataPoint{ - createDataPoint("hist_test_bucket", 1, nil, "foo", "bar", "le", "10"), - createDataPoint("hist_test_bucket", 2, nil, "foo", "bar", "le", "20"), - createDataPoint("hist_test_bucket", 10, nil, "foo", "bar", "le", "+inf"), - createDataPoint("hist_test_sum", 99, nil, "foo", "bar"), - createDataPoint("hist_test_count", 10, nil, "foo", "bar"), + for _, disableMetricAdjustment := range []bool{true, false} { + tests := []buildTestData{ + { + name: "single item", + inputs: []*testScrapedPage{ + { + pts: []*testDataPoint{ + createDataPoint("hist_test_bucket", 1, nil, "foo", "bar", "le", "10"), + createDataPoint("hist_test_bucket", 2, nil, "foo", "bar", "le", "20"), + createDataPoint("hist_test_bucket", 10, nil, "foo", "bar", "le", "+inf"), + createDataPoint("hist_test_sum", 99, nil, "foo", "bar"), + createDataPoint("hist_test_count", 10, nil, "foo", "bar"), + }, }, }, - }, - wants: func() []pmetric.Metrics { - md0 := pmetric.NewMetrics() - mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() - m0 := mL0.AppendEmpty() - m0.SetName("hist_test") - m0.Metadata().PutStr("prometheus.type", "histogram") - hist0 := m0.SetEmptyHistogram() - hist0.SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) - pt0 := hist0.DataPoints().AppendEmpty() - pt0.SetCount(10) - pt0.SetSum(99) - pt0.ExplicitBounds().FromRaw([]float64{10, 20}) - pt0.BucketCounts().FromRaw([]uint64{1, 1, 8}) - pt0.SetTimestamp(tsNanos) - pt0.SetStartTimestamp(startTimestamp) - pt0.Attributes().PutStr("foo", "bar") + wants: func() []pmetric.Metrics { + md0 := pmetric.NewMetrics() + mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() + m0 := mL0.AppendEmpty() + m0.SetName("hist_test") + m0.Metadata().PutStr("prometheus.type", "histogram") + hist0 := m0.SetEmptyHistogram() + hist0.SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + pt0 := hist0.DataPoints().AppendEmpty() + pt0.SetCount(10) + pt0.SetSum(99) + pt0.ExplicitBounds().FromRaw([]float64{10, 20}) + pt0.BucketCounts().FromRaw([]uint64{1, 1, 8}) + pt0.SetTimestamp(tsNanos) + if !disableMetricAdjustment { + pt0.SetStartTimestamp(startTimestamp) + } + pt0.Attributes().PutStr("foo", "bar") - return []pmetric.Metrics{md0} + return []pmetric.Metrics{md0} + }, }, - }, - { - name: "single item with exemplars", - inputs: []*testScrapedPage{ - { - pts: []*testDataPoint{ - createDataPoint( - "hist_test_bucket", - 1, - []exemplar.Exemplar{ - { - Value: 1, - Ts: 1663113420863, - Labels: labels.New([]labels.Label{{Name: model.MetricNameLabel, Value: "counter_test"}, {Name: model.JobLabel, Value: "job"}, {Name: model.InstanceLabel, Value: "instance"}, {Name: "foo", Value: "bar"}}...), - }, - { - Value: 1, - Ts: 1663113420863, - Labels: labels.New([]labels.Label{{Name: "foo", Value: "bar"}, {Name: "trace_id", Value: ""}, {Name: "span_id", Value: ""}, {Name: "le", Value: "20"}}...), - }, - { - Value: 1, - Ts: 1663113420863, - Labels: labels.New([]labels.Label{{Name: "foo", Value: "bar"}, {Name: "trace_id", Value: "10a47365b8aa04e08291fab9deca84db6170"}, {Name: "traceid", Value: "e3688e1aa2961786"}, {Name: "span_id", Value: "719cee4a669fd7d109ff"}}...), - }, - { - Value: 1, - Ts: 1663113420863, - Labels: labels.New([]labels.Label{{Name: "foo", Value: "bar"}, {Name: "trace_id", Value: "174137cab66dc880"}, {Name: "span_id", Value: "dfa4597a9d"}}...), - }, - { - Value: 1, - Ts: 1663113420863, - Labels: labels.New([]labels.Label{{Name: "foo", Value: "bar"}, {Name: "trace_id", Value: "174137cab66dc88"}, {Name: "span_id", Value: "dfa4597a9"}}...), + { + name: "single item with exemplars", + inputs: []*testScrapedPage{ + { + pts: []*testDataPoint{ + createDataPoint( + "hist_test_bucket", + 1, + []exemplar.Exemplar{ + { + Value: 1, + Ts: 1663113420863, + Labels: labels.New([]labels.Label{{Name: model.MetricNameLabel, Value: "counter_test"}, {Name: model.JobLabel, Value: "job"}, {Name: model.InstanceLabel, Value: "instance"}, {Name: "foo", Value: "bar"}}...), + }, + { + Value: 1, + Ts: 1663113420863, + Labels: labels.New([]labels.Label{{Name: "foo", Value: "bar"}, {Name: "trace_id", Value: ""}, {Name: "span_id", Value: ""}, {Name: "le", Value: "20"}}...), + }, + { + Value: 1, + Ts: 1663113420863, + Labels: labels.New([]labels.Label{{Name: "foo", Value: "bar"}, {Name: "trace_id", Value: "10a47365b8aa04e08291fab9deca84db6170"}, {Name: "traceid", Value: "e3688e1aa2961786"}, {Name: "span_id", Value: "719cee4a669fd7d109ff"}}...), + }, + { + Value: 1, + Ts: 1663113420863, + Labels: labels.New([]labels.Label{{Name: "foo", Value: "bar"}, {Name: "trace_id", Value: "174137cab66dc880"}, {Name: "span_id", Value: "dfa4597a9d"}}...), + }, + { + Value: 1, + Ts: 1663113420863, + Labels: labels.New([]labels.Label{{Name: "foo", Value: "bar"}, {Name: "trace_id", Value: "174137cab66dc88"}, {Name: "span_id", Value: "dfa4597a9"}}...), + }, }, - }, - "foo", "bar", "le", "10"), - createDataPoint("hist_test_bucket", 2, nil, "foo", "bar", "le", "20"), - createDataPoint("hist_test_bucket", 10, nil, "foo", "bar", "le", "+inf"), - createDataPoint("hist_test_sum", 99, nil, "foo", "bar"), - createDataPoint("hist_test_count", 10, nil, "foo", "bar"), + "foo", "bar", "le", "10"), + createDataPoint("hist_test_bucket", 2, nil, "foo", "bar", "le", "20"), + createDataPoint("hist_test_bucket", 10, nil, "foo", "bar", "le", "+inf"), + createDataPoint("hist_test_sum", 99, nil, "foo", "bar"), + createDataPoint("hist_test_count", 10, nil, "foo", "bar"), + }, }, }, - }, - wants: func() []pmetric.Metrics { - md0 := pmetric.NewMetrics() - mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() - m0 := mL0.AppendEmpty() - m0.SetName("hist_test") - m0.Metadata().PutStr("prometheus.type", "histogram") - hist0 := m0.SetEmptyHistogram() - hist0.SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) - pt0 := hist0.DataPoints().AppendEmpty() - pt0.SetCount(10) - pt0.SetSum(99) - pt0.ExplicitBounds().FromRaw([]float64{10, 20}) - pt0.BucketCounts().FromRaw([]uint64{1, 1, 8}) - pt0.SetTimestamp(tsNanos) - pt0.SetStartTimestamp(startTimestamp) - pt0.Attributes().PutStr("foo", "bar") + wants: func() []pmetric.Metrics { + md0 := pmetric.NewMetrics() + mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() + m0 := mL0.AppendEmpty() + m0.SetName("hist_test") + m0.Metadata().PutStr("prometheus.type", "histogram") + hist0 := m0.SetEmptyHistogram() + hist0.SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + pt0 := hist0.DataPoints().AppendEmpty() + pt0.SetCount(10) + pt0.SetSum(99) + pt0.ExplicitBounds().FromRaw([]float64{10, 20}) + pt0.BucketCounts().FromRaw([]uint64{1, 1, 8}) + pt0.SetTimestamp(tsNanos) + if !disableMetricAdjustment { + pt0.SetStartTimestamp(startTimestamp) + } + pt0.Attributes().PutStr("foo", "bar") - e0 := pt0.Exemplars().AppendEmpty() - e0.SetTimestamp(timestampFromMs(1663113420863)) - e0.SetDoubleValue(1) - e0.FilteredAttributes().PutStr(model.MetricNameLabel, "counter_test") - e0.FilteredAttributes().PutStr("foo", "bar") - e0.FilteredAttributes().PutStr(model.InstanceLabel, "instance") - e0.FilteredAttributes().PutStr(model.JobLabel, "job") + e0 := pt0.Exemplars().AppendEmpty() + e0.SetTimestamp(timestampFromMs(1663113420863)) + e0.SetDoubleValue(1) + e0.FilteredAttributes().PutStr(model.MetricNameLabel, "counter_test") + e0.FilteredAttributes().PutStr("foo", "bar") + e0.FilteredAttributes().PutStr(model.InstanceLabel, "instance") + e0.FilteredAttributes().PutStr(model.JobLabel, "job") - e1 := pt0.Exemplars().AppendEmpty() - e1.SetTimestamp(timestampFromMs(1663113420863)) - e1.SetDoubleValue(1) - e1.FilteredAttributes().PutStr("foo", "bar") - e1.FilteredAttributes().PutStr("le", "20") + e1 := pt0.Exemplars().AppendEmpty() + e1.SetTimestamp(timestampFromMs(1663113420863)) + e1.SetDoubleValue(1) + e1.FilteredAttributes().PutStr("foo", "bar") + e1.FilteredAttributes().PutStr("le", "20") - e2 := pt0.Exemplars().AppendEmpty() - e2.SetTimestamp(timestampFromMs(1663113420863)) - e2.SetDoubleValue(1) - e2.FilteredAttributes().PutStr("foo", "bar") - e2.FilteredAttributes().PutStr("traceid", "e3688e1aa2961786") - e2.SetTraceID([16]byte{0x10, 0xa4, 0x73, 0x65, 0xb8, 0xaa, 0x04, 0xe0, 0x82, 0x91, 0xfa, 0xb9, 0xde, 0xca, 0x84, 0xdb}) - e2.SetSpanID([8]byte{0x71, 0x9c, 0xee, 0x4a, 0x66, 0x9f, 0xd7, 0xd1}) + e2 := pt0.Exemplars().AppendEmpty() + e2.SetTimestamp(timestampFromMs(1663113420863)) + e2.SetDoubleValue(1) + e2.FilteredAttributes().PutStr("foo", "bar") + e2.FilteredAttributes().PutStr("traceid", "e3688e1aa2961786") + e2.SetTraceID([16]byte{0x10, 0xa4, 0x73, 0x65, 0xb8, 0xaa, 0x04, 0xe0, 0x82, 0x91, 0xfa, 0xb9, 0xde, 0xca, 0x84, 0xdb}) + e2.SetSpanID([8]byte{0x71, 0x9c, 0xee, 0x4a, 0x66, 0x9f, 0xd7, 0xd1}) - e3 := pt0.Exemplars().AppendEmpty() - e3.SetTimestamp(timestampFromMs(1663113420863)) - e3.SetDoubleValue(1) - e3.FilteredAttributes().PutStr("foo", "bar") - e3.SetTraceID([16]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x41, 0x37, 0xca, 0xb6, 0x6d, 0xc8, 0x80}) - e3.SetSpanID([8]byte{0x00, 0x00, 0x00, 0xdf, 0xa4, 0x59, 0x7a, 0x9d}) + e3 := pt0.Exemplars().AppendEmpty() + e3.SetTimestamp(timestampFromMs(1663113420863)) + e3.SetDoubleValue(1) + e3.FilteredAttributes().PutStr("foo", "bar") + e3.SetTraceID([16]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x17, 0x41, 0x37, 0xca, 0xb6, 0x6d, 0xc8, 0x80}) + e3.SetSpanID([8]byte{0x00, 0x00, 0x00, 0xdf, 0xa4, 0x59, 0x7a, 0x9d}) - e4 := pt0.Exemplars().AppendEmpty() - e4.SetTimestamp(timestampFromMs(1663113420863)) - e4.SetDoubleValue(1) - e4.FilteredAttributes().PutStr("foo", "bar") - e4.FilteredAttributes().PutStr("span_id", "dfa4597a9") - e4.FilteredAttributes().PutStr("trace_id", "174137cab66dc88") + e4 := pt0.Exemplars().AppendEmpty() + e4.SetTimestamp(timestampFromMs(1663113420863)) + e4.SetDoubleValue(1) + e4.FilteredAttributes().PutStr("foo", "bar") + e4.FilteredAttributes().PutStr("span_id", "dfa4597a9") + e4.FilteredAttributes().PutStr("trace_id", "174137cab66dc88") - return []pmetric.Metrics{md0} + return []pmetric.Metrics{md0} + }, }, - }, - { - name: "multi-groups", - inputs: []*testScrapedPage{ - { - pts: []*testDataPoint{ - createDataPoint("hist_test_bucket", 1, nil, "foo", "bar", "le", "10"), - createDataPoint("hist_test_bucket", 2, nil, "foo", "bar", "le", "20"), - createDataPoint("hist_test_bucket", 10, nil, "foo", "bar", "le", "+inf"), - createDataPoint("hist_test_sum", 99, nil, "foo", "bar"), - createDataPoint("hist_test_count", 10, nil, "foo", "bar"), - createDataPoint("hist_test_bucket", 1, nil, "key2", "v2", "le", "10"), - createDataPoint("hist_test_bucket", 2, nil, "key2", "v2", "le", "20"), - createDataPoint("hist_test_bucket", 3, nil, "key2", "v2", "le", "+inf"), - createDataPoint("hist_test_sum", 50, nil, "key2", "v2"), - createDataPoint("hist_test_count", 3, nil, "key2", "v2"), + { + name: "multi-groups", + inputs: []*testScrapedPage{ + { + pts: []*testDataPoint{ + createDataPoint("hist_test_bucket", 1, nil, "foo", "bar", "le", "10"), + createDataPoint("hist_test_bucket", 2, nil, "foo", "bar", "le", "20"), + createDataPoint("hist_test_bucket", 10, nil, "foo", "bar", "le", "+inf"), + createDataPoint("hist_test_sum", 99, nil, "foo", "bar"), + createDataPoint("hist_test_count", 10, nil, "foo", "bar"), + createDataPoint("hist_test_bucket", 1, nil, "key2", "v2", "le", "10"), + createDataPoint("hist_test_bucket", 2, nil, "key2", "v2", "le", "20"), + createDataPoint("hist_test_bucket", 3, nil, "key2", "v2", "le", "+inf"), + createDataPoint("hist_test_sum", 50, nil, "key2", "v2"), + createDataPoint("hist_test_count", 3, nil, "key2", "v2"), + }, }, }, - }, - wants: func() []pmetric.Metrics { - md0 := pmetric.NewMetrics() - mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() - m0 := mL0.AppendEmpty() - m0.SetName("hist_test") - m0.Metadata().PutStr("prometheus.type", "histogram") - hist0 := m0.SetEmptyHistogram() - hist0.SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) - pt0 := hist0.DataPoints().AppendEmpty() - pt0.SetCount(10) - pt0.SetSum(99) - pt0.ExplicitBounds().FromRaw([]float64{10, 20}) - pt0.BucketCounts().FromRaw([]uint64{1, 1, 8}) - pt0.SetTimestamp(tsNanos) - pt0.SetStartTimestamp(startTimestamp) - pt0.Attributes().PutStr("foo", "bar") + wants: func() []pmetric.Metrics { + md0 := pmetric.NewMetrics() + mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() + m0 := mL0.AppendEmpty() + m0.SetName("hist_test") + m0.Metadata().PutStr("prometheus.type", "histogram") + hist0 := m0.SetEmptyHistogram() + hist0.SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + pt0 := hist0.DataPoints().AppendEmpty() + pt0.SetCount(10) + pt0.SetSum(99) + pt0.ExplicitBounds().FromRaw([]float64{10, 20}) + pt0.BucketCounts().FromRaw([]uint64{1, 1, 8}) + pt0.SetTimestamp(tsNanos) + if !disableMetricAdjustment { + pt0.SetStartTimestamp(startTimestamp) + } + pt0.Attributes().PutStr("foo", "bar") - pt1 := hist0.DataPoints().AppendEmpty() - pt1.SetCount(3) - pt1.SetSum(50) - pt1.ExplicitBounds().FromRaw([]float64{10, 20}) - pt1.BucketCounts().FromRaw([]uint64{1, 1, 1}) - pt1.SetTimestamp(tsNanos) - pt1.SetStartTimestamp(startTimestamp) - pt1.Attributes().PutStr("key2", "v2") + pt1 := hist0.DataPoints().AppendEmpty() + pt1.SetCount(3) + pt1.SetSum(50) + pt1.ExplicitBounds().FromRaw([]float64{10, 20}) + pt1.BucketCounts().FromRaw([]uint64{1, 1, 1}) + pt1.SetTimestamp(tsNanos) + if !disableMetricAdjustment { + pt1.SetStartTimestamp(startTimestamp) + } + pt1.Attributes().PutStr("key2", "v2") - return []pmetric.Metrics{md0} + return []pmetric.Metrics{md0} + }, }, - }, - { - name: "multi-groups-and-families", - inputs: []*testScrapedPage{ - { - pts: []*testDataPoint{ - createDataPoint("hist_test_bucket", 1, nil, "foo", "bar", "le", "10"), - createDataPoint("hist_test_bucket", 2, nil, "foo", "bar", "le", "20"), - createDataPoint("hist_test_bucket", 10, nil, "foo", "bar", "le", "+inf"), - createDataPoint("hist_test_sum", 99, nil, "foo", "bar"), - createDataPoint("hist_test_count", 10, nil, "foo", "bar"), - createDataPoint("hist_test_bucket", 1, nil, "key2", "v2", "le", "10"), - createDataPoint("hist_test_bucket", 2, nil, "key2", "v2", "le", "20"), - createDataPoint("hist_test_bucket", 3, nil, "key2", "v2", "le", "+inf"), - createDataPoint("hist_test_sum", 50, nil, "key2", "v2"), - createDataPoint("hist_test_count", 3, nil, "key2", "v2"), - createDataPoint("hist_test2_bucket", 1, nil, "foo", "bar", "le", "10"), - createDataPoint("hist_test2_bucket", 2, nil, "foo", "bar", "le", "20"), - createDataPoint("hist_test2_bucket", 3, nil, "foo", "bar", "le", "+inf"), - createDataPoint("hist_test2_sum", 50, nil, "foo", "bar"), - createDataPoint("hist_test2_count", 3, nil, "foo", "bar"), + { + name: "multi-groups-and-families", + inputs: []*testScrapedPage{ + { + pts: []*testDataPoint{ + createDataPoint("hist_test_bucket", 1, nil, "foo", "bar", "le", "10"), + createDataPoint("hist_test_bucket", 2, nil, "foo", "bar", "le", "20"), + createDataPoint("hist_test_bucket", 10, nil, "foo", "bar", "le", "+inf"), + createDataPoint("hist_test_sum", 99, nil, "foo", "bar"), + createDataPoint("hist_test_count", 10, nil, "foo", "bar"), + createDataPoint("hist_test_bucket", 1, nil, "key2", "v2", "le", "10"), + createDataPoint("hist_test_bucket", 2, nil, "key2", "v2", "le", "20"), + createDataPoint("hist_test_bucket", 3, nil, "key2", "v2", "le", "+inf"), + createDataPoint("hist_test_sum", 50, nil, "key2", "v2"), + createDataPoint("hist_test_count", 3, nil, "key2", "v2"), + createDataPoint("hist_test2_bucket", 1, nil, "foo", "bar", "le", "10"), + createDataPoint("hist_test2_bucket", 2, nil, "foo", "bar", "le", "20"), + createDataPoint("hist_test2_bucket", 3, nil, "foo", "bar", "le", "+inf"), + createDataPoint("hist_test2_sum", 50, nil, "foo", "bar"), + createDataPoint("hist_test2_count", 3, nil, "foo", "bar"), + }, }, }, - }, - wants: func() []pmetric.Metrics { - md0 := pmetric.NewMetrics() - mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() - m0 := mL0.AppendEmpty() - m0.SetName("hist_test") - m0.Metadata().PutStr("prometheus.type", "histogram") - hist0 := m0.SetEmptyHistogram() - hist0.SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) - pt0 := hist0.DataPoints().AppendEmpty() - pt0.SetCount(10) - pt0.SetSum(99) - pt0.ExplicitBounds().FromRaw([]float64{10, 20}) - pt0.BucketCounts().FromRaw([]uint64{1, 1, 8}) - pt0.SetTimestamp(tsNanos) - pt0.SetStartTimestamp(startTimestamp) - pt0.Attributes().PutStr("foo", "bar") + wants: func() []pmetric.Metrics { + md0 := pmetric.NewMetrics() + mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() + m0 := mL0.AppendEmpty() + m0.SetName("hist_test") + m0.Metadata().PutStr("prometheus.type", "histogram") + hist0 := m0.SetEmptyHistogram() + hist0.SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + pt0 := hist0.DataPoints().AppendEmpty() + pt0.SetCount(10) + pt0.SetSum(99) + pt0.ExplicitBounds().FromRaw([]float64{10, 20}) + pt0.BucketCounts().FromRaw([]uint64{1, 1, 8}) + pt0.SetTimestamp(tsNanos) + if !disableMetricAdjustment { + pt0.SetStartTimestamp(startTimestamp) + } + pt0.Attributes().PutStr("foo", "bar") - pt1 := hist0.DataPoints().AppendEmpty() - pt1.SetCount(3) - pt1.SetSum(50) - pt1.ExplicitBounds().FromRaw([]float64{10, 20}) - pt1.BucketCounts().FromRaw([]uint64{1, 1, 1}) - pt1.SetTimestamp(tsNanos) - pt1.SetStartTimestamp(startTimestamp) - pt1.Attributes().PutStr("key2", "v2") + pt1 := hist0.DataPoints().AppendEmpty() + pt1.SetCount(3) + pt1.SetSum(50) + pt1.ExplicitBounds().FromRaw([]float64{10, 20}) + pt1.BucketCounts().FromRaw([]uint64{1, 1, 1}) + pt1.SetTimestamp(tsNanos) + if !disableMetricAdjustment { + pt1.SetStartTimestamp(startTimestamp) + } + pt1.Attributes().PutStr("key2", "v2") - m1 := mL0.AppendEmpty() - m1.SetName("hist_test2") - m1.Metadata().PutStr("prometheus.type", "histogram") - hist1 := m1.SetEmptyHistogram() - hist1.SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) - pt2 := hist1.DataPoints().AppendEmpty() - pt2.SetCount(3) - pt2.SetSum(50) - pt2.ExplicitBounds().FromRaw([]float64{10, 20}) - pt2.BucketCounts().FromRaw([]uint64{1, 1, 1}) - pt2.SetTimestamp(tsNanos) - pt2.SetStartTimestamp(startTimestamp) - pt2.Attributes().PutStr("foo", "bar") + m1 := mL0.AppendEmpty() + m1.SetName("hist_test2") + m1.Metadata().PutStr("prometheus.type", "histogram") + hist1 := m1.SetEmptyHistogram() + hist1.SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + pt2 := hist1.DataPoints().AppendEmpty() + pt2.SetCount(3) + pt2.SetSum(50) + pt2.ExplicitBounds().FromRaw([]float64{10, 20}) + pt2.BucketCounts().FromRaw([]uint64{1, 1, 1}) + pt2.SetTimestamp(tsNanos) + if !disableMetricAdjustment { + pt2.SetStartTimestamp(startTimestamp) + } + pt2.Attributes().PutStr("foo", "bar") - return []pmetric.Metrics{md0} + return []pmetric.Metrics{md0} + }, }, - }, - { - name: "unordered-buckets", - inputs: []*testScrapedPage{ - { - pts: []*testDataPoint{ - createDataPoint("hist_test_bucket", 10, nil, "foo", "bar", "le", "+inf"), - createDataPoint("hist_test_bucket", 1, nil, "foo", "bar", "le", "10"), - createDataPoint("hist_test_bucket", 2, nil, "foo", "bar", "le", "20"), - createDataPoint("hist_test_sum", 99, nil, "foo", "bar"), - createDataPoint("hist_test_count", 10, nil, "foo", "bar"), + { + name: "unordered-buckets", + inputs: []*testScrapedPage{ + { + pts: []*testDataPoint{ + createDataPoint("hist_test_bucket", 10, nil, "foo", "bar", "le", "+inf"), + createDataPoint("hist_test_bucket", 1, nil, "foo", "bar", "le", "10"), + createDataPoint("hist_test_bucket", 2, nil, "foo", "bar", "le", "20"), + createDataPoint("hist_test_sum", 99, nil, "foo", "bar"), + createDataPoint("hist_test_count", 10, nil, "foo", "bar"), + }, }, }, - }, - wants: func() []pmetric.Metrics { - md0 := pmetric.NewMetrics() - mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() - m0 := mL0.AppendEmpty() - m0.SetName("hist_test") - m0.Metadata().PutStr("prometheus.type", "histogram") - hist0 := m0.SetEmptyHistogram() - hist0.SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) - pt0 := hist0.DataPoints().AppendEmpty() - pt0.SetCount(10) - pt0.SetSum(99) - pt0.ExplicitBounds().FromRaw([]float64{10, 20}) - pt0.BucketCounts().FromRaw([]uint64{1, 1, 8}) - pt0.SetTimestamp(tsNanos) - pt0.SetStartTimestamp(startTimestamp) - pt0.Attributes().PutStr("foo", "bar") + wants: func() []pmetric.Metrics { + md0 := pmetric.NewMetrics() + mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() + m0 := mL0.AppendEmpty() + m0.SetName("hist_test") + m0.Metadata().PutStr("prometheus.type", "histogram") + hist0 := m0.SetEmptyHistogram() + hist0.SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + pt0 := hist0.DataPoints().AppendEmpty() + pt0.SetCount(10) + pt0.SetSum(99) + pt0.ExplicitBounds().FromRaw([]float64{10, 20}) + pt0.BucketCounts().FromRaw([]uint64{1, 1, 8}) + pt0.SetTimestamp(tsNanos) + if !disableMetricAdjustment { + pt0.SetStartTimestamp(startTimestamp) + } + pt0.Attributes().PutStr("foo", "bar") - return []pmetric.Metrics{md0} + return []pmetric.Metrics{md0} + }, }, - }, - { - // this won't likely happen in real env, as prometheus wont generate histogram with less than 3 buckets - name: "only-one-bucket", - inputs: []*testScrapedPage{ - { - pts: []*testDataPoint{ - createDataPoint("hist_test_bucket", 3, nil, "foo", "bar", "le", "+inf"), - createDataPoint("hist_test_count", 3, nil, "foo", "bar"), - createDataPoint("hist_test_sum", 100, nil, "foo", "bar"), + { + // this won't likely happen in real env, as prometheus wont generate histogram with less than 3 buckets + name: "only-one-bucket", + inputs: []*testScrapedPage{ + { + pts: []*testDataPoint{ + createDataPoint("hist_test_bucket", 3, nil, "foo", "bar", "le", "+inf"), + createDataPoint("hist_test_count", 3, nil, "foo", "bar"), + createDataPoint("hist_test_sum", 100, nil, "foo", "bar"), + }, }, }, - }, - wants: func() []pmetric.Metrics { - md0 := pmetric.NewMetrics() - mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() - m0 := mL0.AppendEmpty() - m0.SetName("hist_test") - m0.Metadata().PutStr("prometheus.type", "histogram") - hist0 := m0.SetEmptyHistogram() - hist0.SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) - pt0 := hist0.DataPoints().AppendEmpty() - pt0.SetCount(3) - pt0.SetSum(100) - pt0.BucketCounts().FromRaw([]uint64{3}) - pt0.SetTimestamp(tsNanos) - pt0.SetStartTimestamp(startTimestamp) - pt0.Attributes().PutStr("foo", "bar") + wants: func() []pmetric.Metrics { + md0 := pmetric.NewMetrics() + mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() + m0 := mL0.AppendEmpty() + m0.SetName("hist_test") + m0.Metadata().PutStr("prometheus.type", "histogram") + hist0 := m0.SetEmptyHistogram() + hist0.SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + pt0 := hist0.DataPoints().AppendEmpty() + pt0.SetCount(3) + pt0.SetSum(100) + pt0.BucketCounts().FromRaw([]uint64{3}) + pt0.SetTimestamp(tsNanos) + if !disableMetricAdjustment { + pt0.SetStartTimestamp(startTimestamp) + } + pt0.Attributes().PutStr("foo", "bar") - return []pmetric.Metrics{md0} + return []pmetric.Metrics{md0} + }, }, - }, - { - // this won't likely happen in real env, as prometheus wont generate histogram with less than 3 buckets - name: "only-one-bucket-noninf", - inputs: []*testScrapedPage{ - { - pts: []*testDataPoint{ - createDataPoint("hist_test_bucket", 3, nil, "foo", "bar", "le", "20"), - createDataPoint("hist_test_count", 3, nil, "foo", "bar"), - createDataPoint("hist_test_sum", 100, nil, "foo", "bar"), + { + // this won't likely happen in real env, as prometheus wont generate histogram with less than 3 buckets + name: "only-one-bucket-noninf", + inputs: []*testScrapedPage{ + { + pts: []*testDataPoint{ + createDataPoint("hist_test_bucket", 3, nil, "foo", "bar", "le", "20"), + createDataPoint("hist_test_count", 3, nil, "foo", "bar"), + createDataPoint("hist_test_sum", 100, nil, "foo", "bar"), + }, }, }, - }, - wants: func() []pmetric.Metrics { - md0 := pmetric.NewMetrics() - mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() - m0 := mL0.AppendEmpty() - m0.SetName("hist_test") - m0.Metadata().PutStr("prometheus.type", "histogram") - hist0 := m0.SetEmptyHistogram() - hist0.SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) - pt0 := hist0.DataPoints().AppendEmpty() - pt0.SetCount(3) - pt0.SetSum(100) - pt0.BucketCounts().FromRaw([]uint64{3, 0}) - pt0.ExplicitBounds().FromRaw([]float64{20}) - pt0.SetTimestamp(tsNanos) - pt0.SetStartTimestamp(startTimestamp) - pt0.Attributes().PutStr("foo", "bar") + wants: func() []pmetric.Metrics { + md0 := pmetric.NewMetrics() + mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() + m0 := mL0.AppendEmpty() + m0.SetName("hist_test") + m0.Metadata().PutStr("prometheus.type", "histogram") + hist0 := m0.SetEmptyHistogram() + hist0.SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + pt0 := hist0.DataPoints().AppendEmpty() + pt0.SetCount(3) + pt0.SetSum(100) + pt0.BucketCounts().FromRaw([]uint64{3, 0}) + pt0.ExplicitBounds().FromRaw([]float64{20}) + pt0.SetTimestamp(tsNanos) + if !disableMetricAdjustment { + pt0.SetStartTimestamp(startTimestamp) + } + pt0.Attributes().PutStr("foo", "bar") - return []pmetric.Metrics{md0} + return []pmetric.Metrics{md0} + }, }, - }, - { - name: "no-sum", - inputs: []*testScrapedPage{ - { - pts: []*testDataPoint{ - createDataPoint("hist_test_bucket", 1, nil, "foo", "bar", "le", "10"), - createDataPoint("hist_test_bucket", 2, nil, "foo", "bar", "le", "20"), - createDataPoint("hist_test_bucket", 3, nil, "foo", "bar", "le", "+inf"), - createDataPoint("hist_test_count", 3, nil, "foo", "bar"), + { + name: "no-sum", + inputs: []*testScrapedPage{ + { + pts: []*testDataPoint{ + createDataPoint("hist_test_bucket", 1, nil, "foo", "bar", "le", "10"), + createDataPoint("hist_test_bucket", 2, nil, "foo", "bar", "le", "20"), + createDataPoint("hist_test_bucket", 3, nil, "foo", "bar", "le", "+inf"), + createDataPoint("hist_test_count", 3, nil, "foo", "bar"), + }, }, }, - }, - wants: func() []pmetric.Metrics { - md0 := pmetric.NewMetrics() - mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() - m0 := mL0.AppendEmpty() - m0.SetName("hist_test") - m0.Metadata().PutStr("prometheus.type", "histogram") - hist0 := m0.SetEmptyHistogram() - hist0.SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) - pt0 := hist0.DataPoints().AppendEmpty() - pt0.SetCount(3) - pt0.ExplicitBounds().FromRaw([]float64{10, 20}) - pt0.BucketCounts().FromRaw([]uint64{1, 1, 1}) - pt0.SetTimestamp(tsNanos) - pt0.SetStartTimestamp(startTimestamp) - pt0.Attributes().PutStr("foo", "bar") + wants: func() []pmetric.Metrics { + md0 := pmetric.NewMetrics() + mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() + m0 := mL0.AppendEmpty() + m0.SetName("hist_test") + m0.Metadata().PutStr("prometheus.type", "histogram") + hist0 := m0.SetEmptyHistogram() + hist0.SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + pt0 := hist0.DataPoints().AppendEmpty() + pt0.SetCount(3) + pt0.ExplicitBounds().FromRaw([]float64{10, 20}) + pt0.BucketCounts().FromRaw([]uint64{1, 1, 1}) + pt0.SetTimestamp(tsNanos) + if !disableMetricAdjustment { + pt0.SetStartTimestamp(startTimestamp) + } + pt0.Attributes().PutStr("foo", "bar") - return []pmetric.Metrics{md0} + return []pmetric.Metrics{md0} + }, }, - }, - { - name: "corrupted-no-buckets", - inputs: []*testScrapedPage{ - { - pts: []*testDataPoint{ - createDataPoint("hist_test_sum", 99, nil, "foo", "bar"), - createDataPoint("hist_test_count", 10, nil, "foo", "bar"), + { + name: "corrupted-no-buckets", + inputs: []*testScrapedPage{ + { + pts: []*testDataPoint{ + createDataPoint("hist_test_sum", 99, nil, "foo", "bar"), + createDataPoint("hist_test_count", 10, nil, "foo", "bar"), + }, }, }, - }, - wants: func() []pmetric.Metrics { - md0 := pmetric.NewMetrics() - mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() - m0 := mL0.AppendEmpty() - m0.SetName("hist_test") - m0.Metadata().PutStr("prometheus.type", "histogram") - hist0 := m0.SetEmptyHistogram() - hist0.SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) - pt0 := hist0.DataPoints().AppendEmpty() - pt0.SetCount(10) - pt0.SetSum(99) - pt0.BucketCounts().FromRaw([]uint64{10}) - pt0.SetTimestamp(tsNanos) - pt0.SetStartTimestamp(startTimestamp) - pt0.Attributes().PutStr("foo", "bar") + wants: func() []pmetric.Metrics { + md0 := pmetric.NewMetrics() + mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() + m0 := mL0.AppendEmpty() + m0.SetName("hist_test") + m0.Metadata().PutStr("prometheus.type", "histogram") + hist0 := m0.SetEmptyHistogram() + hist0.SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + pt0 := hist0.DataPoints().AppendEmpty() + pt0.SetCount(10) + pt0.SetSum(99) + pt0.BucketCounts().FromRaw([]uint64{10}) + pt0.SetTimestamp(tsNanos) + if !disableMetricAdjustment { + pt0.SetStartTimestamp(startTimestamp) + } + pt0.Attributes().PutStr("foo", "bar") - return []pmetric.Metrics{md0} + return []pmetric.Metrics{md0} + }, }, - }, - { - name: "corrupted-no-count", - inputs: []*testScrapedPage{ - { - pts: []*testDataPoint{ - createDataPoint("hist_test_bucket", 1, nil, "foo", "bar", "le", "10"), - createDataPoint("hist_test_bucket", 2, nil, "foo", "bar", "le", "20"), - createDataPoint("hist_test_bucket", 3, nil, "foo", "bar", "le", "+inf"), - createDataPoint("hist_test_sum", 99, nil, "foo", "bar"), + { + name: "corrupted-no-count", + inputs: []*testScrapedPage{ + { + pts: []*testDataPoint{ + createDataPoint("hist_test_bucket", 1, nil, "foo", "bar", "le", "10"), + createDataPoint("hist_test_bucket", 2, nil, "foo", "bar", "le", "20"), + createDataPoint("hist_test_bucket", 3, nil, "foo", "bar", "le", "+inf"), + createDataPoint("hist_test_sum", 99, nil, "foo", "bar"), + }, }, }, + wants: func() []pmetric.Metrics { + return []pmetric.Metrics{pmetric.NewMetrics()} + }, }, - wants: func() []pmetric.Metrics { - return []pmetric.Metrics{pmetric.NewMetrics()} - }, - }, - } + } - for _, tt := range tests { - for _, enableNativeHistograms := range []bool{true, false} { - // None of the histograms above have native histogram versions, so enabling native histograms has no effect. - t.Run(fmt.Sprintf("%s/enableNativeHistograms=%v", tt.name, enableNativeHistograms), func(t *testing.T) { - tt.run(t, enableNativeHistograms) - }) + for _, tt := range tests { + for _, enableNativeHistograms := range []bool{true, false} { + // None of the histograms above have native histogram versions, so enabling native histograms has no effect. + t.Run(fmt.Sprintf("%s/enableNativeHistograms=%v/removeStartTimeAdjustment=%v", tt.name, enableNativeHistograms, disableMetricAdjustment), func(t *testing.T) { + defer testutil.SetFeatureGateForTest(t, removeStartTimeAdjustment, disableMetricAdjustment)() + tt.run(t, enableNativeHistograms) + }) + } } } } func TestMetricBuilderSummary(t *testing.T) { - tests := []buildTestData{ - { - name: "no-sum-and-count", - inputs: []*testScrapedPage{ - { - pts: []*testDataPoint{ - createDataPoint("summary_test", 5, nil, "foo", "bar", "quantile", "1"), + for _, disableMetricAdjustment := range []bool{true, false} { + tests := []buildTestData{ + { + name: "no-sum-and-count", + inputs: []*testScrapedPage{ + { + pts: []*testDataPoint{ + createDataPoint("summary_test", 5, nil, "foo", "bar", "quantile", "1"), + }, }, }, - }, - wants: func() []pmetric.Metrics { - return []pmetric.Metrics{pmetric.NewMetrics()} - }, - }, - { - name: "no-count", - inputs: []*testScrapedPage{ - { - pts: []*testDataPoint{ - createDataPoint("summary_test", 1, nil, "foo", "bar", "quantile", "0.5"), - createDataPoint("summary_test", 2, nil, "foo", "bar", "quantile", "0.75"), - createDataPoint("summary_test", 5, nil, "foo", "bar", "quantile", "1"), - createDataPoint("summary_test_sum", 500, nil, "foo", "bar"), - }, + wants: func() []pmetric.Metrics { + return []pmetric.Metrics{pmetric.NewMetrics()} }, }, - wants: func() []pmetric.Metrics { - return []pmetric.Metrics{pmetric.NewMetrics()} - }, - }, - { - name: "no-sum", - inputs: []*testScrapedPage{ - { - pts: []*testDataPoint{ - createDataPoint("summary_test", 1, nil, "foo", "bar", "quantile", "0.5"), - createDataPoint("summary_test", 2, nil, "foo", "bar", "quantile", "0.75"), - createDataPoint("summary_test", 5, nil, "foo", "bar", "quantile", "1"), - createDataPoint("summary_test_count", 500, nil, "foo", "bar"), + { + name: "no-count", + inputs: []*testScrapedPage{ + { + pts: []*testDataPoint{ + createDataPoint("summary_test", 1, nil, "foo", "bar", "quantile", "0.5"), + createDataPoint("summary_test", 2, nil, "foo", "bar", "quantile", "0.75"), + createDataPoint("summary_test", 5, nil, "foo", "bar", "quantile", "1"), + createDataPoint("summary_test_sum", 500, nil, "foo", "bar"), + }, }, }, - }, - wants: func() []pmetric.Metrics { - md0 := pmetric.NewMetrics() - mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() - m0 := mL0.AppendEmpty() - m0.SetName("summary_test") - m0.Metadata().PutStr("prometheus.type", "summary") - sum0 := m0.SetEmptySummary() - pt0 := sum0.DataPoints().AppendEmpty() - pt0.SetTimestamp(tsNanos) - pt0.SetStartTimestamp(startTimestamp) - pt0.SetCount(500) - pt0.SetSum(0.0) - pt0.Attributes().PutStr("foo", "bar") - qvL := pt0.QuantileValues() - q50 := qvL.AppendEmpty() - q50.SetQuantile(.50) - q50.SetValue(1.0) - q75 := qvL.AppendEmpty() - q75.SetQuantile(.75) - q75.SetValue(2.0) - q100 := qvL.AppendEmpty() - q100.SetQuantile(1) - q100.SetValue(5.0) - return []pmetric.Metrics{md0} - }, - }, - { - name: "empty-quantiles", - inputs: []*testScrapedPage{ - { - pts: []*testDataPoint{ - createDataPoint("summary_test_sum", 100, nil, "foo", "bar"), - createDataPoint("summary_test_count", 500, nil, "foo", "bar"), - }, + wants: func() []pmetric.Metrics { + return []pmetric.Metrics{pmetric.NewMetrics()} }, }, - wants: func() []pmetric.Metrics { - md0 := pmetric.NewMetrics() - mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() - m0 := mL0.AppendEmpty() - m0.SetName("summary_test") - m0.Metadata().PutStr("prometheus.type", "summary") - sum0 := m0.SetEmptySummary() - pt0 := sum0.DataPoints().AppendEmpty() - pt0.SetStartTimestamp(startTimestamp) - pt0.SetTimestamp(tsNanos) - pt0.SetCount(500) - pt0.SetSum(100.0) - pt0.Attributes().PutStr("foo", "bar") - - return []pmetric.Metrics{md0} - }, - }, - { - name: "regular-summary", - inputs: []*testScrapedPage{ - { - pts: []*testDataPoint{ - createDataPoint("summary_test", 1, nil, "foo", "bar", "quantile", "0.5"), - createDataPoint("summary_test", 2, nil, "foo", "bar", "quantile", "0.75"), - createDataPoint("summary_test", 5, nil, "foo", "bar", "quantile", "1"), - createDataPoint("summary_test_sum", 100, nil, "foo", "bar"), - createDataPoint("summary_test_count", 500, nil, "foo", "bar"), + { + name: "no-sum", + inputs: []*testScrapedPage{ + { + pts: []*testDataPoint{ + createDataPoint("summary_test", 1, nil, "foo", "bar", "quantile", "0.5"), + createDataPoint("summary_test", 2, nil, "foo", "bar", "quantile", "0.75"), + createDataPoint("summary_test", 5, nil, "foo", "bar", "quantile", "1"), + createDataPoint("summary_test_count", 500, nil, "foo", "bar"), + }, }, }, + wants: func() []pmetric.Metrics { + md0 := pmetric.NewMetrics() + mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() + m0 := mL0.AppendEmpty() + m0.SetName("summary_test") + m0.Metadata().PutStr("prometheus.type", "summary") + sum0 := m0.SetEmptySummary() + pt0 := sum0.DataPoints().AppendEmpty() + pt0.SetTimestamp(tsNanos) + if !disableMetricAdjustment { + pt0.SetStartTimestamp(startTimestamp) + } + pt0.SetCount(500) + pt0.SetSum(0.0) + pt0.Attributes().PutStr("foo", "bar") + qvL := pt0.QuantileValues() + q50 := qvL.AppendEmpty() + q50.SetQuantile(.50) + q50.SetValue(1.0) + q75 := qvL.AppendEmpty() + q75.SetQuantile(.75) + q75.SetValue(2.0) + q100 := qvL.AppendEmpty() + q100.SetQuantile(1) + q100.SetValue(5.0) + return []pmetric.Metrics{md0} + }, }, - wants: func() []pmetric.Metrics { - md0 := pmetric.NewMetrics() - mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() - m0 := mL0.AppendEmpty() - m0.SetName("summary_test") - m0.Metadata().PutStr("prometheus.type", "summary") - sum0 := m0.SetEmptySummary() - pt0 := sum0.DataPoints().AppendEmpty() - pt0.SetStartTimestamp(startTimestamp) - pt0.SetTimestamp(tsNanos) - pt0.SetCount(500) - pt0.SetSum(100.0) - pt0.Attributes().PutStr("foo", "bar") - qvL := pt0.QuantileValues() - q50 := qvL.AppendEmpty() - q50.SetQuantile(.50) - q50.SetValue(1.0) - q75 := qvL.AppendEmpty() - q75.SetQuantile(.75) - q75.SetValue(2.0) - q100 := qvL.AppendEmpty() - q100.SetQuantile(1) - q100.SetValue(5.0) - - return []pmetric.Metrics{md0} - }, - }, - } - - for _, tt := range tests { - for _, enableNativeHistograms := range []bool{false, true} { - t.Run(fmt.Sprintf("%s/enableNativeHistograms=%v", tt.name, enableNativeHistograms), func(t *testing.T) { - tt.run(t, enableNativeHistograms) - }) - } - } -} - -func TestMetricBuilderNativeHistogram(t *testing.T) { - for _, enableNativeHistograms := range []bool{false, true} { - emptyH := &histogram.Histogram{ - Schema: 1, - Count: 0, - Sum: 0, - ZeroThreshold: 0.001, - ZeroCount: 0, - } - h0 := tsdbutil.GenerateTestHistogram(0) - - tests := []buildTestData{ { - name: "empty integer histogram", + name: "empty-quantiles", inputs: []*testScrapedPage{ { pts: []*testDataPoint{ - createHistogramDataPoint("hist_test", emptyH, nil, nil, "foo", "bar"), + createDataPoint("summary_test_sum", 100, nil, "foo", "bar"), + createDataPoint("summary_test_count", 500, nil, "foo", "bar"), }, }, }, wants: func() []pmetric.Metrics { md0 := pmetric.NewMetrics() - if !enableNativeHistograms { - return []pmetric.Metrics{md0} - } mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() m0 := mL0.AppendEmpty() - m0.SetName("hist_test") - m0.Metadata().PutStr("prometheus.type", "histogram") - m0.SetEmptyExponentialHistogram() - m0.ExponentialHistogram().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) - pt0 := m0.ExponentialHistogram().DataPoints().AppendEmpty() - pt0.Attributes().PutStr("foo", "bar") - pt0.SetStartTimestamp(startTimestamp) + m0.SetName("summary_test") + m0.Metadata().PutStr("prometheus.type", "summary") + sum0 := m0.SetEmptySummary() + pt0 := sum0.DataPoints().AppendEmpty() + if !disableMetricAdjustment { + pt0.SetStartTimestamp(startTimestamp) + } pt0.SetTimestamp(tsNanos) - pt0.SetCount(0) - pt0.SetSum(0) - pt0.SetZeroThreshold(0.001) - pt0.SetScale(1) + pt0.SetCount(500) + pt0.SetSum(100.0) + pt0.Attributes().PutStr("foo", "bar") return []pmetric.Metrics{md0} }, }, { - name: "integer histogram", + name: "regular-summary", inputs: []*testScrapedPage{ { pts: []*testDataPoint{ - createHistogramDataPoint("hist_test", h0, nil, nil, "foo", "bar"), + createDataPoint("summary_test", 1, nil, "foo", "bar", "quantile", "0.5"), + createDataPoint("summary_test", 2, nil, "foo", "bar", "quantile", "0.75"), + createDataPoint("summary_test", 5, nil, "foo", "bar", "quantile", "1"), + createDataPoint("summary_test_sum", 100, nil, "foo", "bar"), + createDataPoint("summary_test_count", 500, nil, "foo", "bar"), }, }, }, wants: func() []pmetric.Metrics { md0 := pmetric.NewMetrics() - if !enableNativeHistograms { - return []pmetric.Metrics{md0} - } mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() m0 := mL0.AppendEmpty() - m0.SetName("hist_test") - m0.Metadata().PutStr("prometheus.type", "histogram") - m0.SetEmptyExponentialHistogram() - m0.ExponentialHistogram().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) - pt0 := m0.ExponentialHistogram().DataPoints().AppendEmpty() - pt0.Attributes().PutStr("foo", "bar") - pt0.SetStartTimestamp(startTimestamp) + m0.SetName("summary_test") + m0.Metadata().PutStr("prometheus.type", "summary") + sum0 := m0.SetEmptySummary() + pt0 := sum0.DataPoints().AppendEmpty() + if !disableMetricAdjustment { + pt0.SetStartTimestamp(startTimestamp) + } pt0.SetTimestamp(tsNanos) - pt0.SetCount(12) - pt0.SetSum(18.4) - pt0.SetScale(1) - pt0.SetZeroThreshold(0.001) - pt0.SetZeroCount(2) - pt0.Positive().SetOffset(-1) - pt0.Positive().BucketCounts().Append(1) - pt0.Positive().BucketCounts().Append(2) - pt0.Positive().BucketCounts().Append(0) - pt0.Positive().BucketCounts().Append(1) - pt0.Positive().BucketCounts().Append(1) - pt0.Negative().SetOffset(-1) - pt0.Negative().BucketCounts().Append(1) - pt0.Negative().BucketCounts().Append(2) - pt0.Negative().BucketCounts().Append(0) - pt0.Negative().BucketCounts().Append(1) - pt0.Negative().BucketCounts().Append(1) + pt0.SetCount(500) + pt0.SetSum(100.0) + pt0.Attributes().PutStr("foo", "bar") + qvL := pt0.QuantileValues() + q50 := qvL.AppendEmpty() + q50.SetQuantile(.50) + q50.SetValue(1.0) + q75 := qvL.AppendEmpty() + q75.SetQuantile(.75) + q75.SetValue(2.0) + q100 := qvL.AppendEmpty() + q100.SetQuantile(1) + q100.SetValue(5.0) return []pmetric.Metrics{md0} }, @@ -1998,9 +1933,118 @@ func TestMetricBuilderNativeHistogram(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tt.run(t, enableNativeHistograms) - }) + for _, enableNativeHistograms := range []bool{false, true} { + t.Run(fmt.Sprintf("%s/enableNativeHistograms=%v/removeStartTimeAdjustment=%v", tt.name, enableNativeHistograms, disableMetricAdjustment), func(t *testing.T) { + defer testutil.SetFeatureGateForTest(t, removeStartTimeAdjustment, disableMetricAdjustment)() + tt.run(t, enableNativeHistograms) + }) + } + } + } +} + +func TestMetricBuilderNativeHistogram(t *testing.T) { + for _, disableMetricAdjustment := range []bool{true, false} { + for _, enableNativeHistograms := range []bool{false, true} { + emptyH := &histogram.Histogram{ + Schema: 1, + Count: 0, + Sum: 0, + ZeroThreshold: 0.001, + ZeroCount: 0, + } + h0 := tsdbutil.GenerateTestHistogram(0) + + tests := []buildTestData{ + { + name: "empty integer histogram", + inputs: []*testScrapedPage{ + { + pts: []*testDataPoint{ + createHistogramDataPoint("hist_test", emptyH, nil, nil, "foo", "bar"), + }, + }, + }, + wants: func() []pmetric.Metrics { + md0 := pmetric.NewMetrics() + if !enableNativeHistograms { + return []pmetric.Metrics{md0} + } + mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() + m0 := mL0.AppendEmpty() + m0.SetName("hist_test") + m0.Metadata().PutStr("prometheus.type", "histogram") + m0.SetEmptyExponentialHistogram() + m0.ExponentialHistogram().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + pt0 := m0.ExponentialHistogram().DataPoints().AppendEmpty() + pt0.Attributes().PutStr("foo", "bar") + if !disableMetricAdjustment { + pt0.SetStartTimestamp(startTimestamp) + } + pt0.SetTimestamp(tsNanos) + pt0.SetCount(0) + pt0.SetSum(0) + pt0.SetZeroThreshold(0.001) + pt0.SetScale(1) + + return []pmetric.Metrics{md0} + }, + }, + { + name: "integer histogram", + inputs: []*testScrapedPage{ + { + pts: []*testDataPoint{ + createHistogramDataPoint("hist_test", h0, nil, nil, "foo", "bar"), + }, + }, + }, + wants: func() []pmetric.Metrics { + md0 := pmetric.NewMetrics() + if !enableNativeHistograms { + return []pmetric.Metrics{md0} + } + mL0 := md0.ResourceMetrics().AppendEmpty().ScopeMetrics().AppendEmpty().Metrics() + m0 := mL0.AppendEmpty() + m0.SetName("hist_test") + m0.Metadata().PutStr("prometheus.type", "histogram") + m0.SetEmptyExponentialHistogram() + m0.ExponentialHistogram().SetAggregationTemporality(pmetric.AggregationTemporalityCumulative) + pt0 := m0.ExponentialHistogram().DataPoints().AppendEmpty() + pt0.Attributes().PutStr("foo", "bar") + if !disableMetricAdjustment { + pt0.SetStartTimestamp(startTimestamp) + } + pt0.SetTimestamp(tsNanos) + pt0.SetCount(12) + pt0.SetSum(18.4) + pt0.SetScale(1) + pt0.SetZeroThreshold(0.001) + pt0.SetZeroCount(2) + pt0.Positive().SetOffset(-1) + pt0.Positive().BucketCounts().Append(1) + pt0.Positive().BucketCounts().Append(2) + pt0.Positive().BucketCounts().Append(0) + pt0.Positive().BucketCounts().Append(1) + pt0.Positive().BucketCounts().Append(1) + pt0.Negative().SetOffset(-1) + pt0.Negative().BucketCounts().Append(1) + pt0.Negative().BucketCounts().Append(2) + pt0.Negative().BucketCounts().Append(0) + pt0.Negative().BucketCounts().Append(1) + pt0.Negative().BucketCounts().Append(1) + + return []pmetric.Metrics{md0} + }, + }, + } + + for _, tt := range tests { + t.Run(fmt.Sprintf("%s/enableNativeHistograms=%v/removeStartTimeAdjustment=%v", tt.name, enableNativeHistograms, disableMetricAdjustment), func(t *testing.T) { + defer testutil.SetFeatureGateForTest(t, removeStartTimeAdjustment, disableMetricAdjustment)() + tt.run(t, enableNativeHistograms) + }) + } } } } diff --git a/receiver/prometheusreceiver/metrics_receiver_created_timestamp_zero_ingestion_test.go b/receiver/prometheusreceiver/metrics_receiver_created_timestamp_zero_ingestion_test.go index 8190164cf1bb0..c166262983371 100644 --- a/receiver/prometheusreceiver/metrics_receiver_created_timestamp_zero_ingestion_test.go +++ b/receiver/prometheusreceiver/metrics_receiver_created_timestamp_zero_ingestion_test.go @@ -141,7 +141,7 @@ func verifyOpenMetricsCreatedTimestampZeroIngestionDisabled(t *testing.T, td *te []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts1), + compareStartTimestamp(tsZero), compareTimestamp(ts1), compareDoubleValue(1.0), }, diff --git a/receiver/prometheusreceiver/metrics_receiver_honor_timestamp_test.go b/receiver/prometheusreceiver/metrics_receiver_honor_timestamp_test.go index 5a0416ad8bf0d..c857fe9ba2b18 100644 --- a/receiver/prometheusreceiver/metrics_receiver_honor_timestamp_test.go +++ b/receiver/prometheusreceiver/metrics_receiver_honor_timestamp_test.go @@ -226,7 +226,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts2))), + compareStartTimestamp(tsZero), compareTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts2))), compareDoubleValue(100), compareAttributes(map[string]string{"method": "post", "code": "200"}), @@ -234,7 +234,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme }, { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts3))), + compareStartTimestamp(tsZero), compareTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts3))), compareDoubleValue(5), compareAttributes(map[string]string{"method": "post", "code": "400"}), @@ -250,7 +250,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts4))), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts4))), compareHistogram(2500, 5000, []float64{0.05, 0.5, 1}, []uint64{1000, 500, 500, 500}), }, @@ -265,7 +265,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts5))), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts5))), compareSummary(1000, 5000, [][]float64{{0.01, 1}, {0.9, 5}, {0.99, 8}}), }, @@ -302,7 +302,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts7))), + compareStartTimestamp(tsZero), compareTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts7))), compareDoubleValue(99), compareAttributes(map[string]string{"method": "post", "code": "200"}), @@ -310,7 +310,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme }, { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts8))), + compareStartTimestamp(tsZero), compareTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts8))), compareDoubleValue(3), compareAttributes(map[string]string{"method": "post", "code": "400"}), @@ -326,7 +326,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts9))), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts9))), compareHistogram(2400, 4950, []float64{0.05, 0.5, 1}, []uint64{900, 500, 500, 500}), }, @@ -341,7 +341,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts10))), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts10))), compareSummary(900, 4980, [][]float64{{0.01, 1}, {0.9, 6}, {0.99, 8}}), }, @@ -378,7 +378,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts7))), + compareStartTimestamp(tsZero), compareTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts12))), compareDoubleValue(100), compareAttributes(map[string]string{"method": "post", "code": "200"}), @@ -386,7 +386,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme }, { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts8))), + compareStartTimestamp(tsZero), compareTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts13))), compareDoubleValue(5), compareAttributes(map[string]string{"method": "post", "code": "400"}), @@ -402,7 +402,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts9))), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts14))), compareHistogram(2500, 5000, []float64{0.05, 0.5, 1}, []uint64{1000, 500, 500, 500}), }, @@ -417,7 +417,7 @@ func verifyHonorTimeStampsTrue(t *testing.T, td *testData, resourceMetrics []pme []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts10))), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(pcommon.NewTimestampFromTime(time.UnixMilli(ts15))), compareSummary(1000, 5000, [][]float64{{0.01, 1}, {0.9, 5}, {0.99, 8}}), }, @@ -462,7 +462,7 @@ func verifyHonorTimeStampsFalse(t *testing.T, td *testData, resourceMetrics []pm []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts1), + compareStartTimestamp(tsZero), compareTimestamp(ts1), compareDoubleValue(100), compareAttributes(map[string]string{"method": "post", "code": "200"}), @@ -470,7 +470,7 @@ func verifyHonorTimeStampsFalse(t *testing.T, td *testData, resourceMetrics []pm }, { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts1), + compareStartTimestamp(tsZero), compareTimestamp(ts1), compareDoubleValue(5), compareAttributes(map[string]string{"method": "post", "code": "400"}), @@ -486,7 +486,7 @@ func verifyHonorTimeStampsFalse(t *testing.T, td *testData, resourceMetrics []pm []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(ts1), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts1), compareHistogram(2500, 5000, []float64{0.05, 0.5, 1}, []uint64{1000, 500, 500, 500}), }, @@ -501,7 +501,7 @@ func verifyHonorTimeStampsFalse(t *testing.T, td *testData, resourceMetrics []pm []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts1), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts1), compareSummary(1000, 5000, [][]float64{{0.01, 1}, {0.9, 5}, {0.99, 8}}), }, @@ -540,7 +540,7 @@ func verifyHonorTimeStampsFalse(t *testing.T, td *testData, resourceMetrics []pm []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts2), + compareStartTimestamp(tsZero), compareTimestamp(ts2), compareDoubleValue(99), compareAttributes(map[string]string{"method": "post", "code": "200"}), @@ -548,7 +548,7 @@ func verifyHonorTimeStampsFalse(t *testing.T, td *testData, resourceMetrics []pm }, { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts2), + compareStartTimestamp(tsZero), compareTimestamp(ts2), compareDoubleValue(3), compareAttributes(map[string]string{"method": "post", "code": "400"}), @@ -564,7 +564,7 @@ func verifyHonorTimeStampsFalse(t *testing.T, td *testData, resourceMetrics []pm []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(ts2), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts2), compareHistogram(2400, 4950, []float64{0.05, 0.5, 1}, []uint64{900, 500, 500, 500}), }, @@ -579,7 +579,7 @@ func verifyHonorTimeStampsFalse(t *testing.T, td *testData, resourceMetrics []pm []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts2), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts2), compareSummary(900, 4980, [][]float64{{0.01, 1}, {0.9, 6}, {0.99, 8}}), }, diff --git a/receiver/prometheusreceiver/metrics_receiver_labels_test.go b/receiver/prometheusreceiver/metrics_receiver_labels_test.go index a04b9b8e93e90..87f5cb12a261b 100644 --- a/receiver/prometheusreceiver/metrics_receiver_labels_test.go +++ b/receiver/prometheusreceiver/metrics_receiver_labels_test.go @@ -178,7 +178,7 @@ func verifyLabelConfigTarget1(t *testing.T, td *testData, rms []pmetric.Resource []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts1), + compareStartTimestamp(tsZero), compareTimestamp(ts1), compareDoubleValue(1), compareAttributes(map[string]string{"label1": "value1", "label2": "value2"}), @@ -209,7 +209,7 @@ func verifyLabelConfigTarget1(t *testing.T, td *testData, rms []pmetric.Resource []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(ts1), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts1), compareHistogram(2500, 5000, []float64{0.1, 0.5, 1}, []uint64{1000, 500, 500, 500}), compareHistogramAttributes(map[string]string{"label1": "value1", "label2": "value2"}), @@ -225,7 +225,7 @@ func verifyLabelConfigTarget1(t *testing.T, td *testData, rms []pmetric.Resource []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts1), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts1), compareSummary(1000, 5000, [][]float64{{0.1, 1}, {0.5, 5}, {0.99, 8}}), compareSummaryAttributes(map[string]string{"label1": "value1", "label2": "value2"}), @@ -383,7 +383,7 @@ func verifyEmptyLabelValuesTarget1(t *testing.T, td *testData, rms []pmetric.Res []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(ts1), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts1), compareHistogram(2500, 5000, []float64{0.1, 0.5, 1}, []uint64{1000, 500, 500, 500}), compareHistogramAttributes(map[string]string{"id": "1"}), @@ -399,7 +399,7 @@ func verifyEmptyLabelValuesTarget1(t *testing.T, td *testData, rms []pmetric.Res []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts1), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts1), compareSummary(1000, 5000, [][]float64{{0.1, 1}, {0.5, 5}, {0.99, 8}}), compareSummaryAttributes(map[string]string{"id": "1"}), diff --git a/receiver/prometheusreceiver/metrics_receiver_non_numerical_test.go b/receiver/prometheusreceiver/metrics_receiver_non_numerical_test.go index 11564da6062c9..4296db81fe9ff 100644 --- a/receiver/prometheusreceiver/metrics_receiver_non_numerical_test.go +++ b/receiver/prometheusreceiver/metrics_receiver_non_numerical_test.go @@ -10,7 +10,6 @@ import ( "github.com/prometheus/prometheus/model/value" "github.com/stretchr/testify/assert" - "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/pmetric" ) @@ -73,18 +72,16 @@ func TestStaleNaNs(t *testing.T) { func verifyStaleNaNs(t *testing.T, td *testData, resourceMetrics []pmetric.ResourceMetrics) { verifyNumTotalScrapeResults(t, td, resourceMetrics) - metrics1 := resourceMetrics[0].ScopeMetrics().At(0).Metrics() - ts := getTS(metrics1) for i := range totalScrapes { if i%2 == 0 { - verifyStaleNaNsSuccessfulScrape(t, td, resourceMetrics[i], ts, i+1) + verifyStaleNaNsSuccessfulScrape(t, td, resourceMetrics[i], i+1) } else { - verifyStaleNaNsFailedScrape(t, td, resourceMetrics[i], ts, i+1) + verifyStaleNaNsFailedScrape(t, td, resourceMetrics[i], i+1) } } } -func verifyStaleNaNsSuccessfulScrape(t *testing.T, td *testData, resourceMetric pmetric.ResourceMetrics, startTimestamp pcommon.Timestamp, iteration int) { +func verifyStaleNaNsSuccessfulScrape(t *testing.T, td *testData, resourceMetric pmetric.ResourceMetrics, iteration int) { // m1 has 4 metrics + 5 internal scraper metrics assert.Equal(t, 9, metricsCount(resourceMetric)) wantAttributes := td.attributes // should want attribute be part of complete target or each scrape? @@ -112,7 +109,7 @@ func verifyStaleNaNsSuccessfulScrape(t *testing.T, td *testData, resourceMetric []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(startTimestamp), + compareStartTimestamp(tsZero), compareTimestamp(ts1), compareDoubleValue(100), compareAttributes(map[string]string{"method": "post", "code": "200"}), @@ -120,7 +117,7 @@ func verifyStaleNaNsSuccessfulScrape(t *testing.T, td *testData, resourceMetric }, { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(startTimestamp), + compareStartTimestamp(tsZero), compareTimestamp(ts1), compareDoubleValue(5), compareAttributes(map[string]string{"method": "post", "code": "400"}), @@ -136,7 +133,7 @@ func verifyStaleNaNsSuccessfulScrape(t *testing.T, td *testData, resourceMetric []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(startTimestamp), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts1), compareHistogram(2500, 5000, []float64{0.05, 0.5, 1}, []uint64{1000, 500, 500, 500}), }, @@ -151,7 +148,7 @@ func verifyStaleNaNsSuccessfulScrape(t *testing.T, td *testData, resourceMetric []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(startTimestamp), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts1), compareSummary(1000, 5000, [][]float64{{0.01, 1}, {0.9, 5}, {0.99, 8}}), }, @@ -163,7 +160,7 @@ func verifyStaleNaNsSuccessfulScrape(t *testing.T, td *testData, resourceMetric doCompare(t, fmt.Sprintf("validScrape-scrape-%d", iteration), wantAttributes, resourceMetric, e1) } -func verifyStaleNaNsFailedScrape(t *testing.T, td *testData, resourceMetric pmetric.ResourceMetrics, startTimestamp pcommon.Timestamp, iteration int) { +func verifyStaleNaNsFailedScrape(t *testing.T, td *testData, resourceMetric pmetric.ResourceMetrics, iteration int) { // m1 has 4 metrics + 5 internal scraper metrics assert.Equal(t, 9, metricsCount(resourceMetric)) wantAttributes := td.attributes @@ -194,14 +191,14 @@ func verifyStaleNaNsFailedScrape(t *testing.T, td *testData, resourceMetric pmet []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(startTimestamp), + compareStartTimestamp(tsZero), compareTimestamp(ts1), assertNumberPointFlagNoRecordedValue(), }, }, { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(startTimestamp), + compareStartTimestamp(tsZero), compareTimestamp(ts1), assertNumberPointFlagNoRecordedValue(), }, @@ -216,7 +213,7 @@ func verifyStaleNaNsFailedScrape(t *testing.T, td *testData, resourceMetric pmet []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(startTimestamp), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts1), assertHistogramPointFlagNoRecordedValue(), }, @@ -231,7 +228,7 @@ func verifyStaleNaNsFailedScrape(t *testing.T, td *testData, resourceMetric pmet []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(startTimestamp), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts1), assertSummaryPointFlagNoRecordedValue(), }, @@ -325,7 +322,7 @@ func verifyNormalNaNs(t *testing.T, td *testData, resourceMetrics []pmetric.Reso []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts1), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts1), compareSummary(1000, 5000, [][]float64{ {0.01, math.Float64frombits(value.NormalNaN)}, @@ -424,7 +421,7 @@ func verifyInfValues(t *testing.T, td *testData, resourceMetrics []pmetric.Resou []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts1), + compareStartTimestamp(tsZero), compareTimestamp(ts1), compareDoubleValue(math.Inf(1)), compareAttributes(map[string]string{"method": "post", "code": "200"}), @@ -440,7 +437,7 @@ func verifyInfValues(t *testing.T, td *testData, resourceMetrics []pmetric.Resou []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts1), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts1), compareSummary(1000, 5000, [][]float64{{0.01, math.Inf(1)}, {0.9, math.Inf(1)}, {0.99, math.Inf(1)}}), }, diff --git a/receiver/prometheusreceiver/metrics_receiver_test.go b/receiver/prometheusreceiver/metrics_receiver_test.go index 28fbeec6e056f..d2470571c3c6f 100644 --- a/receiver/prometheusreceiver/metrics_receiver_test.go +++ b/receiver/prometheusreceiver/metrics_receiver_test.go @@ -18,6 +18,8 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/collector/component/componenttest" "go.opentelemetry.io/collector/consumer/consumertest" + "go.opentelemetry.io/collector/featuregate" + "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/pmetric" "go.opentelemetry.io/collector/receiver/receivertest" "google.golang.org/protobuf/types/known/timestamppb" @@ -25,6 +27,8 @@ import ( "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/prometheusreceiver/internal/metadata" ) +var tsZero = pcommon.Timestamp(0) + // Test data and validation functions for all four core metrics for Prometheus Receiver. // Make sure every page has a gauge, we are relying on it to figure out the start time if needed @@ -149,7 +153,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts1), + compareStartTimestamp(tsZero), compareTimestamp(ts1), compareDoubleValue(100), compareAttributes(map[string]string{"method": "post", "code": "200"}), @@ -157,7 +161,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts1), + compareStartTimestamp(tsZero), compareTimestamp(ts1), compareDoubleValue(5), compareAttributes(map[string]string{"method": "post", "code": "400"}), @@ -173,7 +177,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(ts1), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts1), compareHistogram(2500, 5000, []float64{0.05, 0.5, 1}, []uint64{1000, 500, 500, 500}), }, @@ -188,7 +192,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts1), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts1), compareSummary(1000, 5000, [][]float64{{0.01, 1}, {0.9, 5}, {0.99, 8}}), }, @@ -227,7 +231,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts1), + compareStartTimestamp(tsZero), compareTimestamp(ts2), compareDoubleValue(199), compareAttributes(map[string]string{"method": "post", "code": "200"}), @@ -235,7 +239,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts1), + compareStartTimestamp(tsZero), compareTimestamp(ts2), compareDoubleValue(12), compareAttributes(map[string]string{"method": "post", "code": "400"}), @@ -252,7 +256,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc { histogramPointComparator: []histogramPointComparator{ // TODO: Prometheus Receiver Issue- start_timestamp are incorrect for Summary and Histogram metrics after a failed scrape (issue not yet posted on collector-contrib repo) - compareHistogramStartTimestamp(ts1), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts2), compareHistogram(2600, 5050, []float64{0.05, 0.5, 1}, []uint64{1100, 500, 500, 500}), }, @@ -268,7 +272,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc { summaryPointComparator: []summaryPointComparator{ // TODO: Prometheus Receiver Issue- start_timestamp are incorrect for Summary and Histogram metrics after a failed scrape (issue not yet posted on collector-contrib repo) - compareSummaryStartTimestamp(ts1), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts2), compareSummary(1001, 5002, [][]float64{{0.01, 1}, {0.9, 6}, {0.99, 8}}), }, @@ -307,7 +311,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc { numberPointComparator: []numberPointComparator{ // TODO: #6360 Prometheus Receiver Issue- start_timestamp should reset if the prior scrape had higher value - compareStartTimestamp(ts3), + compareStartTimestamp(tsZero), compareTimestamp(ts3), compareDoubleValue(99), compareAttributes(map[string]string{"method": "post", "code": "200"}), @@ -316,7 +320,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc { numberPointComparator: []numberPointComparator{ // TODO: #6360 Prometheus Receiver Issue- start_timestamp should reset if the prior scrape had higher value - compareStartTimestamp(ts3), + compareStartTimestamp(tsZero), compareTimestamp(ts3), compareDoubleValue(3), compareAttributes(map[string]string{"method": "post", "code": "400"}), @@ -333,7 +337,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc { histogramPointComparator: []histogramPointComparator{ // TODO: #6360 Prometheus Receiver Issue- start_timestamp should reset if the prior scrape had higher value - compareHistogramStartTimestamp(ts3), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts3), compareHistogram(2400, 4900, []float64{0.05, 0.5, 1}, []uint64{900, 500, 500, 500}), }, @@ -349,7 +353,7 @@ func verifyTarget1(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc { summaryPointComparator: []summaryPointComparator{ // TODO: #6360 Prometheus Receiver Issue- start_timestamp should reset if the prior scrape had higher value - compareSummaryStartTimestamp(ts3), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts3), compareSummary(900, 4900, [][]float64{{0.01, 1}, {0.9, 4}, {0.99, 6}}), }, @@ -583,7 +587,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(ts1), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts1), compareHistogramAttributes(map[string]string{"method": "post", "code": "200"}), compareHistogram(10, 7, []float64{1}, []uint64{8, 2}), @@ -591,7 +595,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(ts1), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts1), compareHistogramAttributes(map[string]string{"method": "post", "code": "400"}), compareHistogram(50, 25, []float64{1}, []uint64{30, 20}), @@ -607,7 +611,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts1), + compareStartTimestamp(tsZero), compareTimestamp(ts1), compareDoubleValue(10), compareAttributes(map[string]string{"method": "post", "code": "200"}), @@ -615,7 +619,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts1), + compareStartTimestamp(tsZero), compareTimestamp(ts1), compareDoubleValue(50), compareAttributes(map[string]string{"method": "post", "code": "400"}), @@ -631,7 +635,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts1), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts1), compareSummaryAttributes(map[string]string{"code": "0"}), compareSummary(50, 100, [][]float64{{0.5, 47}}), @@ -639,7 +643,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts1), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts1), compareSummaryAttributes(map[string]string{"code": "5"}), compareSummary(400, 180, [][]float64{{0.5, 35}}), @@ -679,7 +683,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(ts1), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts2), compareHistogramAttributes(map[string]string{"method": "post", "code": "200"}), compareHistogram(50, 43, []float64{1}, []uint64{40, 10}), @@ -687,7 +691,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(ts2), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts2), compareHistogramAttributes(map[string]string{"method": "post", "code": "300"}), compareHistogram(3, 2, []float64{1}, []uint64{3, 0}), @@ -695,7 +699,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(ts1), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts2), compareHistogramAttributes(map[string]string{"method": "post", "code": "400"}), compareHistogram(60, 30, []float64{1}, []uint64{35, 25}), @@ -711,7 +715,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts1), + compareStartTimestamp(tsZero), compareTimestamp(ts2), compareDoubleValue(50), compareAttributes(map[string]string{"method": "post", "code": "200"}), @@ -719,7 +723,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts2), + compareStartTimestamp(tsZero), compareTimestamp(ts2), compareDoubleValue(3), compareAttributes(map[string]string{"method": "post", "code": "300"}), @@ -727,7 +731,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts1), + compareStartTimestamp(tsZero), compareTimestamp(ts2), compareDoubleValue(60), compareAttributes(map[string]string{"method": "post", "code": "400"}), @@ -743,7 +747,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts1), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts2), compareSummaryAttributes(map[string]string{"code": "0"}), compareSummary(60, 110, [][]float64{{0.5, 57}}), @@ -751,7 +755,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts2), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts2), compareSummaryAttributes(map[string]string{"code": "3"}), compareSummary(30, 50, [][]float64{{0.5, 42}}), @@ -759,7 +763,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts1), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts2), compareSummaryAttributes(map[string]string{"code": "5"}), compareSummary(410, 190, [][]float64{{0.5, 45}}), @@ -799,7 +803,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(ts1), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts3), compareHistogramAttributes(map[string]string{"method": "post", "code": "200"}), compareHistogram(50, 43, []float64{1}, []uint64{40, 10}), @@ -807,7 +811,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(ts2), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts3), compareHistogramAttributes(map[string]string{"method": "post", "code": "300"}), compareHistogram(5, 7, []float64{1}, []uint64{3, 2}), @@ -815,7 +819,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(ts1), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts3), compareHistogramAttributes(map[string]string{"method": "post", "code": "400"}), compareHistogram(60, 30, []float64{1}, []uint64{35, 25}), @@ -831,7 +835,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts1), + compareStartTimestamp(tsZero), compareTimestamp(ts3), compareDoubleValue(50), compareAttributes(map[string]string{"method": "post", "code": "200"}), @@ -839,7 +843,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts2), + compareStartTimestamp(tsZero), compareTimestamp(ts3), compareDoubleValue(5), compareAttributes(map[string]string{"method": "post", "code": "300"}), @@ -847,7 +851,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts1), + compareStartTimestamp(tsZero), compareTimestamp(ts3), compareDoubleValue(60), compareAttributes(map[string]string{"method": "post", "code": "400"}), @@ -863,7 +867,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts1), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts3), compareSummaryAttributes(map[string]string{"code": "0"}), compareSummary(70, 120, [][]float64{{0.5, 67}}), @@ -871,7 +875,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts2), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts3), compareSummaryAttributes(map[string]string{"code": "3"}), compareSummary(40, 60, [][]float64{{0.5, 52}}), @@ -879,7 +883,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts1), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts3), compareSummaryAttributes(map[string]string{"code": "5"}), compareSummary(420, 200, [][]float64{{0.5, 55}}), @@ -919,7 +923,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(ts4), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts4), compareHistogramAttributes(map[string]string{"method": "post", "code": "200"}), compareHistogram(49, 42, []float64{1}, []uint64{40, 9}), @@ -927,7 +931,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(ts4), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts4), compareHistogramAttributes(map[string]string{"method": "post", "code": "300"}), compareHistogram(3, 4, []float64{1}, []uint64{2, 1}), @@ -935,7 +939,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(ts4), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts4), compareHistogramAttributes(map[string]string{"method": "post", "code": "400"}), compareHistogram(59, 29, []float64{1}, []uint64{34, 25}), @@ -951,7 +955,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts4), + compareStartTimestamp(tsZero), compareTimestamp(ts4), compareDoubleValue(49), compareAttributes(map[string]string{"method": "post", "code": "200"}), @@ -959,7 +963,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts4), + compareStartTimestamp(tsZero), compareTimestamp(ts4), compareDoubleValue(3), compareAttributes(map[string]string{"method": "post", "code": "300"}), @@ -967,7 +971,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts4), + compareStartTimestamp(tsZero), compareTimestamp(ts4), compareDoubleValue(59), compareAttributes(map[string]string{"method": "post", "code": "400"}), @@ -983,7 +987,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts4), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts4), compareSummaryAttributes(map[string]string{"code": "0"}), compareSummary(69, 119, [][]float64{{0.5, 66}}), @@ -991,7 +995,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts4), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts4), compareSummaryAttributes(map[string]string{"code": "3"}), compareSummary(39, 59, [][]float64{{0.5, 51}}), @@ -999,7 +1003,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts4), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts4), compareSummaryAttributes(map[string]string{"code": "5"}), compareSummary(419, 199, [][]float64{{0.5, 54}}), @@ -1039,7 +1043,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(ts4), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts5), compareHistogramAttributes(map[string]string{"method": "post", "code": "200"}), compareHistogram(50, 43, []float64{1}, []uint64{41, 9}), @@ -1047,7 +1051,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(ts4), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts5), compareHistogramAttributes(map[string]string{"method": "post", "code": "300"}), compareHistogram(5, 4, []float64{1}, []uint64{4, 1}), @@ -1055,7 +1059,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(ts4), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts5), compareHistogramAttributes(map[string]string{"method": "post", "code": "400"}), compareHistogram(59, 29, []float64{1}, []uint64{34, 25}), @@ -1071,7 +1075,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts4), + compareStartTimestamp(tsZero), compareTimestamp(ts5), compareDoubleValue(50), compareAttributes(map[string]string{"method": "post", "code": "200"}), @@ -1079,7 +1083,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts4), + compareStartTimestamp(tsZero), compareTimestamp(ts5), compareDoubleValue(5), compareAttributes(map[string]string{"method": "post", "code": "300"}), @@ -1087,7 +1091,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { numberPointComparator: []numberPointComparator{ - compareStartTimestamp(ts4), + compareStartTimestamp(tsZero), compareTimestamp(ts5), compareDoubleValue(59), compareAttributes(map[string]string{"method": "post", "code": "400"}), @@ -1103,7 +1107,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts4), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts5), compareSummaryAttributes(map[string]string{"code": "0"}), compareSummary(79, 129, [][]float64{{0.5, 76}}), @@ -1111,7 +1115,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts4), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts5), compareSummaryAttributes(map[string]string{"code": "3"}), compareSummary(49, 69, [][]float64{{0.5, 61}}), @@ -1119,7 +1123,7 @@ func verifyTarget2(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts4), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts5), compareSummaryAttributes(map[string]string{"code": "5"}), compareSummary(429, 209, [][]float64{{0.5, 64}}), @@ -1245,7 +1249,7 @@ func verifyTarget3(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(ts1), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts1), compareHistogram(13003, 50000, []float64{0.2, 0.5, 1}, []uint64{10000, 1000, 1001, 1002}), }, @@ -1260,7 +1264,7 @@ func verifyTarget3(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(ts1), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts1), compareHistogram(10, 100, nil, []uint64{10}), }, @@ -1275,7 +1279,7 @@ func verifyTarget3(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts1), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts1), compareSummaryAttributes(map[string]string{"foo": "bar"}), compareSummary(900, 8000, [][]float64{{0.01, 31}, {0.05, 35}, {0.5, 47}, {0.9, 70}, {0.99, 76}}), @@ -1283,7 +1287,7 @@ func verifyTarget3(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts1), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts1), compareSummaryAttributes(map[string]string{"foo": "no_quantile"}), compareSummary(50, 100, [][]float64{}), @@ -1323,7 +1327,7 @@ func verifyTarget3(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(ts1), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts2), compareHistogram(14003, 50100, []float64{0.2, 0.5, 1}, []uint64{11000, 1000, 1001, 1002}), }, @@ -1338,7 +1342,7 @@ func verifyTarget3(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { histogramPointComparator: []histogramPointComparator{ - compareHistogramStartTimestamp(ts1), + compareHistogramStartTimestamp(tsZero), compareHistogramTimestamp(ts2), compareHistogram(15, 101, nil, []uint64{15}), }, @@ -1353,7 +1357,7 @@ func verifyTarget3(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc []dataPointExpectation{ { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts1), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts2), compareSummaryAttributes(map[string]string{"foo": "bar"}), compareSummary(950, 8100, [][]float64{{0.01, 32}, {0.05, 35}, {0.5, 47}, {0.9, 70}, {0.99, 77}}), @@ -1361,7 +1365,7 @@ func verifyTarget3(t *testing.T, td *testData, resourceMetrics []pmetric.Resourc }, { summaryPointComparator: []summaryPointComparator{ - compareSummaryStartTimestamp(ts1), + compareSummaryStartTimestamp(tsZero), compareSummaryTimestamp(ts2), compareSummaryAttributes(map[string]string{"foo": "no_quantile"}), compareSummary(55, 101, [][]float64{}), @@ -1541,6 +1545,11 @@ func verifyStartTimeMetricPage(t *testing.T, td *testData, result []pmetric.Reso // TestStartTimeMetric validates that timeseries have start time set to 'process_start_time_seconds' func TestStartTimeMetric(t *testing.T) { + err := featuregate.GlobalRegistry().Set("receiver.prometheusreceiver.RemoveStartTimeAdjustment", false) + require.NoError(t, err) + defer func() { + _ = featuregate.GlobalRegistry().Set("receiver.prometheusreceiver.RemoveStartTimeAdjustment", true) + }() targets := []*testData{ { name: "target1", diff --git a/receiver/prometheusreceiver/metrics_reciever_metric_rename_test.go b/receiver/prometheusreceiver/metrics_reciever_metric_rename_test.go index 3f9cd5ed301ec..a52e07d413c3d 100644 --- a/receiver/prometheusreceiver/metrics_reciever_metric_rename_test.go +++ b/receiver/prometheusreceiver/metrics_reciever_metric_rename_test.go @@ -185,7 +185,6 @@ func verifyRenameMetricKeepAction(t *testing.T, td *testData, resourceMetrics [] { numberPointComparator: []numberPointComparator{ compareTimestamp(ts1), - compareStartTimestamp(ts1), compareDoubleValue(100), compareAttributes(map[string]string{"method": "post", "port": "6380"}), },