Skip to content

Commit f760fe1

Browse files
authored
[exporter/prometheusremotewrite] remove export_created_metric (#38662)
#### Description Removing `export_created_metric` per note in README. See #35003 for reference.
1 parent b6e1b36 commit f760fe1

19 files changed

+57
-160
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: breaking
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: prometheusremotewriteexporter
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Remove `export_created_metric` config option
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [35003]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: []

exporter/prometheusremotewriteexporter/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ The following settings can be optionally configured:
5959
- `enabled` (default = false): If `enabled` is `true`, all the resource attributes will be converted to metric labels by default.
6060
- `target_info`: customize `target_info` metric
6161
- `enabled` (default = true): If `enabled` is `true`, a `target_info` metric will be generated for each resource metric (see https://github.com/open-telemetry/opentelemetry-specification/pull/2381).
62-
- `export_created_metric`: `WARNING` Deprecated and planned for removal in v0.116.0. See [related issue](https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/35003) for more information.
63-
- `enabled` (default = false): If `enabled` is `true`, a `_created` metric is
64-
exported for Summary, Histogram, and Monotonic Sum metric points if
65-
`StartTimeUnixNano` is set.
6662
- `max_batch_size_bytes` (default = `3000000` -> `~2.861 mb`): Maximum size of a batch of
6763
samples to be sent to the remote write endpoint. If the batch size is larger
6864
than this value, it will be split into multiple batches.

exporter/prometheusremotewriteexporter/config.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ type Config struct {
4747
// TargetInfo allows customizing the target_info metric
4848
TargetInfo *TargetInfo `mapstructure:"target_info,omitempty"`
4949

50-
// CreatedMetric allows customizing creation of _created metrics
51-
// Deprecated[0.114.0]: The feature doesn't provide the expected behavior. Use Prometheus remote-write v2 to enable sending Created Timestamps.
52-
// This feature is planned to be removed in v0.116.0
53-
CreatedMetric *CreatedMetric `mapstructure:"export_created_metric,omitempty"`
54-
5550
// AddMetricSuffixes controls whether unit and type suffixes are added to metrics on export
5651
AddMetricSuffixes bool `mapstructure:"add_metric_suffixes"`
5752

@@ -111,11 +106,6 @@ func (cfg *Config) Validate() error {
111106
Enabled: true,
112107
}
113108
}
114-
if cfg.CreatedMetric == nil {
115-
cfg.CreatedMetric = &CreatedMetric{
116-
Enabled: false,
117-
}
118-
}
119109
if cfg.MaxBatchSizeBytes < 0 {
120110
return fmt.Errorf("max_batch_byte_size must be greater than 0")
121111
}

exporter/prometheusremotewriteexporter/config_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ func TestLoadConfig(t *testing.T) {
8181
TargetInfo: &TargetInfo{
8282
Enabled: true,
8383
},
84-
CreatedMetric: &CreatedMetric{Enabled: true},
8584
},
8685
},
8786
{

exporter/prometheusremotewriteexporter/exporter.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,21 +158,16 @@ func newPRWExporter(cfg *Config, set exporter.Settings) (*prwExporter, error) {
158158
retrySettings: cfg.BackOffConfig,
159159
retryOnHTTP429: retryOn429FeatureGate.IsEnabled(),
160160
exporterSettings: prometheusremotewrite.Settings{
161-
Namespace: cfg.Namespace,
162-
ExternalLabels: sanitizedLabels,
163-
DisableTargetInfo: !cfg.TargetInfo.Enabled,
164-
ExportCreatedMetric: cfg.CreatedMetric.Enabled,
165-
AddMetricSuffixes: cfg.AddMetricSuffixes,
166-
SendMetadata: cfg.SendMetadata,
161+
Namespace: cfg.Namespace,
162+
ExternalLabels: sanitizedLabels,
163+
DisableTargetInfo: !cfg.TargetInfo.Enabled,
164+
AddMetricSuffixes: cfg.AddMetricSuffixes,
165+
SendMetadata: cfg.SendMetadata,
167166
},
168167
telemetry: telemetry,
169168
batchStatePool: sync.Pool{New: func() any { return newBatchTimeServicesState() }},
170169
}
171170

172-
if prwe.exporterSettings.ExportCreatedMetric {
173-
prwe.settings.Logger.Warn("export_created_metric is deprecated and will be removed in a future release")
174-
}
175-
176171
prwe.wal = newWAL(cfg.WAL, prwe.export)
177172
return prwe, nil
178173
}

exporter/prometheusremotewriteexporter/exporter_concurrency_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ func Test_PushMetricsConcurrent(t *testing.T) {
109109
TargetInfo: &TargetInfo{
110110
Enabled: true,
111111
},
112-
CreatedMetric: &CreatedMetric{
113-
Enabled: false,
114-
},
115112
BackOffConfig: retrySettings,
116113
}
117114

exporter/prometheusremotewriteexporter/exporter_test.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ func Test_NewPRWExporter(t *testing.T) {
5656
TargetInfo: &TargetInfo{
5757
Enabled: true,
5858
},
59-
CreatedMetric: &CreatedMetric{
60-
Enabled: false,
61-
},
6259
}
6360
buildInfo := component.BuildInfo{
6461
Description: "OpenTelemetry Collector",
@@ -152,9 +149,6 @@ func Test_Start(t *testing.T) {
152149
TargetInfo: &TargetInfo{
153150
Enabled: true,
154151
},
155-
CreatedMetric: &CreatedMetric{
156-
Enabled: false,
157-
},
158152
}
159153
buildInfo := component.BuildInfo{
160154
Description: "OpenTelemetry Collector",
@@ -497,7 +491,7 @@ func Test_PushMetrics(t *testing.T) {
497491
name: "intSum_case",
498492
metrics: intSumBatch,
499493
reqTestFunc: checkFunc,
500-
expectedTimeSeries: 4,
494+
expectedTimeSeries: 2,
501495
httpResponseCode: http.StatusAccepted,
502496
},
503497
{
@@ -721,9 +715,6 @@ func Test_PushMetrics(t *testing.T) {
721715
TargetInfo: &TargetInfo{
722716
Enabled: true,
723717
},
724-
CreatedMetric: &CreatedMetric{
725-
Enabled: true,
726-
},
727718
BackOffConfig: retrySettings,
728719
}
729720

@@ -948,9 +939,6 @@ func TestWALOnExporterRoundTrip(t *testing.T) {
948939
TargetInfo: &TargetInfo{
949940
Enabled: true,
950941
},
951-
CreatedMetric: &CreatedMetric{
952-
Enabled: false,
953-
},
954942
}
955943

956944
set := exportertest.NewNopSettings(metadata.Type)
@@ -1309,7 +1297,6 @@ func benchmarkPushMetrics(b *testing.B, numMetrics, numConsumers int) {
13091297
RemoteWriteQueue: RemoteWriteQueue{NumConsumers: numConsumers},
13101298
BackOffConfig: retrySettings,
13111299
TargetInfo: &TargetInfo{Enabled: true},
1312-
CreatedMetric: &CreatedMetric{Enabled: false},
13131300
}
13141301
exporter, err := newPRWExporter(cfg, set)
13151302
require.NoError(b, err)

exporter/prometheusremotewriteexporter/factory.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,5 @@ func createDefaultConfig() component.Config {
116116
TargetInfo: &TargetInfo{
117117
Enabled: true,
118118
},
119-
CreatedMetric: &CreatedMetric{
120-
Enabled: false,
121-
},
122119
}
123120
}

exporter/prometheusremotewriteexporter/testdata/config.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ prometheusremotewrite/2:
2121
key2: value2
2222
resource_to_telemetry_conversion:
2323
enabled: true
24-
export_created_metric:
25-
enabled: true
2624
remote_write_queue:
2725
queue_size: 2000
2826
num_consumers: 10

exporter/prometheusremotewriteexporter/wal_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ func TestExportWithWALEnabled(t *testing.T) {
166166
WAL: &WALConfig{
167167
Directory: t.TempDir(),
168168
},
169-
TargetInfo: &TargetInfo{}, // Declared just to avoid nil pointer dereference.
170-
CreatedMetric: &CreatedMetric{}, // Declared just to avoid nil pointer dereference.
169+
TargetInfo: &TargetInfo{}, // Declared just to avoid nil pointer dereference.
171170
}
172171
buildInfo := component.BuildInfo{
173172
Description: "OpenTelemetry Collector",

pkg/translator/prometheusremotewrite/helper.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,6 @@ func (c *prometheusConverter) addHistogramDataPoints(dataPoints pmetric.Histogra
284284

285285
bucketBounds = append(bucketBounds, bucketBoundsData{ts: ts, bound: math.Inf(1)})
286286
c.addExemplars(pt, bucketBounds)
287-
288-
startTimestamp := pt.StartTimestamp()
289-
if settings.ExportCreatedMetric && startTimestamp != 0 && !exportCreatedMetricGate.IsEnabled() {
290-
labels := createLabels(baseName+createdSuffix, baseLabels)
291-
c.addTimeSeriesIfNeeded(labels, startTimestamp, pt.Timestamp())
292-
}
293287
}
294288
}
295289

@@ -440,12 +434,6 @@ func (c *prometheusConverter) addSummaryDataPoints(dataPoints pmetric.SummaryDat
440434
qtlabels := createLabels(baseName, baseLabels, quantileStr, percentileStr)
441435
c.addSample(quantile, qtlabels)
442436
}
443-
444-
startTimestamp := pt.StartTimestamp()
445-
if settings.ExportCreatedMetric && startTimestamp != 0 && !exportCreatedMetricGate.IsEnabled() {
446-
createdLabels := createLabels(baseName+createdSuffix, baseLabels)
447-
c.addTimeSeriesIfNeeded(createdLabels, startTimestamp, pt.Timestamp())
448-
}
449437
}
450438
}
451439

@@ -502,22 +490,6 @@ func (c *prometheusConverter) getOrCreateTimeSeries(lbls []prompb.Label) (*promp
502490
return ts, true
503491
}
504492

505-
// addTimeSeriesIfNeeded adds a corresponding time series if it doesn't already exist.
506-
// If the time series doesn't already exist, it gets added with startTimestamp for its value and timestamp for its timestamp,
507-
// both converted to milliseconds.
508-
func (c *prometheusConverter) addTimeSeriesIfNeeded(lbls []prompb.Label, startTimestamp pcommon.Timestamp, timestamp pcommon.Timestamp) {
509-
ts, created := c.getOrCreateTimeSeries(lbls)
510-
if created {
511-
ts.Samples = []prompb.Sample{
512-
{
513-
// convert ns to ms
514-
Value: float64(convertTimeStamp(startTimestamp)),
515-
Timestamp: convertTimeStamp(timestamp),
516-
},
517-
}
518-
}
519-
}
520-
521493
// addResourceTargetInfo converts the resource to the target info metric.
522494
func addResourceTargetInfo(resource pcommon.Resource, settings Settings, timestamp pcommon.Timestamp, converter *prometheusConverter) {
523495
if settings.DisableTargetInfo || timestamp == 0 {

pkg/translator/prometheusremotewrite/helper_test.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -862,9 +862,7 @@ func TestPrometheusConverter_AddSummaryDataPoints(t *testing.T) {
862862
converter.addSummaryDataPoints(
863863
metric.Summary().DataPoints(),
864864
pcommon.NewResource(),
865-
Settings{
866-
ExportCreatedMetric: true,
867-
},
865+
Settings{},
868866
metric.Name(),
869867
)
870868

@@ -1004,9 +1002,7 @@ func TestPrometheusConverter_AddHistogramDataPoints(t *testing.T) {
10041002
converter.addHistogramDataPoints(
10051003
metric.Histogram().DataPoints(),
10061004
pcommon.NewResource(),
1007-
Settings{
1008-
ExportCreatedMetric: true,
1009-
},
1005+
Settings{},
10101006
metric.Name(),
10111007
)
10121008

pkg/translator/prometheusremotewrite/metrics_to_prw.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ import (
1818
)
1919

2020
type Settings struct {
21-
Namespace string
22-
ExternalLabels map[string]string
23-
DisableTargetInfo bool
24-
ExportCreatedMetric bool
25-
AddMetricSuffixes bool
26-
SendMetadata bool
21+
Namespace string
22+
ExternalLabels map[string]string
23+
DisableTargetInfo bool
24+
AddMetricSuffixes bool
25+
SendMetadata bool
2726
}
2827

2928
// FromMetrics converts pmetric.Metrics to Prometheus remote write format.

pkg/translator/prometheusremotewrite/metrics_to_prw_v2.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,3 @@ func (c *prometheusConverterV2) addSample(sample *writev2.Sample, lbls []prompb.
137137
}
138138
c.unique[timeSeriesSignature(lbls)] = &ts
139139
}
140-
141-
// TODO: implement this function.
142-
func (c *prometheusConverterV2) addTimeSeriesIfNeeded(_ []prompb.Label, _ pcommon.Timestamp, _ pcommon.Timestamp) {
143-
}

pkg/translator/prometheusremotewrite/metrics_to_prw_v2_test.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ import (
1616

1717
func TestFromMetricsV2(t *testing.T) {
1818
settings := Settings{
19-
Namespace: "",
20-
ExternalLabels: nil,
21-
DisableTargetInfo: false,
22-
ExportCreatedMetric: false,
23-
AddMetricSuffixes: false,
24-
SendMetadata: false,
19+
Namespace: "",
20+
ExternalLabels: nil,
21+
DisableTargetInfo: false,
22+
AddMetricSuffixes: false,
23+
SendMetadata: false,
2524
}
2625

2726
ts := uint64(time.Now().UnixNano())

pkg/translator/prometheusremotewrite/number_data_points.go

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (c *prometheusConverter) addGaugeNumberDataPoints(dataPoints pmetric.Number
4545
}
4646

4747
func (c *prometheusConverter) addSumNumberDataPoints(dataPoints pmetric.NumberDataPointSlice,
48-
resource pcommon.Resource, metric pmetric.Metric, settings Settings, name string,
48+
resource pcommon.Resource, _ pmetric.Metric, settings Settings, name string,
4949
) {
5050
for x := 0; x < dataPoints.Len(); x++ {
5151
pt := dataPoints.At(x)
@@ -76,23 +76,5 @@ func (c *prometheusConverter) addSumNumberDataPoints(dataPoints pmetric.NumberDa
7676
exemplars := getPromExemplars[pmetric.NumberDataPoint](pt)
7777
ts.Exemplars = append(ts.Exemplars, exemplars...)
7878
}
79-
80-
// add created time series if needed
81-
if settings.ExportCreatedMetric && metric.Sum().IsMonotonic() {
82-
startTimestamp := pt.StartTimestamp()
83-
if startTimestamp == 0 {
84-
return
85-
}
86-
87-
createdLabels := make([]prompb.Label, len(lbls))
88-
copy(createdLabels, lbls)
89-
for i, l := range createdLabels {
90-
if l.Name == model.MetricNameLabel {
91-
createdLabels[i].Value = name + createdSuffix
92-
break
93-
}
94-
}
95-
c.addTimeSeriesIfNeeded(createdLabels, startTimestamp, pt.Timestamp())
96-
}
9779
}
9880
}

pkg/translator/prometheusremotewrite/number_data_points_test.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,22 +149,13 @@ func TestPrometheusConverter_addSumNumberDataPoints(t *testing.T) {
149149
labels := []prompb.Label{
150150
{Name: model.MetricNameLabel, Value: "test_sum"},
151151
}
152-
createdLabels := []prompb.Label{
153-
{Name: model.MetricNameLabel, Value: "test_sum" + createdSuffix},
154-
}
155152
return map[uint64]*prompb.TimeSeries{
156153
timeSeriesSignature(labels): {
157154
Labels: labels,
158155
Samples: []prompb.Sample{
159156
{Value: 1, Timestamp: convertTimeStamp(ts)},
160157
},
161158
},
162-
timeSeriesSignature(createdLabels): {
163-
Labels: createdLabels,
164-
Samples: []prompb.Sample{
165-
{Value: float64(convertTimeStamp(ts)), Timestamp: convertTimeStamp(ts)},
166-
},
167-
},
168159
}
169160
},
170161
},
@@ -232,7 +223,7 @@ func TestPrometheusConverter_addSumNumberDataPoints(t *testing.T) {
232223
metric.Sum().DataPoints(),
233224
pcommon.NewResource(),
234225
metric,
235-
Settings{ExportCreatedMetric: true},
226+
Settings{},
236227
metric.Name(),
237228
)
238229

0 commit comments

Comments
 (0)