-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkg/translator/prometheus: Allow not translating UTF8-characters
Signed-off-by: Arthur Silva Sens <[email protected]>
- Loading branch information
1 parent
4b1e300
commit 2e05a62
Showing
11 changed files
with
348 additions
and
64 deletions.
There are no files selected for viewing
This file contains 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,27 @@ | ||
# Use this changelog template to create an entry for release notes. | ||
|
||
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
change_type: enhancement | ||
|
||
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
component: pkg/translator/prometheus | ||
|
||
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
note: Allow UTF-8 characters in Prometheus metric names and labels. | ||
|
||
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
issues: [35459] | ||
|
||
# (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: | ||
|
||
# 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, api] |
This file contains 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 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 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 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 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 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,53 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package prometheus // import "github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/prometheus" | ||
|
||
import ( | ||
"go.opentelemetry.io/collector/featuregate" | ||
) | ||
|
||
var ( | ||
dropSanitizationGate = featuregate.GlobalRegistry().MustRegister( | ||
"pkg.translator.prometheus.PermissiveLabelSanitization", | ||
featuregate.StageAlpha, | ||
featuregate.WithRegisterDescription("Controls whether to change labels starting with '_' to 'key_'."), | ||
featuregate.WithRegisterReferenceURL("https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/8950"), | ||
) | ||
|
||
normalizeNameGate = featuregate.GlobalRegistry().MustRegister( | ||
"pkg.translator.prometheus.NormalizeName", | ||
featuregate.StageBeta, | ||
featuregate.WithRegisterDescription("Controls whether metrics names are automatically normalized to follow Prometheus naming convention. Attention: if 'pkg.translator.prometheus.allowUTF8' is enabled, UTF-8 characters will not be normalized."), | ||
featuregate.WithRegisterReferenceURL("https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/8950"), | ||
) | ||
|
||
// AllowUTF8FeatureGate could be a private variable, it is used mostly to toogle the | ||
// value of a global variable and it's intended usage is: | ||
/* | ||
import "github.com/prometheus/common/model" | ||
if AllowUTF8FeatureGate.IsEnabled() { | ||
model.NameValidationScheme = model.UTF8Validation | ||
} | ||
*/ | ||
// We could do this with a init function in the translator package, but we can't guarantee that | ||
// the featuregate.GlobalRegistry is initialized before the init function here. | ||
// | ||
// Components that want to respect this feature gate behavior should check if it is enabled and | ||
// set the model.NameValidationScheme accordingly. | ||
// | ||
// WARNING: Since it's a global variable, if one component enables it then it works for all components | ||
// that are using this package. | ||
AllowUTF8FeatureGate = featuregate.GlobalRegistry().MustRegister( | ||
"pkg.translator.prometheus.allowUTF8", | ||
featuregate.StageAlpha, | ||
featuregate.WithRegisterDescription("When enabled, UTF-8 characters will not be translated to underscores."), | ||
featuregate.WithRegisterReferenceURL("https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/35459"), | ||
featuregate.WithRegisterFromVersion("v0.110.0"), | ||
) | ||
) | ||
|
||
func init() { | ||
|
||
} |
This file contains 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 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.