Skip to content

Adding Sanitizer interface and implementation - #70

Closed
ravirajj wants to merge 1 commit into
uber-java:masterfrom
ravirajj:rj.sanitizer
Closed

Adding Sanitizer interface and implementation#70
ravirajj wants to merge 1 commit into
uber-java:masterfrom
ravirajj:rj.sanitizer

Conversation

@ravirajj

@ravirajjravirajj commented May 3, 2020

Copy link
Copy Markdown
  • Sanitizes metric names and tag keys and values.
  • Does nothing by default.
  • The ScopeBulider can be configured with the standard M3Sanitizer.
  • FixesAdd Metrics Sanitizer  #8

/**
* Sanitize returns a sanitized version of the input string value.
*/
public interface Sanitize {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please try for a different name. Sanitize next to Sanitizer confused me thoroughly

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The Sanitizer interface matches the uber-go/tallySanitizer interface.

The Sanitize interface is meant to match the uber-go/tallySanitizeFn interface. Name it SanitizeFn too?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please elaborate on what this interface is needed for


// first check if the provided character is valid
boolean validCurr =
ranges.stream().anyMatch(range -> ch >= range.low() && ch <= range.high())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

is this operation performance-sensitive? If so, this looks very expensive

@ravirajjravirajjMay 4, 2020

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It matches the uber-go/tallysanitzeFn(). Like the go version, it optimizes allocations by avoiding copying if the all characters are valid. Any suggestions on how to optimize this in Java?

@longquanzheng

Copy link
Copy Markdown

Any progress on this PR? @ravirajj@inetchitailo ?

@longquanzheng

Copy link
Copy Markdown

@SokolAndrey@andrewmains12@alexeykudinkin can you help take a look? I am needing this in my project. Thanks so much

return snap;
}

private ImmutableMap<String, String> copyAndSanitizeMap(Map<String, String> tags) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's avoid copying if there are no changes to the map

* @param name the name string
* @return the sanitized name
*/
String name(String name);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please follow the naming convention -- method name should bear a verb in it

/**
* Sanitize returns a sanitized version of the input string value.
*/
public interface Sanitize {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please elaborate on what this interface is needed for

@longquanzheng

Copy link
Copy Markdown

@alexeykudinkin@ravirajj Hello, thanks so much for this.
Would you mind if I fork this branch and open another PR to address the comments?

Thanks

@alexeykudinkin

Copy link
Copy Markdown
Contributor

@longquanzheng works for me

Sign up for freeto 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.

Add Metrics Sanitizer

4 participants

@ravirajj@longquanzheng@alexeykudinkin@inetchitailo