-
Notifications
You must be signed in to change notification settings - Fork 242
Fixing Websocket Connections when Prometheus Metrics Enabled #371
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
Fixing Websocket Connections when Prometheus Metrics Enabled #371
Conversation
Signed-off-by: hfuss <haydenfuss@gmail.com>
Signed-off-by: hfuss <haydenfuss@gmail.com>
nguyer
left a comment
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 @hfuss! Looks good to me after tests and coverage passes.
Signed-off-by: hfuss <haydenfuss@gmail.com>
|
Thanks @nguyer! @eberger727 and I will ensure E2E is fixed w/ metrics enabled and then I can cleanup the coverage / unit tests. |
peterbroadhurst
left a comment
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.
Would like to understand why can't just put our own middleware in, that wraps the prometheus middleware, rather than the code copy
Signed-off-by: hfuss <haydenfuss@gmail.com>
Signed-off-by: hfuss <haydenfuss@gmail.com>
Codecov Report
@@ Coverage Diff @@
## main #371 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 239 239
Lines 12886 12886
=========================================
Hits 12886 12886
Continue to review full report at Codecov.
|
internal/metrics/response_writer.go
Outdated
| type statusResponseWriter struct { | ||
| // websocketResponseWriter | ||
| type websocketResponseWriter struct { | ||
| http.ResponseWriter |
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.
@peterbroadhurst this didn't work as expected because the inherited ResponseWriter for websocketResponseWriter ended up being a statusResponseWriter which does not implement Hijacker.
I tried climbing the "inheritance stack" with something like the following since statusResponseWriter is private:
type wrapperResponseWriter struct {
http.ResponseWriter
}
// ...
func (w *websocketResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
h, ok := w.ResponseWriter.(wrapperResponseWriter).ResponseWriter.(http.Hijacker)
// ...
}but that didn't work either so decided it was easier to fork the library with the fix and have FireFly use that instead.
peterbroadhurst
left a comment
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.
Sorry this turned into more work, but this seems like a great solution 👍
Hijackmethod is implemented in the wrapper aroundResponseWriterin order to fix Websocket: response does not implement http.Hijacker - when metrics enabled #370ff_prefix to the middleware metricsgo mod tidy