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

gcp/observability: update method name validation #5951

Merged
merged 2 commits into from Jan 23, 2023

Conversation

zasweq
Copy link
Contributor

@zasweq zasweq commented Jan 18, 2023

This PR iterates what a valid method name is in the observability config, according to offline discussions.

From Doug, this can be summarized as:

Allowed patterns:
- *
- service/*
- service/method

- service and method may not contain slash

RELEASE NOTES:

  • gcp/observability: update method name validation

@zasweq zasweq requested a review from dfawley January 18, 2023 20:37
@zasweq zasweq added this to the 1.53 Release milestone Jan 18, 2023
@dfawley
Copy link
Member

dfawley commented Jan 18, 2023

FYI the tests are now failing here.

@zasweq zasweq force-pushed the leading-slash-fix branch 3 times, most recently from 2daf783 to 8b823e5 Compare January 19, 2023 16:31
@dfawley dfawley changed the title gcp/observability: Iterate vaild method name gcp/observability: update method name validation Jan 23, 2023
// validateMethodString validates whether the string passed in is a valid
// pattern.
func validateMethodString(method string) error {
if method == "*" {
Copy link
Member

Choose a reason for hiding this comment

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

Note that this function isn't even called if method is *.

Maybe inline this in validateLogEventMethod?

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 fair point missed that. I'm assuming inline this means just leave what is there (if * continue (skip calling this function/validating). Deleted this conditional.

// parseMethod splits service and method from the input. It expects format
// "service/method".
func parseMethod(method string) (string, string, error) {
pos := strings.LastIndex(method, "/")
Copy link
Member

Choose a reason for hiding this comment

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

Nit: maybe Index is a little less unusual than LastIndex since we know there is exactly one slash.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah good point already validated by this point. Switched.

@dfawley dfawley assigned zasweq and unassigned dfawley Jan 23, 2023
@zasweq zasweq merged commit 52a8392 into grpc:master Jan 23, 2023
1 check passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants