-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[exporter/signalfx] Remove deprecated translation_rules configuration option #35332
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
Merged
dmitryax
merged 11 commits into
open-telemetry:main
from
crobert-1:signalfx_exporter_remove_translation_rules
Feb 20, 2025
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
638d1be
[exporter/signalfx] Remove deprecated translation_rules configuration…
crobert-1 3c42821
Update .chloggen/signalfx_exporter_remove_translation_rules.yaml
crobert-1 c3995da
Update exporter/signalfxexporter/internal/translation/constants.go
crobert-1 edc2454
Restore translation rules to YAML
crobert-1 a615275
Move config struct to private
crobert-1 db7dfc3
Add steps to resolve breaking changes to changelog
crobert-1 4ad28f3
Move changelog directions to a table
crobert-1 0efbf1f
Alphabetize translation rules in changelog
crobert-1 651b757
Add comment requested
crobert-1 416ed86
Move migration guide to a doc
crobert-1 8ff576a
Merge branch 'main' into signalfx_exporter_remove_translation_rules
crobert-1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# 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 migration guidance in the | ||
[translation rules migration guide](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/exporter/signalfxexporter/docs/translation_rules_migration_guide.md). | ||
|
||
# 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: [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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,27 @@ import ( | |
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/splunk" | ||
) | ||
|
||
const ( | ||
translationRulesConfigKey = "translation_rules" | ||
) | ||
// This mimics the original translation_rules config option (now deleted), but is not reachable | ||
// by user configuration. It's only used by defaultTranslationRules to parse the | ||
// YAML into a []translation.Rule object. | ||
type translationRulesConfig struct { | ||
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 +98,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 +154,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 | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
exporter/signalfxexporter/docs/translation_rules_migration_guide.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Translation Rules Migration Guide | ||
|
||
## Context | ||
|
||
The `translation_rules` configuration option of the SignalFx exporter | ||
[has been deprecated](https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/18218) | ||
and [removed](https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/35332) in an effort to | ||
reduce the exporter's complexity and leverage existing functionality in existing | ||
OpenTelemetry Collector processors. | ||
|
||
## Migration Guide | ||
|
||
The following table can be referenced to map existing translation rule actions to processors that | ||
can be used to accomplish the same functionality. | ||
|
||
| Deleted Translation rule | Replacement option | Replacement example | | ||
| -----------------|--------------------|----------------------| | ||
| 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) | | ||
| 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) | | ||
| 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 | | ||
| 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) | | ||
| 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) | | ||
| 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) | | ||
| split_metric | `metricstransform` processor's `insert` functionality and `filter` processor | Refer to the replacement guidance for the `copy_metrics` and `drop_metrics` translation rules | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.