mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-09 17:22:21 +08:00
26 lines
687 B
Go
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
|
|
}
|
|
}
|