changed the diagnostics configuration option to a boolean

This commit is contained in:
Michael Baird 2017-10-24 10:40:21 -05:00
parent 6f0ee1cf17
commit c14f72b66a
6 changed files with 19 additions and 16 deletions

View file

@ -43,9 +43,6 @@ const (
// DefaultMaxWritesPerRequest is the default number of writes per request.
DefaultMaxWritesPerRequest = 5000
// DefaultDiagnosticsInterval is the default sync frequency diagnostic metrics.
DefaultDiagnosticsInterval = 1 * time.Hour
)
// ClusterTypes set of cluster types.
@ -91,10 +88,10 @@ type Config struct {
LogPath string `toml:"log-path"`
Metric struct {
Service string `toml:"service"`
Host string `toml:"host"`
PollInterval Duration `toml:"poll-interval"`
DiagnosticInterval Duration `toml:"diagnostics"`
Service string `toml:"service"`
Host string `toml:"host"`
PollInterval Duration `toml:"poll-interval"`
Diagnostics bool `toml:"diagnostics"`
} `toml:"metric"`
TLS TLSConfig
@ -112,7 +109,7 @@ func NewConfig() *Config {
c.Cluster.Hosts = []string{}
c.AntiEntropy.Interval = Duration(DefaultAntiEntropyInterval)
c.Metric.Service = DefaultMetrics
c.Metric.DiagnosticInterval = Duration(DefaultDiagnosticsInterval)
c.Metric.Diagnostics = true
c.TLS = TLSConfig{}
return c
}

View file

@ -41,7 +41,7 @@ func BuildServerFlags(cmd *cobra.Command, srv *server.Command) {
flags.StringVarP(&srv.Config.Cluster.Type, "cluster.type", "", "gossip", "Determine how the cluster handles membership and state sharing. Choose from [static, gossip]")
flags.StringVarP(&srv.Config.Metric.Service, "metric.service", "", "nop", "Default URI on which pilosa should listen.")
flags.StringVarP(&srv.Config.Metric.Host, "metric.host", "", "", "Default URI to send metrics.")
flags.DurationVarP((*time.Duration)(&srv.Config.Metric.DiagnosticInterval), "metric.diagnostics", "", time.Hour*1, "Diagnostic reporting interval back to Pilosa.")
flags.BoolVarP((&srv.Config.Metric.Diagnostics), "metric.diagnostics", "", true, "Enabled diagnostics reporting.")
flags.DurationVarP((*time.Duration)(&srv.Config.Metric.PollInterval), "metric.poll-interval", "", time.Minute*0, "Polling interval metrics.")
SetTLSConfig(flags, &srv.Config.TLS.CertificatePath, &srv.Config.TLS.CertificateKeyPath, &srv.Config.TLS.SkipVerify)
}

View file

@ -131,7 +131,7 @@ Each Pilosa cluster is configured by default to share anonymous usage details wi
<strong id="open_files">OpenFiles:</strong> Open file handle count.
<strong id="go_routines">GoRoutines:</strong> Go routine count.
You can opt-out of the Pilosa diagnostics reporting by setting the `diagnostics` configuration option under `metric` to `0m0s`.
You can opt-out of the Pilosa diagnostics reporting by setting either the `metric.diagnostics` configuration option to false, using the `PILOSA_METRIC_DIAGNOSTICS` environment variable, or the TOML configuration file `[metric]` `diagnostics` option.
#### Metrics

View file

@ -206,16 +206,16 @@ Any flag that has a value that is a comma separated list on the command line bec
poll-interval = "0m15s"
```
##### Metric Diagnostics Interval
##### Metric Diagnostics
* Description: Diagnostic reporting interval. To disable diagnostics set to zero.
* Flag: `metric.diagnostics=”60m0s”`
* Env: `PILOSA_METRIC_DIAGNOSTICS=60m0s`
* Description: Enable diagnostic reporting. To disable diagnostics set to false.
* Flag: `metric.diagnostics`
* Env: `PILOSA_METRIC_DIAGNOSTICS`
* Config:
```toml
[metric]
diagnostics = "60m0s"
diagnostics = true
```

View file

@ -517,6 +517,7 @@ func (s *Server) checkMaxSlices(scheme string, hostPort string) (map[string]uint
// monitorDiagnostics periodically polls the the Pilosa Indexes for cluster info.
func (s *Server) monitorDiagnostics() {
if s.DiagnosticInterval <= 0 {
s.Logger().Printf("diagnostics disabled")
return
}

View file

@ -43,6 +43,9 @@ func init() {
const (
// DefaultDataDir is the default data directory.
DefaultDataDir = "~/.pilosa"
// DefaultDiagnosticsInterval is the default sync frequency diagnostic metrics.
DefaultDiagnosticsInterval = 1 * time.Hour
)
// Command represents the state of the pilosa server command.
@ -143,8 +146,10 @@ func (m *Command) SetupServer() error {
m.Server.Logger().Printf("Using data from: %s\n", m.Config.DataDir)
m.Server.Holder.Path = m.Config.DataDir
m.Server.MetricInterval = time.Duration(m.Config.Metric.PollInterval)
if m.Config.Metric.Diagnostics {
m.Server.DiagnosticInterval = time.Duration(DefaultDiagnosticsInterval)
}
m.Server.Holder.Stats, err = NewStatsClient(m.Config.Metric.Service, m.Config.Metric.Host)
m.Server.DiagnosticInterval = time.Duration(m.Config.Metric.DiagnosticInterval)
if err != nil {
return err
}