Skip to content

Conversation

@perebaj
Copy link
Contributor

@perebaj perebaj commented Dec 9, 2025

Description

Promote feature flag removeStartTimeAdjustment to Stable

Link to tracking issue

Fixes #44180

Signed-off-by: perebaj <perebaj@gmail.com>
Signed-off-by: perebaj <perebaj@gmail.com>
Signed-off-by: perebaj <perebaj@gmail.com>
Signed-off-by: perebaj <perebaj@gmail.com>
Comment on lines -1546 to -1566
// 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",
pages: []mockPrometheusResponse{
{code: 200, data: startTimeMetricPage},
},
validateFunc: verifyStartTimeMetricPage,
},
}
testComponent(t, targets, func(c *Config) {
c.UseStartTimeMetric = true
})
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that test makes sense for the current statement? I don't think so...

This function expects the receiver to adjust the StartTimestamp from process_start_time_seconds

Defined here -> https://github.com/perebaj/opentelemetry-collector-contrib/blob/849b9ec53a4fa0f5195e2bb2f3e7e58ae04e9506/receiver/prometheusreceiver/metrics_receiver_test.go#L1545

After receiver.prometheusreceiver.RemoveStartTimeAdjustment was promoted to stable, the transaction production flow does:

if !removeStartTimeAdjustment.IsEnabled() {    
         // only here would it call the adjuster (including the StartTimeMetricAdjuster)
t.metricAdjuster.AdjustMetrics(md)}

Since the gate is stable, it is always enabled and cannot be turned off; then this block never runs and no start time adjustment is made, even with UseStartTimeMetric = true.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, you can remove this test.

@perebaj perebaj marked this pull request as ready for review December 9, 2025 17:06
@perebaj perebaj requested review from a team, ArthurSens and dashpole as code owners December 9, 2025 17:06
@github-actions github-actions bot added the receiver/prometheus Prometheus receiver label Dec 9, 2025
Copy link
Member

@ArthurSens ArthurSens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going through the changes and realized I have different expectations for a stable feature gate.

I thought that meant we could delete the codebase related to the metrics adjuster because a stable feature gate will never decrease its stability. I'm wondering if my expectations are correct or if we need to keep that code around for some reason 🤔

"go.opentelemetry.io/collector/pdata/pmetric"
semconv "go.opentelemetry.io/otel/semconv/v1.27.0"
"go.uber.org/zap"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're removing metrics adjuster, should we even keep this file? If I understand it correctly it's only testing starttimeadjuster

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}

func (stma *startTimeMetricAdjuster) AdjustMetrics(metrics pmetric.Metrics) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we delete this whole codebase?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 264 to 269
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)
})
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tests when the adjuster fails. Shouldn't we delete this test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks!

removed here ->
80d0584

Signed-off-by: perebaj <perebaj@gmail.com>
Comment on lines -40 to -52
useCreatedMetric bool,
enableNativeHistograms bool,
useMetadata bool,
externalLabels labels.Labels,
trimSuffixes bool,
) (storage.Appendable, error) {
var metricAdjuster MetricsAdjuster
if !useStartTimeMetric {
metricAdjuster = NewInitialPointAdjuster(set.Logger, gcInterval, useCreatedMetric)
} else {
metricAdjuster = NewStartTimeMetricAdjuster(set.Logger, startTimeMetricRegex, gcInterval)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we don't need of this code anymore, the feature
var useCreatedMetricGate = featuregate.GlobalRegistry().MustRegister can be removed. But I don't know if should I remove it or just omit the var declaration, as I did here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// This file implements config for Prometheus receiver.
var useCreatedMetricGate = featuregate.GlobalRegistry().MustRegister(
var _ = featuregate.GlobalRegistry().MustRegister(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we remove this feature gate, or this should be done in a different PR? We are basically deprecating the necessity to use it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in a different PR I think. I believe you should use featuregate.WithRegisterToVersion, with a version a few releases in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, wait. I didn't realize this isn't a different feature gate. This is unrelated to this PR. Please make the change to the created timestamp gate in a new PR if thats ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but is it ok to leave var definition as I did? ⬇️

var _ = featuregate.GlobalRegistry().MustRegister(

With that, I think that we are basically deprecating the variable, because we aren't using it anymore

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I see. This is a sub-feature of the metrics adjuster.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final update, I promise :). You should set this to featuregate.StageDeprecated, and add WithRegisterToVersion, but leave it around.

Please also add to the release notes that this disables the created metric feature gate. However, this does not mean that the _created series is always ignored. Prometheus parses the _created series as the start timestamp, but only when using OpenMetrics 1.0. So this change is removing support for the _created series only from other scrape protocols.

Signed-off-by: perebaj <perebaj@gmail.com>
Signed-off-by: perebaj <perebaj@gmail.com>
@dashpole
Copy link
Contributor

@ArthurSens the stable gate can't be disabled, so it is OK to remove code: https://github.com/open-telemetry/opentelemetry-collector/blob/main/featuregate/README.md#feature-lifecycle

A generally available or stable stage where the feature is permanently enabled.

Copy link
Member

@ArthurSens ArthurSens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just need to resolve the conflicts :)

Always good seeing this 😁
image

@perebaj
Copy link
Contributor Author

perebaj commented Dec 12, 2025

isn't better to wait for this PR here?

I think that it will add more conflicts 🫠

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PrometheusReceiver Configuration - Deprecate and remove UseStartTimeMetric and StartTimeMetricRegex

4 participants