mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
*: register metrics handler for grpcproxy self
This commit is contained in:
parent
e94dc39edc
commit
fff5d3cc03
@ -215,6 +215,7 @@ func startGRPCProxy(cmd *cobra.Command, args []string) {
|
||||
mux := http.NewServeMux()
|
||||
grpcproxy.HandleMetrics(mux, httpClient, client.Endpoints())
|
||||
grpcproxy.HandleHealth(lg, mux, client)
|
||||
grpcproxy.HandleProxyMetrics(mux)
|
||||
lg.Info("gRPC proxy server metrics URL serving")
|
||||
herr := http.Serve(mhttpl, mux)
|
||||
if herr != nil {
|
||||
@ -407,6 +408,7 @@ func mustHTTPListener(lg *zap.Logger, m cmux.CMux, tlsinfo *transport.TLSInfo, c
|
||||
httpmux.HandleFunc("/", http.NotFound)
|
||||
grpcproxy.HandleMetrics(httpmux, httpClient, c.Endpoints())
|
||||
grpcproxy.HandleHealth(lg, httpmux, c)
|
||||
grpcproxy.HandleProxyMetrics(httpmux)
|
||||
if grpcProxyEnablePprof {
|
||||
for p, h := range debugutil.PProfHandlers() {
|
||||
httpmux.Handle(p, h)
|
||||
|
@ -29,8 +29,9 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
PathMetrics = "/metrics"
|
||||
PathHealth = "/health"
|
||||
PathMetrics = "/metrics"
|
||||
PathHealth = "/health"
|
||||
PathProxyMetrics = "/proxy/metrics"
|
||||
)
|
||||
|
||||
// HandleMetricsHealth registers metrics and health handlers.
|
||||
|
@ -23,6 +23,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"go.etcd.io/etcd/v3/etcdserver/api/etcdhttp"
|
||||
)
|
||||
|
||||
@ -98,6 +99,11 @@ func HandleMetrics(mux *http.ServeMux, c *http.Client, eps []string) {
|
||||
})
|
||||
}
|
||||
|
||||
// HandleProxyMetrics registers metrics handler on '/proxy/metrics'.
|
||||
func HandleProxyMetrics(mux *http.ServeMux) {
|
||||
mux.Handle(etcdhttp.PathProxyMetrics, promhttp.Handler())
|
||||
}
|
||||
|
||||
func shuffleEndpoints(r *rand.Rand, eps []string) []string {
|
||||
// copied from Go 1.9<= rand.Rand.Perm
|
||||
n := len(eps)
|
||||
|
Loading…
x
Reference in New Issue
Block a user