aboutsummaryrefslogtreecommitdiff
path: root/plugin/pprof/setup.go
diff options
context:
space:
mode:
authorGravatar Francois Tur <ftur@infoblox.com> 2019-03-29 02:37:17 -0400
committerGravatar Miek Gieben <miek@miek.nl> 2019-03-29 06:37:17 +0000
commitc144da2524fc705cb20f23c4a4ce36c2ff45525e (patch)
treedda9aabaa63f31b094d872118943ab9aaa69c6ef /plugin/pprof/setup.go
parentf6eb2a4c14177277572de7c9313f41f53a8f48c7 (diff)
downloadcoredns-c144da2524fc705cb20f23c4a4ce36c2ff45525e.tar.gz
coredns-c144da2524fc705cb20f23c4a4ce36c2ff45525e.tar.zst
coredns-c144da2524fc705cb20f23c4a4ce36c2ff45525e.zip
plugin/pprof - add option to enable block profiling (#2729)
* - add an option for block profiling to plugin pprof * - move option block into nested block
Diffstat (limited to 'plugin/pprof/setup.go')
-rw-r--r--plugin/pprof/setup.go26
1 files changed, 23 insertions, 3 deletions
diff --git a/plugin/pprof/setup.go b/plugin/pprof/setup.go
index cdc346374..66c147e78 100644
--- a/plugin/pprof/setup.go
+++ b/plugin/pprof/setup.go
@@ -2,6 +2,7 @@ package pprof
import (
"net"
+ "strconv"
"sync"
"github.com/coredns/coredns/plugin"
@@ -36,15 +37,34 @@ func setup(c *caddy.Controller) error {
h.addr = args[0]
_, _, e := net.SplitHostPort(h.addr)
if e != nil {
- return e
+ return plugin.Error("pprof", c.Errf("%v", e))
}
}
+
if len(args) > 1 {
return plugin.Error("pprof", c.ArgErr())
}
- if c.NextBlock() {
- return plugin.Error("pprof", c.ArgErr())
+
+ for c.NextBlock() {
+ switch c.Val() {
+ case "block":
+ args := c.RemainingArgs()
+ if len(args) > 1 {
+ return plugin.Error("pprof", c.ArgErr())
+ }
+ h.rateBloc = 1
+ if len(args) > 0 {
+ t, err := strconv.Atoi(args[0])
+ if err != nil {
+ return plugin.Error("pprof", c.Errf("property '%s' invalid integer value '%v'", "block", args[0]))
+ }
+ h.rateBloc = t
+ }
+ default:
+ return plugin.Error("pprof", c.Errf("unknown property '%s'", c.Val()))
+ }
}
+
}
pprofOnce.Do(func() {