提交 dd20f484 作者: Lars Gierth

daemon: instrument the gateway and api HTTP handlers

License: MIT
Signed-off-by: 's avatarLars Gierth <larsg@systemli.org>
上级 e0f04176
......@@ -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(),
......@@ -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(),
......
......@@ -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
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论