Skip to content
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

[prometheusremotewriteexporter] Allow to disable sanitize metric labels #8270

Merged
merged 20 commits into from
Apr 18, 2022

Conversation

newly12
Copy link
Contributor

@newly12 newly12 commented Mar 7, 2022

Description:

This PR does the similar thing as #7112 , while the previous PR covers external labels defined in config, this PR follow the same config and allows to disable sanitize labels from scrapped metrics.

Link to tracking Issue:

Testing:

Documentation:

@newly12 newly12 requested a review from a team March 7, 2022 06:11
@newly12 newly12 requested a review from Aneurysm9 as a code owner March 7, 2022 06:11
@newly12 newly12 changed the title [pkg/translator/prometheusremotewrite] Allow to disable sanitize metric labels [exporter/prometheusremotewrite] Allow to disable sanitize metric labels Mar 7, 2022
@newly12 newly12 changed the title [exporter/prometheusremotewrite] Allow to disable sanitize metric labels [prometheusremotewriteexporter] Allow to disable sanitize metric labels Mar 7, 2022
@jpkrohling
Copy link
Member

jpkrohling commented Mar 7, 2022

Is this a bug? A feature request? Is there an issue tracking this?

@@ -107,7 +109,7 @@ func (prwe *prwExporter) PushMetrics(ctx context.Context, md pdata.Metrics) erro
case <-prwe.closeChan:
return errors.New("shutdown has been called")
default:
tsMap, err := prometheusremotewrite.FromMetrics(md, prometheusremotewrite.Settings{Namespace: prwe.namespace, ExternalLabels: prwe.externalLabels})
tsMap, err := prometheusremotewrite.FromMetrics(md, prometheusremotewrite.Settings{Namespace: prwe.namespace, ExternalLabels: prwe.externalLabels, SanitizeLabel: prwe.sanitizeLabel})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be done without changing the exported interface of the PRW translator package?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see much options, one is to introduce a feature flag in the translator package, but I was thinking to reuse the same feature flag as basically it's about the same thing as #7112 , thus an additional fields in prometheusremotewrite.Settings will be introduced to follow previous behavior by default.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is that feature gates are intended to be temporary and removed eventually. Changes to the public API of a package are not reversible (assuming a world where we're v1.x, which we need to start planning for) and thus should be avoided in conjunction with feature gates. It is hypothesized that the sanitization of labels starting with _ (but not __) is unnecessary, so perhaps we should focus on finding a way to gain confidence in that hypothesis and eliminating the need for this feature gate.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the concern of changing the public API in translator, but it's still the same behavior by default, with regards to gain confidence in the hypothesis, I am not sure how we can move forward on that. could you please elaborate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @Aneurysm9 any thoughts on how we can move forward on this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we should probably eliminate it altogether rather than further propagating it. Changing the public API of this module does not seem like the correct thing to do.

I'm not sure I'm comfortable making this decision by myself. @dashpole @bogdandrutu @jpkrohling @codeboten @gouthamve

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that sounds like this will be a breaking change which is going to remove the key prefix.

If not to change the public API, would it work that introduce a new method similar to FromMetrics which does not sanitize label(no key prefix)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the public API of this module does not seem like the correct thing to do.

I share the same opinion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also agree we should not change the public API. We should either make the change outright, or use a feature-gate to slowly make the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a feature gate for this.

@newly12
Copy link
Contributor Author

newly12 commented Mar 8, 2022

@jpkrohling it's a feature request. I searched issues and didn't see one for this.

Signed-off-by: Peter Deng <[email protected]>

# Conflicts:
#	CHANGELOG.md
#	pkg/translator/prometheusremotewrite/helper.go
#	pkg/translator/prometheusremotewrite/helper_test.go
#	pkg/translator/prometheusremotewrite/testutils_test.go
Signed-off-by: Peter Deng <[email protected]>

# Conflicts:
#	CHANGELOG.md
#	pkg/translator/prometheusremotewrite/helper.go
CHANGELOG.md Outdated Show resolved Hide resolved
@jpkrohling jpkrohling dismissed their stale review March 22, 2022 12:53

changelog fixed

@jpkrohling
Copy link
Member

Once @Aneurysm9 approves, I'll merge this.

Copy link
Contributor

@dashpole dashpole left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this misses some calls to sanitize elsewhere in helper.go. It seems like it would be simpler to just check the feature gate from within sanitize():

-	if s[0] == '_' {
+	if !featuregate.IsEnabled(dropSanitizationGate.ID) && s[0] == '_' {
		s = keyStr + s
	}

CHANGELOG.md Outdated Show resolved Hide resolved
@newly12
Copy link
Contributor Author

newly12 commented Apr 12, 2022

It looks like this misses some calls to sanitize elsewhere in helper.go. It seems like it would be simpler to just check the feature gate from within sanitize():

-	if s[0] == '_' {
+	if !featuregate.IsEnabled(dropSanitizationGate.ID) && s[0] == '_' {
		s = keyStr + s
	}

good point. updated.

@newly12
Copy link
Contributor Author

newly12 commented Apr 15, 2022

@dashpole @Aneurysm9 @jpkrohling could you please review again?

CHANGELOG.md Outdated Show resolved Hide resolved
Co-authored-by: David Ashpole <[email protected]>
@jpkrohling jpkrohling merged commit cae2803 into open-telemetry:main Apr 18, 2022
@newly12 newly12 deleted the label_sanitize branch April 21, 2022 01:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants