diff --git a/diagnostics.go b/diagnostics.go index 6ad6e16b1..8bdcdef3c 100644 --- a/diagnostics.go +++ b/diagnostics.go @@ -37,8 +37,8 @@ type versionResponse struct { Message string `json:"message"` } -// DiagnosticsCollector represents a collector/sender of diagnostics data. -type DiagnosticsCollector struct { +// diagnosticsCollector represents a collector/sender of diagnostics data. +type diagnosticsCollector struct { mu sync.Mutex host string VersionURL string @@ -57,8 +57,8 @@ type DiagnosticsCollector struct { } // NewDiagnosticsCollector returns a new DiagnosticsCollector given an addr in the format "hostname:port". -func NewDiagnosticsCollector(host string) *DiagnosticsCollector { - return &DiagnosticsCollector{ +func NewDiagnosticsCollector(host string) *diagnosticsCollector { + return &diagnosticsCollector{ host: host, VersionURL: defaultVersionCheckURL, startTime: time.Now().Unix(), @@ -70,13 +70,13 @@ func NewDiagnosticsCollector(host string) *DiagnosticsCollector { } // SetVersion of locally running Pilosa Cluster to check against master. -func (d *DiagnosticsCollector) SetVersion(v string) { +func (d *diagnosticsCollector) SetVersion(v string) { d.version = v d.Set("Version", v) } // Flush sends the current metrics. -func (d *DiagnosticsCollector) Flush() error { +func (d *diagnosticsCollector) Flush() error { d.mu.Lock() defer d.mu.Unlock() d.metrics["Uptime"] = (time.Now().Unix() - d.startTime) @@ -99,7 +99,7 @@ func (d *DiagnosticsCollector) Flush() error { } // CheckVersion of the local build against Pilosa master. -func (d *DiagnosticsCollector) CheckVersion() error { +func (d *diagnosticsCollector) CheckVersion() error { var rsp versionResponse req, err := http.NewRequest("GET", d.VersionURL, nil) if err != nil { @@ -131,7 +131,7 @@ func (d *DiagnosticsCollector) CheckVersion() error { } // compareVersion check version strings. -func (d *DiagnosticsCollector) compareVersion(value string) error { +func (d *diagnosticsCollector) compareVersion(value string) error { currentVersion := versionSegments(value) localVersion := versionSegments(d.version) @@ -147,12 +147,12 @@ func (d *DiagnosticsCollector) compareVersion(value string) error { } // Encode metrics maps into the json message format. -func (d *DiagnosticsCollector) encode() ([]byte, error) { +func (d *diagnosticsCollector) encode() ([]byte, error) { return json.Marshal(d.metrics) } // Set adds a key value metric. -func (d *DiagnosticsCollector) Set(name string, value interface{}) { +func (d *diagnosticsCollector) Set(name string, value interface{}) { switch v := value.(type) { case string: if v == "" { @@ -166,7 +166,7 @@ func (d *DiagnosticsCollector) Set(name string, value interface{}) { } // logErr logs the error and returns true if an error exists -func (d *DiagnosticsCollector) logErr(err error) bool { +func (d *diagnosticsCollector) logErr(err error) bool { if err != nil { d.Logger.Printf("%v", err) return true @@ -175,7 +175,7 @@ func (d *DiagnosticsCollector) logErr(err error) bool { } // EnrichWithOSInfo adds OS information to the diagnostics payload. -func (d *DiagnosticsCollector) EnrichWithOSInfo() { +func (d *diagnosticsCollector) EnrichWithOSInfo() { uptime, err := d.server.systemInfo.Uptime() if !d.logErr(err) { d.Set("HostUptime", uptime) @@ -199,7 +199,7 @@ func (d *DiagnosticsCollector) EnrichWithOSInfo() { } // EnrichWithMemoryInfo adds memory information to the diagnostics payload. -func (d *DiagnosticsCollector) EnrichWithMemoryInfo() { +func (d *diagnosticsCollector) EnrichWithMemoryInfo() { memFree, err := d.server.systemInfo.MemFree() if !d.logErr(err) { d.Set("MemFree", memFree) @@ -215,7 +215,7 @@ func (d *DiagnosticsCollector) EnrichWithMemoryInfo() { } // EnrichWithSchemaProperties adds schema info to the diagnostics payload. -func (d *DiagnosticsCollector) EnrichWithSchemaProperties() { +func (d *diagnosticsCollector) EnrichWithSchemaProperties() { var numShards uint64 numFields := 0 numIndexes := 0 diff --git a/server.go b/server.go index 3adf3bb50..38c8d9426 100644 --- a/server.go +++ b/server.go @@ -50,7 +50,7 @@ type Server struct { holder *Holder cluster *cluster translateFile *TranslateFile - diagnostics *DiagnosticsCollector + diagnostics *diagnosticsCollector executor *executor hosts []string clusterDisabled bool