Skip to content

Commit

Permalink
metrics, internal/debug: Add --pprofaddr flag, expose metrics via gexp
Browse files Browse the repository at this point in the history
  • Loading branch information
Arachnid committed Oct 14, 2016
1 parent c780901 commit 9e9bfc4
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions internal/debug/flags.go
Original file line number Diff line number Diff line change
@@ -52,6 +52,11 @@ var (
Usage: "pprof HTTP server listening port",
Value: 6060,
}
pprofAddrFlag = cli.StringFlag{
Name: "pprofaddr",
Usage: "pprof HTTP server listening interface",
Value: "127.0.0.1",
}
memprofilerateFlag = cli.IntFlag{
Name: "memprofilerate",
Usage: "Turn on memory profiling with the given rate",
@@ -74,7 +79,7 @@ var (
// Flags holds all command-line flags required for debugging.
var Flags = []cli.Flag{
verbosityFlag, vmoduleFlag, backtraceAtFlag,
pprofFlag, pprofPortFlag,
pprofFlag, pprofAddrFlag, pprofPortFlag,
memprofilerateFlag, blockprofilerateFlag, cpuprofileFlag, traceFlag,
}

@@ -101,7 +106,7 @@ func Setup(ctx *cli.Context) error {

// pprof server
if ctx.GlobalBool(pprofFlag.Name) {
address := fmt.Sprintf("127.0.0.1:%d", ctx.GlobalInt(pprofPortFlag.Name))
address := fmt.Sprintf("%s:%d", ctx.GlobalString(pprofAddrFlag.Name), ctx.GlobalInt(pprofPortFlag.Name))
go func() {
glog.V(logger.Info).Infof("starting pprof server at http://%s/debug/pprof", address)
glog.Errorln(http.ListenAndServe(address, nil))
2 changes: 2 additions & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ import (
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
"github.com/rcrowley/go-metrics"
"github.com/rcrowley/go-metrics/exp"
)

// MetricsEnabledFlag is the CLI flag name to use to enable metrics collections.
@@ -44,6 +45,7 @@ func init() {
Enabled = true
}
}
exp.Exp(metrics.DefaultRegistry)
}

// NewMeter create a new metrics Meter, either a real one of a NOP stub depending

0 comments on commit 9e9bfc4

Please sign in to comment.