|
@@ -25,6 +25,7 @@ import (
|
|
|
"github.com/coreos/etcd/clientv3"
|
|
"github.com/coreos/etcd/clientv3"
|
|
|
"github.com/coreos/etcd/clientv3/namespace"
|
|
"github.com/coreos/etcd/clientv3/namespace"
|
|
|
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
|
|
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
|
|
|
|
|
+ "github.com/coreos/etcd/pkg/debugutil"
|
|
|
"github.com/coreos/etcd/pkg/transport"
|
|
"github.com/coreos/etcd/pkg/transport"
|
|
|
"github.com/coreos/etcd/proxy/grpcproxy"
|
|
"github.com/coreos/etcd/proxy/grpcproxy"
|
|
|
|
|
|
|
@@ -47,6 +48,8 @@ var (
|
|
|
grpcProxyResolverTTL int
|
|
grpcProxyResolverTTL int
|
|
|
|
|
|
|
|
grpcProxyNamespace string
|
|
grpcProxyNamespace string
|
|
|
|
|
+
|
|
|
|
|
+ grpcProxyEnablePprof bool
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
func init() {
|
|
@@ -80,6 +83,7 @@ func newGRPCProxyStartCommand() *cobra.Command {
|
|
|
cmd.Flags().StringVar(&grpcProxyResolverPrefix, "resolver-prefix", "", "prefix to use for registering proxy (must be shared with other grpc-proxy members)")
|
|
cmd.Flags().StringVar(&grpcProxyResolverPrefix, "resolver-prefix", "", "prefix to use for registering proxy (must be shared with other grpc-proxy members)")
|
|
|
cmd.Flags().IntVar(&grpcProxyResolverTTL, "resolver-ttl", 0, "specify TTL, in seconds, when registering proxy endpoints")
|
|
cmd.Flags().IntVar(&grpcProxyResolverTTL, "resolver-ttl", 0, "specify TTL, in seconds, when registering proxy endpoints")
|
|
|
cmd.Flags().StringVar(&grpcProxyNamespace, "namespace", "", "string to prefix to all keys for namespacing requests")
|
|
cmd.Flags().StringVar(&grpcProxyNamespace, "namespace", "", "string to prefix to all keys for namespacing requests")
|
|
|
|
|
+ cmd.Flags().BoolVar(&grpcProxyEnablePprof, "enable-pprof", false, `Enable runtime profiling data via HTTP server. Address is at client URL + "/debug/pprof/"`)
|
|
|
|
|
|
|
|
return &cmd
|
|
return &cmd
|
|
|
}
|
|
}
|
|
@@ -161,6 +165,13 @@ func startGRPCProxy(cmd *cobra.Command, args []string) {
|
|
|
httpmux := http.NewServeMux()
|
|
httpmux := http.NewServeMux()
|
|
|
httpmux.HandleFunc("/", http.NotFound)
|
|
httpmux.HandleFunc("/", http.NotFound)
|
|
|
httpmux.Handle("/metrics", prometheus.Handler())
|
|
httpmux.Handle("/metrics", prometheus.Handler())
|
|
|
|
|
+ if grpcProxyEnablePprof {
|
|
|
|
|
+ for p, h := range debugutil.PProfHandlers() {
|
|
|
|
|
+ httpmux.Handle(p, h)
|
|
|
|
|
+ }
|
|
|
|
|
+ plog.Infof("pprof is enabled under %s", debugutil.HTTPPrefixPProf)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
srvhttp := &http.Server{
|
|
srvhttp := &http.Server{
|
|
|
Handler: httpmux,
|
|
Handler: httpmux,
|
|
|
}
|
|
}
|