Skip to content

Commit 9e9bfc4

Browse files
committed
metrics, internal/debug: Add --pprofaddr flag, expose metrics via gexp
1 parent c780901 commit 9e9bfc4

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎internal/debug/flags.go‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ var (
5252
Usage: "pprof HTTP server listening port",
5353
Value: 6060,
5454
}
55+
pprofAddrFlag = cli.StringFlag{
56+
Name: "pprofaddr",
57+
Usage: "pprof HTTP server listening interface",
58+
Value: "127.0.0.1",
59+
}
5560
memprofilerateFlag = cli.IntFlag{
5661
Name: "memprofilerate",
5762
Usage: "Turn on memory profiling with the given rate",
@@ -74,7 +79,7 @@ var (
7479
// Flags holds all command-line flags required for debugging.
7580
var Flags = []cli.Flag{
7681
verbosityFlag, vmoduleFlag, backtraceAtFlag,
77-
pprofFlag, pprofPortFlag,
82+
pprofFlag, pprofAddrFlag, pprofPortFlag,
7883
memprofilerateFlag, blockprofilerateFlag, cpuprofileFlag, traceFlag,
7984
}
8085

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

102107
// pprof server
103108
if ctx.GlobalBool(pprofFlag.Name) {
104-
address := fmt.Sprintf("127.0.0.1:%d", ctx.GlobalInt(pprofPortFlag.Name))
109+
address := fmt.Sprintf("%s:%d", ctx.GlobalString(pprofAddrFlag.Name), ctx.GlobalInt(pprofPortFlag.Name))
105110
go func() {
106111
glog.V(logger.Info).Infof("starting pprof server at http://%s/debug/pprof", address)
107112
glog.Errorln(http.ListenAndServe(address, nil))

‎metrics/metrics.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/ethereum/go-ethereum/logger"
2727
"github.com/ethereum/go-ethereum/logger/glog"
2828
"github.com/rcrowley/go-metrics"
29+
"github.com/rcrowley/go-metrics/exp"
2930
)
3031

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

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

0 commit comments

Comments
 (0)