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

daemon: instrument the gateway and api HTTP handlers #1799

Merged
merged 1 commit into from
Oct 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/ipfs/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ func serveHTTPApi(req cmds.Request) (error, <-chan error) {
},
})
var opts = []corehttp.ServeOption{
corehttp.PrometheusCollectorOption("api"),
corehttp.CommandsOption(*req.InvocContext()),
corehttp.WebUIOption,
apiGw.ServeOption(),
Expand Down Expand Up @@ -416,6 +417,7 @@ func serveHTTPGateway(req cmds.Request) (error, <-chan error) {
}

var opts = []corehttp.ServeOption{
corehttp.PrometheusCollectorOption("gateway"),
corehttp.CommandsROOption(*req.InvocContext()),
corehttp.VersionOption(),
corehttp.IPNSHostnameOption(),
Expand Down
10 changes: 9 additions & 1 deletion core/corehttp/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ import (

func PrometheusOption(path string) ServeOption {
return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) {
mux.Handle(path, prom.Handler())
mux.Handle(path, prom.UninstrumentedHandler())
return mux, nil
}
}

func PrometheusCollectorOption(handlerName string) ServeOption {
return func(_ *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) {
childMux := http.NewServeMux()
mux.HandleFunc("/", prom.InstrumentHandler(handlerName, childMux))
return childMux, nil
}
}