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

Adds ability to specify sanitizeOptions for prometheus metrics #3170

Merged

Conversation

mastermanu
Copy link
Member

This PR adds the ability to set specific tally.SanitizeOptions via temporal configuration. If the configuration is not set, we rely on the default that is defined in code. Otherwise, we will generate a tally.SanitizeOptions by parsing the configuration file and converting it to a tally.SanitizeOptions.

Because configuration comes in via yaml, all relevant input fields are strings. The code converts the strings to runes and performs length check validations. Any invalid configuration will fail server startup.

@mastermanu mastermanu requested a review from a team as a code owner August 1, 2022 16:09
func (s SanitizeRange) toTally() (tally.SanitizeRange, error) {
startRangeRunes := []rune(s.StartRange)
if len(startRangeRunes) != 1 {
return tally.SanitizeRange{}, fmt.Errorf("start range '%+v' must be a single rune", startRangeRunes)
Copy link
Contributor

Choose a reason for hiding this comment

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

does this give enough feedback for someone using something that looks like a single character but isn't ala https://en.wikipedia.org/wiki/Combining_character - maybe it does but just want to bring it up.

Copy link
Member Author

Choose a reason for hiding this comment

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

i think the definition of a rune should make that clear as it maps to a Unicode Code Point

return tally.SanitizeRange{}, fmt.Errorf("end range '%+v' must be a single rune", endRangeRunes)
}

return tally.SanitizeRange([2]rune{startRangeRunes[0], endRangeRunes[0]}), nil
Copy link
Member

Choose a reason for hiding this comment

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

Do we need the 2 in [2]?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, that is the tally-specific type. they take in an array of runes, not a slice

Comment on lines 482 to 493
return tally.SanitizeOptions{}, errors.New("invalid nameChars")
}

tallyKeyChars, err := s.KeyCharacters.toTally()
if err != nil {
return tally.SanitizeOptions{}, errors.New("invalid keyChars")
}

tallyValueChars, err := s.ValueCharacters.toTally()
if err != nil {
return tally.SanitizeOptions{}, errors.New("invalid valueChars")
}
Copy link
Member

Choose a reason for hiding this comment

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

the error should wrap the detailed error.

Copy link
Member Author

Choose a reason for hiding this comment

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

oops, good catch

@mastermanu mastermanu merged commit c0fbdf9 into temporalio:master Aug 1, 2022
mastermanu added a commit to mastermanu/temporal that referenced this pull request Aug 2, 2022
…ralio#3170)

This PR adds the ability to set specific tally.SanitizeOptions via temporal configuration. If the configuration is not set, we rely on the default that is defined in code. Otherwise, we will generate a tally.SanitizeOptions by parsing the configuration file and converting it to a tally.SanitizeOptions.

Because configuration comes in via yaml, all relevant input fields are strings. The code converts the strings to runes and performs length check validations. Any invalid configuration will fail server startup.
mastermanu added a commit that referenced this pull request Aug 2, 2022
…etrics (#3170) (#3174)

Adds ability to specify sanitizeOptions for prometheus metrics (#3170)

This PR adds the ability to set specific tally.SanitizeOptions via temporal configuration. If the configuration is not set, we rely on the default that is defined in code. Otherwise, we will generate a tally.SanitizeOptions by parsing the configuration file and converting it to a tally.SanitizeOptions.

Because configuration comes in via yaml, all relevant input fields are strings. The code converts the strings to runes and performs length check validations. Any invalid configuration will fail server startup.
alexshtin pushed a commit that referenced this pull request Aug 2, 2022
…etrics (#3170) (#3174)

Adds ability to specify sanitizeOptions for prometheus metrics (#3170)

This PR adds the ability to set specific tally.SanitizeOptions via temporal configuration. If the configuration is not set, we rely on the default that is defined in code. Otherwise, we will generate a tally.SanitizeOptions by parsing the configuration file and converting it to a tally.SanitizeOptions.

Because configuration comes in via yaml, all relevant input fields are strings. The code converts the strings to runes and performs length check validations. Any invalid configuration will fail server startup.
yux0 pushed a commit to yux0/temporal that referenced this pull request Aug 3, 2022
…ralio#3170)

This PR adds the ability to set specific tally.SanitizeOptions via temporal configuration. If the configuration is not set, we rely on the default that is defined in code. Otherwise, we will generate a tally.SanitizeOptions by parsing the configuration file and converting it to a tally.SanitizeOptions.

Because configuration comes in via yaml, all relevant input fields are strings. The code converts the strings to runes and performs length check validations. Any invalid configuration will fail server startup.
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.

None yet

3 participants