From 46830a3c8fdecc36e430802738de0c535c967ace Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Thu, 20 Feb 2014 13:51:51 -0800 Subject: [PATCH] agent: Enable dumping telemetry on SIGUSR1 --- command/agent/command.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/command/agent/command.go b/command/agent/command.go index f3fc96457..641a43110 100644 --- a/command/agent/command.go +++ b/command/agent/command.go @@ -3,6 +3,7 @@ package agent import ( "flag" "fmt" + "github.com/armon/go-metrics" "github.com/hashicorp/logutils" "github.com/mitchellh/cli" "io" @@ -187,6 +188,16 @@ func (c *Command) Run(args []string) int { return 1 } + /* Setup telemetry + Aggregate on 10 second intervals for 1 minute. Expose the + metrics over stderr when there is a SIGUSR1 received. + */ + inm := metrics.NewInmemSink(10*time.Second, time.Minute) + metrics.DefaultInmemSignal(inm) + metricsConf := metrics.DefaultConfig("consul") + metricsConf.EnableHostname = false + metrics.NewGlobal(metricsConf, inm) + // Create the agent if err := c.setupAgent(config, logOutput, logWriter); err != nil { return 1