golint monitor package. Supports #4098
parent
8fe2469c75
commit
3e4d2a1fb0
|
@ -18,6 +18,7 @@ import (
|
|||
|
||||
const leaderWaitTimeout = 30 * time.Second
|
||||
|
||||
// Policy constants.
|
||||
const (
|
||||
MonitorRetentionPolicy = "monitor"
|
||||
MonitorRetentionPolicyDuration = 7 * 24 * time.Hour
|
||||
|
@ -50,6 +51,7 @@ type Diagnostic struct {
|
|||
Rows [][]interface{}
|
||||
}
|
||||
|
||||
// NewDiagnostic initialises a new Diagnostic with the specified columns.
|
||||
func NewDiagnostic(columns []string) *Diagnostic {
|
||||
return &Diagnostic{
|
||||
Columns: columns,
|
||||
|
@ -57,6 +59,7 @@ func NewDiagnostic(columns []string) *Diagnostic {
|
|||
}
|
||||
}
|
||||
|
||||
// AddRow appends the provided row to the Diagnostic's rows.
|
||||
func (d *Diagnostic) AddRow(r []interface{}) {
|
||||
d.Rows = append(d.Rows, r)
|
||||
}
|
||||
|
@ -172,7 +175,7 @@ func (m *Monitor) DeregisterDiagnosticsClient(name string) {
|
|||
// Statistics returns the combined statistics for all expvar data. The given
|
||||
// tags are added to each of the returned statistics.
|
||||
func (m *Monitor) Statistics(tags map[string]string) ([]*Statistic, error) {
|
||||
statistics := make([]*Statistic, 0)
|
||||
var statistics []*Statistic
|
||||
|
||||
expvar.Do(func(kv expvar.KeyValue) {
|
||||
// Skip built-in expvar stats.
|
||||
|
@ -281,6 +284,9 @@ func (m *Monitor) Statistics(tags map[string]string) ([]*Statistic, error) {
|
|||
return statistics, nil
|
||||
}
|
||||
|
||||
// Diagnostics fetches diagnostic information for each registered
|
||||
// diagnostic client. It skips any clients that return an error when
|
||||
// retrieving their diagnostics.
|
||||
func (m *Monitor) Diagnostics() (map[string]*Diagnostic, error) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
|
@ -412,7 +418,7 @@ func newStatistic(name string, tags map[string]string, values map[string]interfa
|
|||
// valueNames returns a sorted list of the value names, if any.
|
||||
func (s *Statistic) valueNames() []string {
|
||||
a := make([]string, 0, len(s.Values))
|
||||
for k, _ := range s.Values {
|
||||
for k := range s.Values {
|
||||
a = append(a, k)
|
||||
}
|
||||
sort.Strings(a)
|
||||
|
@ -423,7 +429,7 @@ func (s *Statistic) valueNames() []string {
|
|||
func DiagnosticFromMap(m map[string]interface{}) *Diagnostic {
|
||||
// Display columns in deterministic order.
|
||||
sortedKeys := make([]string, 0, len(m))
|
||||
for k, _ := range m {
|
||||
for k := range m {
|
||||
sortedKeys = append(sortedKeys, k)
|
||||
}
|
||||
sort.Strings(sortedKeys)
|
||||
|
|
|
@ -33,8 +33,8 @@ func (s *StatementExecutor) executeShowStatistics(module string) *influxql.Resul
|
|||
if err != nil {
|
||||
return &influxql.Result{Err: err}
|
||||
}
|
||||
rows := make([]*models.Row, 0)
|
||||
|
||||
var rows []*models.Row
|
||||
for _, stat := range stats {
|
||||
if module != "" && stat.Name != module {
|
||||
continue
|
||||
|
@ -61,7 +61,7 @@ func (s *StatementExecutor) executeShowDiagnostics(module string) *influxql.Resu
|
|||
|
||||
// Get a sorted list of diagnostics keys.
|
||||
sortedKeys := make([]string, 0, len(diags))
|
||||
for k, _ := range diags {
|
||||
for k := range diags {
|
||||
sortedKeys = append(sortedKeys, k)
|
||||
}
|
||||
sort.Strings(sortedKeys)
|
||||
|
|
Loading…
Reference in New Issue