-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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/signalfx] Remove deprecated translation_rules configuration option #35332
base: main
Are you sure you want to change the base?
Changes from 7 commits
a427660
77f0691
2a05e21
9f9a0e1
3d13605
3ee394c
11e5523
6e769ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# 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: signalfxexporter | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Remove the deprecated configuration option `translation_rules` | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [35332] | ||
|
||
# (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: | | ||
Please use processors to handle desired metric transformations instead. Find guidance and examples below for each transformation type. | ||
|
||
| Deleted Translation rule | Replacement option | Replacement example | | ||
| -----------------|--------------------|----------------------| | ||
| rename_dimension_keys | `metricstransform` processor's update label function | [one metric](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/metricstransformprocessor#rename-labels), [multiple metrics](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/metricstransformprocessor#rename-labels-for-multiple-metrics) | | ||
| rename_metrics | `metricstransform` processor's rename metric functionality | [one metric](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/metricstransformprocessor#rename-metric), [multiple metrics](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/metricstransformprocessor#rename-multiple-metrics-using-substitution) | | ||
| multiply_int, divide_int, multiply_float | `metricstransform` processor's `scale` value functionality | [one metric](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/metricstransformprocessor#scale-value) | | ||
| convert_values | `transform` processor's `Double` or `Int` converter on a `datapoint` context | [`Double` example](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/ottl/ottlfuncs#double), [`Int` example](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/ottl/ottlfuncs#int) | | ||
| copy_metrics | `metricstransform` processor's `insert` functionality | [copy all datapoints](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/metricstransformprocessor#create-a-new-metric-from-an-existing-metric), [conditionally copy datapoints](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/metricstransformprocessor#create-a-new-metric-from-an-existing-metric-with-matching-label-values) | | ||
| split_metric | `metricstransform` processor's `insert` functionality and `filter` processor | Refer to the replacement guidance for the `copy_metrics` and `drop_metrics` translation rules | | ||
| aggregate_metric | `transform` processor's `aggregate_on_attributes` function with the `metric` context | [aggregate example](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/transformprocessor#aggregate_on_attributes) | | ||
| calculate_new_metric | `metricsgeneration` processor's `calculate` functionality | [calculate example](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/metricsgenerationprocessor#example-configurations) | | ||
| drop_metrics | `filter` processor | [drop by name and value example](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/filterprocessor#dropping-specific-metric-and-value) | | ||
| delta_metric | `cumulativetodelta` processor. To preserve original metrics, first copy the original metric, then use the copied metric in the `cumulativetodelta` processor | [specify which metrics to convert example](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/cumulativetodeltaprocessor#examples) | ||
| drop_dimensions | `transform` processor's `delete_keys` function with the `datapoint` context | [simple example](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/pkg/ottl/ottlfuncs#delete_key), use a `where` clause with the given example to filter based upon the metric name or dimension value | | ||
|
||
# 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: [] |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ import ( | |
"go.opentelemetry.io/collector/config/configtls" | ||
"go.opentelemetry.io/collector/confmap" | ||
"go.opentelemetry.io/collector/exporter/exporterhelper" | ||
"go.uber.org/zap" | ||
"gopkg.in/yaml.v3" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/signalfxexporter/internal/correlation" | ||
|
@@ -24,17 +23,24 @@ import ( | |
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/splunk" | ||
) | ||
|
||
const ( | ||
translationRulesConfigKey = "translation_rules" | ||
) | ||
type translationRulesConfig struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This mimics the original |
||
TranslationRules []translation.Rule `mapstructure:"translation_rules"` | ||
} | ||
|
||
var defaultTranslationRules = func() []translation.Rule { | ||
cfg, err := loadConfig([]byte(translation.DefaultTranslationRulesYaml)) | ||
var data map[string]any | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New functionality here is essentially copied from |
||
var defaultRules translationRulesConfig | ||
|
||
// It is safe to panic since this is deterministic, and will not fail anywhere else if it doesn't fail all the time. | ||
if err != nil { | ||
if err := yaml.Unmarshal([]byte(translation.DefaultTranslationRulesYaml), &data); err != nil { | ||
panic(err) | ||
} | ||
return cfg.TranslationRules | ||
|
||
if err := confmap.NewFromStringMap(data).Unmarshal(&defaultRules); err != nil { | ||
panic(fmt.Errorf("failed to load default translation rules: %w", err)) | ||
} | ||
|
||
return defaultRules.TranslationRules | ||
}() | ||
|
||
var defaultExcludeMetrics = func() []dpfilters.MetricFilter { | ||
|
@@ -89,11 +95,6 @@ type Config struct { | |
|
||
splunk.AccessTokenPassthroughConfig `mapstructure:",squash"` | ||
|
||
// TranslationRules defines a set of rules how to translate metrics to a SignalFx compatible format | ||
// Rules defined in translation/constants.go are used by default. | ||
// Deprecated: Use metricstransform processor to do metrics transformations. | ||
TranslationRules []translation.Rule `mapstructure:"translation_rules"` | ||
|
||
DisableDefaultTranslationRules bool `mapstructure:"disable_default_translation_rules"` | ||
|
||
// DeltaTranslationTTL specifies in seconds the max duration to keep the most recent datapoint for any | ||
|
@@ -150,25 +151,17 @@ type DimensionClientConfig struct { | |
Timeout time.Duration `mapstructure:"timeout"` | ||
} | ||
|
||
func (cfg *Config) getMetricTranslator(logger *zap.Logger, done chan struct{}) (*translation.MetricTranslator, error) { | ||
rules := defaultTranslationRules | ||
if cfg.TranslationRules != nil { | ||
// Previous way to disable default translation rules. | ||
if len(cfg.TranslationRules) == 0 { | ||
logger.Warn("You are using the deprecated `translation_rules` option that will be removed soon; Use `disable_default_translation_rules` to disable the default rules in a gateway mode.") | ||
rules = []translation.Rule{} | ||
} else { | ||
logger.Warn("You are using the deprecated `translation_rules` option that will be removed soon; Use metricstransform processor instead.") | ||
rules = cfg.TranslationRules | ||
} | ||
} | ||
func (cfg *Config) getMetricTranslator(done chan struct{}) (*translation.MetricTranslator, error) { | ||
var rules []translation.Rule | ||
// The new way to disable default translation rules. This override any setting of the default TranslationRules. | ||
if cfg.DisableDefaultTranslationRules { | ||
rules = []translation.Rule{} | ||
} else { | ||
rules = defaultTranslationRules | ||
} | ||
metricTranslator, err := translation.NewMetricTranslator(rules, cfg.DeltaTranslationTTL, done) | ||
if err != nil { | ||
return nil, fmt.Errorf("invalid \"%s\": %w", translationRulesConfigKey, err) | ||
return nil, fmt.Errorf("invalid default translation rules: %w", err) | ||
} | ||
|
||
return metricTranslator, nil | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The metricsgeneration processor could also be used here. I chose
metricstransform
processor instead as we're recommending it for so many other options.