Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[exporter/prometheusremotewrite] deprecate export_created_metric #36214

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

pokgak
Copy link

@pokgak pokgak commented Nov 5, 2024

Description

Deprecate export_created_metric config option

Link to tracking issue

Fixes #35003

Copy link

linux-foundation-easycla bot commented Nov 5, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

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.

Thank you @pokgak!

Not sure if this is documented well, but when deprecating we can put the functionality behind a feature gate that is enabled by default. One example of feature gate can be seen here. In the example though the stability is StageAlpha (disabled by default) and we want it to considered StageBeta so it's enabled by default.

In version 0.114.0 we'll finally change it to Alpha and in 0.115.0 finally remove the option.

.chloggen/35003-deprecate-export_created_metric.yaml Outdated Show resolved Hide resolved
exporter/prometheusremotewriteexporter/config.go Outdated Show resolved Hide resolved
exporter/prometheusremotewriteexporter/README.md Outdated Show resolved Hide resolved
@pokgak
Copy link
Author

pokgak commented Nov 7, 2024

@ArthurSens correct me if I'm wrong but isn't the feature already disabled by default so we should be using StageAlpha instead?

if cfg.CreatedMetric == nil {
cfg.CreatedMetric = &CreatedMetric{
Enabled: false,
}
}

I pushed a commit using StageBeta but note that this will change the default value of the export_created_metric.enabled to true.

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.

@ArthurSens correct me if I'm wrong but isn't the feature already disabled by default so we should be using StageAlpha instead?

if cfg.CreatedMetric == nil {
cfg.CreatedMetric = &CreatedMetric{
Enabled: false,
}
}

I pushed a commit using StageBeta but note that this will change the default value of the export_created_metric.enabled to true.

Yes you're correct, I believe I wasn't clear with my previous comment, let me re-phrase it.

What we want to do is add yet another check when we're generating the created metric.

if settings.ExportCreatedMetric && startTimestamp != 0 {
labels := createLabels(baseName+createdSuffix, baseLabels)
c.addTimeSeriesIfNeeded(labels, startTimestamp, pt.Timestamp())
}

Here we'd switch to:

 if settings.ExportCreatedMetric && startTimestamp != 0 && exportCreatedMetricGate.IsEnabled() { 
 	labels := createLabels(baseName+createdSuffix, baseLabels) 
 	c.addTimeSeriesIfNeeded(labels, startTimestamp, pt.Timestamp()) 
 } 

And then we'll have to update one test to make sure the feature-gate works as expected:

Add a new boolean to the test case struct, and in the the Run you can add:

oldValue := exportCreatedMetricGate.IsEnabled()
testutil.SetFeatureGateForTest(t, exportCreatedMetricGate, tt.isGateEnabled)
defer testutil.SetFeatureGateForTest(t, exportCreatedMetricGate, oldValue)

exporter/prometheusremotewriteexporter/config.go Outdated Show resolved Hide resolved
exporter/prometheusremotewriteexporter/config.go Outdated Show resolved Hide resolved
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, thank you!

Could a maintainer take a look and trigger CI?

@ArthurSens
Copy link
Member

Actually, @pokgak could you rebase your PR on top of main? It looks like you've got some merge conflicts

@pokgak
Copy link
Author

pokgak commented Nov 8, 2024

@ArthurSens thanks for the detailed steps.

In case you're reviewing this already, I only followed based on your steps for now. I think I need to also add test case for when the feature gate is false to make sure it's working correctly but haven't had time yet will do it tomorrow.

@ArthurSens
Copy link
Member

@ArthurSens thanks for the detailed steps.

In case you're reviewing this already, I only followed based on your steps for now. I think I need to also add test case for when the feature gate is false to make sure it's working correctly but haven't had time yet will do it tomorrow.

That makes perfect sense, I'm glad you brought it up!

@pokgak pokgak force-pushed the exporter/prometheusremotewriteexporter/deprecate-created-metric branch from 964ef73 to f11490c Compare November 9, 2024 05:54
@pokgak
Copy link
Author

pokgak commented Nov 9, 2024

@ArthurSens I added the test case and rebased to main. Also updated another test TestPrometheusConverter_AddSummaryDataPoints since it uses the exportCreatedMetric config option too. Should be ready for review again.

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.

Thanks!

@pokgak pokgak requested a review from dashpole November 13, 2024 17:30
@pokgak
Copy link
Author

pokgak commented Nov 13, 2024

@dashpole i changed the default feature gate stage to alpha and updated the code and tests accordingly.

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.

Thank again!

@dashpole dashpole added ready to merge Code review completed; ready to merge by maintainers and removed ready to merge Code review completed; ready to merge by maintainers labels Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exporter/prometheusremotewrite pkg/translator/prometheus ready to merge Code review completed; ready to merge by maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[exporter/prometheusremotewriteexporter] Deprecate and Remove export_created_metric feature.
4 participants