agent: Enable dumping telemetry on SIGUSR1

This commit is contained in:
Armon Dadgar 2014-02-20 13:51:51 -08:00
parent c975f5b968
commit 46830a3c8f
1 changed files with 11 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package agent
import ( import (
"flag" "flag"
"fmt" "fmt"
"github.com/armon/go-metrics"
"github.com/hashicorp/logutils" "github.com/hashicorp/logutils"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
"io" "io"
@ -187,6 +188,16 @@ func (c *Command) Run(args []string) int {
return 1 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 // Create the agent
if err := c.setupAgent(config, logOutput, logWriter); err != nil { if err := c.setupAgent(config, logOutput, logWriter); err != nil {
return 1 return 1