Skip to content

Commit

Permalink
[exporter/prometheusremotewrite] change feature gate to stable (#37399)
Browse files Browse the repository at this point in the history
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

* Change
`exporter.prometheusremotewriteexporter.deprecateCreatedMetric`feature
gate from Beta to Stable
* Adapt some test cases that were considering this feature as disable

<!-- Issue number (e.g. #1234) or full URL to issue, if applicable. -->
#### Link to tracking issue


#35003
  • Loading branch information
perebaj authored Jan 24, 2025
1 parent 0abff4c commit 1d9f279
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 41 deletions.
27 changes: 27 additions & 0 deletions .chloggen/deprecate-created-metric-beta2stable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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. filelogreceiver)
component: exporter/prometheusremotewrite

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Change `exporter.prometheusremotewriteexporter.deprecateCreatedMetric` feature gate from Beta to Stable version.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [35003]

# (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: The `export_created_metric` configuration parameter is now permanently deprecated.

# 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: [user]
3 changes: 2 additions & 1 deletion pkg/translator/prometheusremotewrite/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ const (

var exportCreatedMetricGate = featuregate.GlobalRegistry().MustRegister(
"exporter.prometheusremotewriteexporter.deprecateCreatedMetric",
featuregate.StageBeta,
featuregate.StageStable,
featuregate.WithRegisterDescription("Feature gate used to control the deprecation of created metrics."),
featuregate.WithRegisterReferenceURL("https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/35003"),
featuregate.WithRegisterToVersion("v0.118.0"),
)

type bucketBoundsData struct {
Expand Down
54 changes: 14 additions & 40 deletions pkg/translator/prometheusremotewrite/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -697,14 +697,12 @@ func TestMostRecentTimestampInMetric(t *testing.T) {
func TestPrometheusConverter_AddSummaryDataPoints(t *testing.T) {
ts := pcommon.Timestamp(time.Now().UnixNano())
tests := []struct {
name string
isGateEnabled bool
metric func() pmetric.Metric
want func() map[uint64]*prompb.TimeSeries
name string
metric func() pmetric.Metric
want func() map[uint64]*prompb.TimeSeries
}{
{
name: "summary with start time",
isGateEnabled: false,
name: "summary with start time",
metric: func() pmetric.Metric {
metric := pmetric.NewMetric()
metric.SetName("test_summary")
Expand All @@ -720,9 +718,6 @@ func TestPrometheusConverter_AddSummaryDataPoints(t *testing.T) {
labels := []prompb.Label{
{Name: model.MetricNameLabel, Value: "test_summary" + countStr},
}
createdLabels := []prompb.Label{
{Name: model.MetricNameLabel, Value: "test_summary" + createdSuffix},
}
sumLabels := []prompb.Label{
{Name: model.MetricNameLabel, Value: "test_summary" + sumStr},
}
Expand All @@ -739,18 +734,11 @@ func TestPrometheusConverter_AddSummaryDataPoints(t *testing.T) {
{Value: 0, Timestamp: convertTimeStamp(ts)},
},
},
timeSeriesSignature(createdLabels): {
Labels: createdLabels,
Samples: []prompb.Sample{
{Value: float64(convertTimeStamp(ts)), Timestamp: convertTimeStamp(ts)},
},
},
}
},
},
{
name: "summary without start time",
isGateEnabled: false,
name: "summary without start time",
metric: func() pmetric.Metric {
metric := pmetric.NewMetric()
metric.SetName("test_summary")
Expand Down Expand Up @@ -785,8 +773,7 @@ func TestPrometheusConverter_AddSummaryDataPoints(t *testing.T) {
},
},
{
name: "summary with exportCreatedMetricGate enabled",
isGateEnabled: true,
name: "summary with exportCreatedMetricGate enabled",
metric: func() pmetric.Metric {
metric := pmetric.NewMetric()
metric.SetName("test_summary")
Expand Down Expand Up @@ -825,7 +812,7 @@ func TestPrometheusConverter_AddSummaryDataPoints(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
oldValue := exportCreatedMetricGate.IsEnabled()
testutil.SetFeatureGateForTest(t, exportCreatedMetricGate, tt.isGateEnabled)
testutil.SetFeatureGateForTest(t, exportCreatedMetricGate, true)
defer testutil.SetFeatureGateForTest(t, exportCreatedMetricGate, oldValue)

metric := tt.metric()
Expand All @@ -849,14 +836,12 @@ func TestPrometheusConverter_AddSummaryDataPoints(t *testing.T) {
func TestPrometheusConverter_AddHistogramDataPoints(t *testing.T) {
ts := pcommon.Timestamp(time.Now().UnixNano())
tests := []struct {
name string
isGateEnabled bool
metric func() pmetric.Metric
want func() map[uint64]*prompb.TimeSeries
name string
metric func() pmetric.Metric
want func() map[uint64]*prompb.TimeSeries
}{
{
name: "histogram with start time",
isGateEnabled: false,
name: "histogram with start time",
metric: func() pmetric.Metric {
metric := pmetric.NewMetric()
metric.SetName("test_hist")
Expand All @@ -872,9 +857,6 @@ func TestPrometheusConverter_AddHistogramDataPoints(t *testing.T) {
labels := []prompb.Label{
{Name: model.MetricNameLabel, Value: "test_hist" + countStr},
}
createdLabels := []prompb.Label{
{Name: model.MetricNameLabel, Value: "test_hist" + createdSuffix},
}
infLabels := []prompb.Label{
{Name: model.MetricNameLabel, Value: "test_hist_bucket"},
{Name: model.BucketLabel, Value: "+Inf"},
Expand All @@ -892,18 +874,11 @@ func TestPrometheusConverter_AddHistogramDataPoints(t *testing.T) {
{Value: 0, Timestamp: convertTimeStamp(ts)},
},
},
timeSeriesSignature(createdLabels): {
Labels: createdLabels,
Samples: []prompb.Sample{
{Value: float64(convertTimeStamp(ts)), Timestamp: convertTimeStamp(ts)},
},
},
}
},
},
{
name: "histogram without start time",
isGateEnabled: false,
name: "histogram without start time",
metric: func() pmetric.Metric {
metric := pmetric.NewMetric()
metric.SetName("test_hist")
Expand Down Expand Up @@ -939,8 +914,7 @@ func TestPrometheusConverter_AddHistogramDataPoints(t *testing.T) {
},
},
{
name: "histogram with exportCreatedMetricGate enabled",
isGateEnabled: true,
name: "histogram with exportCreatedMetricGate enabled",
metric: func() pmetric.Metric {
metric := pmetric.NewMetric()
metric.SetName("test_hist")
Expand Down Expand Up @@ -980,7 +954,7 @@ func TestPrometheusConverter_AddHistogramDataPoints(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
oldValue := exportCreatedMetricGate.IsEnabled()
testutil.SetFeatureGateForTest(t, exportCreatedMetricGate, tt.isGateEnabled)
testutil.SetFeatureGateForTest(t, exportCreatedMetricGate, true)
defer testutil.SetFeatureGateForTest(t, exportCreatedMetricGate, oldValue)

metric := tt.metric()
Expand Down

0 comments on commit 1d9f279

Please sign in to comment.