-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
HTTP Metrics Path Matching #7746
base: master
Are you sure you want to change the base?
HTTP Metrics Path Matching #7746
Conversation
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
80e852f
to
561b9e8
Compare
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
38e25af
to
8dc24c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally the mainainters would tell you it's a bit premature to do the work before the proposal is even reviewed...!
This proposal was reviewed among some runtime maintainers and people got invited to participate in the discussion too. While there is space for discussion, multiple maintainers thought this proposal to be reasonable and low risk to start implementation. |
@nelson-parente Please, address the optimization suggestions as this is a hot path for Dapr and can cause a performance regression. Thanks, @ItalyPaleAle |
This is interesting as every time I was in @nelson-parente's shoes, the response I got from maintainers was very different. I have not seen voting happening (to my understanding, you will need the majority of 3 votes - 1 person for each company), and only 1 person commented. |
The PR is still pending proposal approval |
…turn Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
0e20ef3
to
a8f8a91
Compare
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
e1a4830
to
f9bfd3a
Compare
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
e750b0f
to
7ef2c20
Compare
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
7e36a31
to
7bbdafd
Compare
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
7bbdafd
to
2a2b4ef
Compare
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @nelson-parente, couple more from me 🙂
if !catchAllRegistered { | ||
mux.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
if !legacy { | ||
rw, ok := w.(*pathMatchingRW) | ||
if !ok { | ||
log.Errorf("Failed to cast to PathMatchingRW") | ||
return | ||
} | ||
rw.MatchedPath = unmatchedPathPlaceholder | ||
} | ||
})) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than have 2 HandlerFunc
registrations, we can optionally append "/"
if in non-legacy mode and remove dupes in the paths slice.
if !legacy {
paths = append(paths, "/")
slices.Sort(paths)
paths = slices.Compact(paths)
}
if !catchAllRegistered { | |
mux.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | |
if !legacy { | |
rw, ok := w.(*pathMatchingRW) | |
if !ok { | |
log.Errorf("Failed to cast to PathMatchingRW") | |
return | |
} | |
rw.MatchedPath = unmatchedPathPlaceholder | |
} | |
})) | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need the 2 handlers registration because we want to distinguish when the user explicitly sets the "/" path or not.
When the user sets the "/" path we match it and use it otherwise if the user does not set a "/" we fallback to the unmatched placeholder "_" so we need to have different handler funcs for those cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done! we always need to register the catch all otherwise serveHTTP will throw an error when it doesn't match the path.
if !strings.HasPrefix(path, "/") { | ||
path = "/" + path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Paths not starting /
are invalid and the request will return an error on the handle function.
I noticed this when testing and we had errors with dapr/config
path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: all invoke method paths are coming without the initial slash. I fixed the dapr/config but all these others are using the *invokev1.InvokeMethodRequest
and I don't really know the why these don't have the initial slash.
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
Signed-off-by: nelson.parente <nelson_parente@live.com.pt>
Description
This PR implements the proposal dapr/proposals#58.
PathMatching configuration is opt-in and ensures consistent representation of HTTP request paths in server metrics.
Issue reference
HTTP Metrics Path Matching Proposal: dapr/proposals#58
Dapr Low Cardinality Issue with initial motivation for the proposal: #7719
Please reference the issue this PR will close: #[issue number]
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: