1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-09 17:22:21 +08:00
Files
kubo/core/corehttp/prometheus.go
Lars Gierth dd20f48454 daemon: instrument the gateway and api HTTP handlers
License: MIT
Signed-off-by: Lars Gierth <larsg@systemli.org>
2015-10-05 03:53:49 +02:00

26 lines
687 B
Go

package corehttp
import (
"net"
"net/http"
prom "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/prometheus/client_golang/prometheus"
"github.com/ipfs/go-ipfs/core"
)
func PrometheusOption(path string) ServeOption {
return func(n *core.IpfsNode, _ net.Listener, mux *http.ServeMux) (*http.ServeMux, error) {
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
}
}