-
Notifications
You must be signed in to change notification settings - Fork 263
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
Enable serving /_status and /_metrics via HTTP #295
Conversation
main.go
Outdated
@@ -615,6 +615,12 @@ func (context *Context) serveStatus() error { | |||
mux.Handle("/debug/pprof/trace", http.HandlerFunc(pprof.Trace)) | |||
} | |||
|
|||
serveHTTPS := true | |||
if strings.HasPrefix(*statusAddress, "http://") { | |||
*statusAddress = (*statusAddress)[7:] |
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.
(1) Would prefer that we avoid changing the global flag value here, as it may lead to odd side-effects if the value is ever used somewhere else. Let's introduce a local var for the status address.
(2) This code should also handle the case where the prefix might be https://
instead of http://
, and behave accordingly. Ideally create a function that parses the status address and returns (https bool, network, address string, err error)
based on parsing the flag value with net/url and socket.ParseAddress.
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.
@csstaub Thanks for the comment.
Pushed a new commit, but instead of a function return (https bool, network, address string, err error), I created socket.ParseHTTPAddress function that return (https bool, address string)
the return address could be further parsed by existing socket.ParseAddress.
IMHO, this would avoid more code changes.
Thanks for the contribution @Wuvist! This seems reasonable as a feature, but I left some comments to improve the implementation. |
socket/net.go
Outdated
@@ -47,6 +47,12 @@ func ParseAddress(input string) (network, address, host string, err error) { | |||
return | |||
} | |||
|
|||
if strings.HasPrefix(input, "http:") { | |||
network = "unix" |
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.
Not sure why this block is needed?
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 for the typo, accidentally click ctrl +v and miss when committing.
amended commit.
rebased with newest master |
Thanks @Wuvist! |
The pull request is to address the issue #294
By making parameter
--status
handle value likehttp://127.0.0.1:8888
,/_status
and/_metrics
could serve via HTTP.