Skip to content

Commit

Permalink
[processor/cumulativetodelta] Remove deprecated Metrics config option (
Browse files Browse the repository at this point in the history
…#12732)

* Remove deprecated Metrics config option

* Update README

* Add changelog entry
  • Loading branch information
TylerHelmuth authored Aug 2, 2022
1 parent 8b6aef5 commit ba325a3
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 92 deletions.
1 change: 0 additions & 1 deletion processor/cumulativetodeltaprocessor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ The following settings can be optionally configured:
- `include`: List of metrics names or patterns to convert to delta.
- `exclude`: List of metrics names or patterns to not convert to delta. **If a metric name matches both include and exclude, exclude takes precedence.**
- `max_stale`: The total time a state entry will live past the time it was last seen. Set to 0 to retain state indefinitely. Default: 0
- `metrics`: Deprecated. The processor uses metric names to identify a set of cumulative metrics and converts them to delta.

If neither include nor exclude are supplied, no filtering is applied.

Expand Down
7 changes: 0 additions & 7 deletions processor/cumulativetodeltaprocessor/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ type Config struct {
// MaxStaleness is the total time a state entry will live past the time it was last seen. Set to 0 to retain state indefinitely.
MaxStaleness time.Duration `mapstructure:"max_staleness"`

// Deprecated: List of cumulative metrics to convert to delta.
// Cannot be used with Include/Exclude.
Metrics []string `mapstructure:"metrics"`

// Include specifies a filter on the metrics that should be converted.
// Exclude specifies a filter on the metrics that should not be converted.
// If neither `include` nor `exclude` are set, all metrics will be converted.
Expand All @@ -53,9 +49,6 @@ var _ config.Processor = (*Config)(nil)
// Validate checks whether the input configuration has all of the required fields for the processor.
// An error is returned if there are any invalid inputs.
func (config *Config) Validate() error {
if len(config.Metrics) > 0 && (len(config.Include.Metrics) > 0 || len(config.Exclude.Metrics) > 0) {
return fmt.Errorf("metrics and include/exclude cannot be used at the same time")
}
if (len(config.Include.Metrics) > 0 && len(config.Include.MatchType) == 0) ||
(len(config.Exclude.Metrics) > 0 && len(config.Exclude.MatchType) == 0) {
return fmt.Errorf("match_type must be set if metrics are supplied")
Expand Down
5 changes: 0 additions & 5 deletions processor/cumulativetodeltaprocessor/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ func TestValidateConfig(t *testing.T) {
configName: "config.yaml",
succeed: true,
},
{
configName: "config_invalid_combo.yaml",
succeed: false,
errorMessage: "metrics and include/exclude cannot be used at the same time",
},
{
configName: "config_missing_match_type.yaml",
succeed: false,
Expand Down
13 changes: 0 additions & 13 deletions processor/cumulativetodeltaprocessor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
)

type cumulativeToDeltaProcessor struct {
metrics map[string]struct{}
includeFS filterset.FilterSet
excludeFS filterset.FilterSet
logger *zap.Logger
Expand All @@ -41,13 +40,6 @@ func newCumulativeToDeltaProcessor(config *Config, logger *zap.Logger) *cumulati
deltaCalculator: tracking.NewMetricTracker(ctx, logger, config.MaxStaleness),
cancelFunc: cancel,
}
if len(config.Metrics) > 0 {
p.logger.Warn("The 'metrics' configuration is deprecated. Use 'include'/'exclude' instead.")
p.metrics = make(map[string]struct{}, len(config.Metrics))
for _, m := range config.Metrics {
p.metrics[m] = struct{}{}
}
}
if len(config.Include.Metrics) > 0 {
p.includeFS, _ = filterset.CreateFilterSet(config.Include.Metrics, &config.Include.Config)
}
Expand Down Expand Up @@ -108,11 +100,6 @@ func (ctdp *cumulativeToDeltaProcessor) shutdown(context.Context) error {
}

func (ctdp *cumulativeToDeltaProcessor) shouldConvertMetric(metricName string) bool {
// Legacy support for deprecated Metrics config
if len(ctdp.metrics) > 0 {
_, ok := ctdp.metrics[metricName]
return ok
}
return (ctdp.includeFS == nil || ctdp.includeFS.Matches(metricName)) &&
(ctdp.excludeFS == nil || !ctdp.excludeFS.Matches(metricName))
}
Expand Down
37 changes: 2 additions & 35 deletions processor/cumulativetodeltaprocessor/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ type testMetric struct {

type cumulativeToDeltaTest struct {
name string
metrics []string
include MatchMetrics
exclude MatchMetrics
inMetrics pmetric.Metrics
Expand All @@ -51,36 +50,7 @@ type cumulativeToDeltaTest struct {
var (
testCases = []cumulativeToDeltaTest{
{
name: "legacy_cumulative_to_delta_one_positive",
metrics: []string{"metric_1"},
inMetrics: generateTestMetrics(testMetric{
metricNames: []string{"metric_1", "metric_2"},
metricValues: [][]float64{{100, 200, 500}, {4}},
isCumulative: []bool{true, true},
}),
outMetrics: generateTestMetrics(testMetric{
metricNames: []string{"metric_1", "metric_2"},
metricValues: [][]float64{{100, 100, 300}, {4}},
isCumulative: []bool{false, true},
}),
},
{
name: "legacy_cumulative_to_delta_nan_value",
metrics: []string{"metric_1"},
inMetrics: generateTestMetrics(testMetric{
metricNames: []string{"metric_1", "metric_2"},
metricValues: [][]float64{{100, 200, math.NaN()}, {4}},
isCumulative: []bool{true, true},
}),
outMetrics: generateTestMetrics(testMetric{
metricNames: []string{"metric_1", "metric_2"},
metricValues: [][]float64{{100, 100, math.NaN()}, {4}},
isCumulative: []bool{false, true},
}),
},
{
name: "cumulative_to_delta_convert_nothing",
metrics: nil,
name: "cumulative_to_delta_convert_nothing",
exclude: MatchMetrics{
Metrics: []string{".*"},
Config: filterset.Config{
Expand Down Expand Up @@ -140,8 +110,7 @@ var (
}),
},
{
name: "cumulative_to_delta_exclude_precedence",
metrics: nil,
name: "cumulative_to_delta_exclude_precedence",
include: MatchMetrics{
Metrics: []string{".*"},
Config: filterset.Config{
Expand Down Expand Up @@ -177,7 +146,6 @@ func TestCumulativeToDeltaProcessor(t *testing.T) {
next := new(consumertest.MetricsSink)
cfg := &Config{
ProcessorSettings: config.NewProcessorSettings(config.NewComponentID(typeStr)),
Metrics: test.metrics,
Include: test.include,
Exclude: test.exclude,
}
Expand Down Expand Up @@ -286,7 +254,6 @@ func BenchmarkConsumeMetrics(b *testing.B) {
BuildInfo: component.BuildInfo{},
}
cfg := createDefaultConfig().(*Config)
cfg.Metrics = []string{""}
p, err := createMetricsProcessor(context.Background(), params, cfg, c)
if err != nil {
b.Fatal(err)
Expand Down

This file was deleted.

16 changes: 16 additions & 0 deletions unreleased/deprecate-metrics-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 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: processor/cumulativetodelta

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Removes the deprecated `metrics` config option. Use `include`/`exclude` instead.

# One or more tracking issues related to the change
issues: [12732]

# (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:

0 comments on commit ba325a3

Please sign in to comment.