diff --git a/cmd/collectors/rest/rest.go b/cmd/collectors/rest/rest.go index 6eae94280..eba2dc9b7 100644 --- a/cmd/collectors/rest/rest.go +++ b/cmd/collectors/rest/rest.go @@ -52,7 +52,7 @@ type Rest struct { Client *rest.Client Prop *prop endpoints []*EndPoint - IsIgnoreUnknownFieldsEnabled bool + isIgnoreUnknownFieldsEnabled bool } type EndPoint struct { @@ -111,7 +111,7 @@ func (r *Rest) Fields(prop *prop) []string { fields := prop.Fields if prop.IsPublic { // applicable for public API only - if !r.IsIgnoreUnknownFieldsEnabled || !r.isValidFormat(prop) { + if !r.isIgnoreUnknownFieldsEnabled || !r.isValidFormat(prop) { fields = []string{"*"} } } @@ -349,9 +349,9 @@ func (r *Rest) PollCounter() (map[string]*matrix.Matrix, error) { } // Check the version if it is 9.11.1 then pass relevant fields and not * if v { - r.IsIgnoreUnknownFieldsEnabled = true + r.isIgnoreUnknownFieldsEnabled = true } else { - r.IsIgnoreUnknownFieldsEnabled = false + r.isIgnoreUnknownFieldsEnabled = false } r.updateHref() parseD := time.Since(startTime) @@ -368,7 +368,7 @@ func (r *Rest) updateHref() { Fields(r.Fields(r.Prop)). Filter(r.Prop.Filter). ReturnTimeout(r.Prop.ReturnTimeOut). - IsIgnoreUnknownFieldsEnabled(r.IsIgnoreUnknownFieldsEnabled). + IsIgnoreUnknownFieldsEnabled(r.isIgnoreUnknownFieldsEnabled). Build() for _, e := range r.endpoints { @@ -377,7 +377,7 @@ func (r *Rest) updateHref() { Fields(r.Fields(e.prop)). Filter(r.filter(e)). ReturnTimeout(r.Prop.ReturnTimeOut). - IsIgnoreUnknownFieldsEnabled(r.IsIgnoreUnknownFieldsEnabled). + IsIgnoreUnknownFieldsEnabled(r.isIgnoreUnknownFieldsEnabled). Build() } } diff --git a/cmd/collectors/rest/rest_test.go b/cmd/collectors/rest/rest_test.go index d2d67d42c..6251cbe39 100644 --- a/cmd/collectors/rest/rest_test.go +++ b/cmd/collectors/rest/rest_test.go @@ -269,7 +269,7 @@ func TestFields(t *testing.T) { { name: "Test with valid fields and no hidden fields", r: &Rest{ - IsIgnoreUnknownFieldsEnabled: true, + isIgnoreUnknownFieldsEnabled: true, }, p: &prop{ Fields: []string{ @@ -288,7 +288,7 @@ func TestFields(t *testing.T) { { name: "Test with invalid fields and no hidden fields", r: &Rest{ - IsIgnoreUnknownFieldsEnabled: true, + isIgnoreUnknownFieldsEnabled: true, }, p: &prop{ Fields: []string{ @@ -303,7 +303,7 @@ func TestFields(t *testing.T) { { name: "Test with valid fields and hidden fields", r: &Rest{ - IsIgnoreUnknownFieldsEnabled: true, + isIgnoreUnknownFieldsEnabled: true, }, p: &prop{ Fields: []string{ @@ -328,7 +328,7 @@ func TestFields(t *testing.T) { { name: "Test with valid fields and hidden fields and prior versions to 9.11.1", r: &Rest{ - IsIgnoreUnknownFieldsEnabled: false, + isIgnoreUnknownFieldsEnabled: false, }, p: &prop{ Fields: []string{ @@ -351,7 +351,7 @@ func TestFields(t *testing.T) { { name: "Test with valid fields and no hidden fields for private API", r: &Rest{ - IsIgnoreUnknownFieldsEnabled: false, + isIgnoreUnknownFieldsEnabled: false, }, p: &prop{ Fields: []string{ @@ -370,7 +370,7 @@ func TestFields(t *testing.T) { { name: "Test with invalid fields and no hidden fields, ignore unknown fields disabled", r: &Rest{ - IsIgnoreUnknownFieldsEnabled: false, + isIgnoreUnknownFieldsEnabled: false, }, p: &prop{ Fields: []string{ @@ -385,7 +385,7 @@ func TestFields(t *testing.T) { { name: "Test with invalid fields and no hidden fields for private API", r: &Rest{ - IsIgnoreUnknownFieldsEnabled: true, + isIgnoreUnknownFieldsEnabled: true, }, p: &prop{ Fields: []string{ @@ -404,7 +404,7 @@ func TestFields(t *testing.T) { { name: "Test with valid fields and hidden fields for private API", r: &Rest{ - IsIgnoreUnknownFieldsEnabled: true, + isIgnoreUnknownFieldsEnabled: true, }, p: &prop{ Fields: []string{ diff --git a/cmd/collectors/zapiperf/zapiperf.go b/cmd/collectors/zapiperf/zapiperf.go index d0e660c43..f5cbd2382 100644 --- a/cmd/collectors/zapiperf/zapiperf.go +++ b/cmd/collectors/zapiperf/zapiperf.go @@ -67,6 +67,7 @@ const ( objWorkloadClass = "user_defined|system_defined" objWorkloadVolumeClass = "autovolume" BILLION = 1_000_000_000 + timestampMetricName = "timestamp" ) var workloadDetailMetrics = []string{"resource_latency"} @@ -396,7 +397,7 @@ func (z *ZapiPerf) PollData() (map[string]*matrix.Matrix, error) { curMat := prevMat.Clone(matrix.With{Data: false, Metrics: true, Instances: true, ExportInstances: false}) curMat.Reset() - timestamp := curMat.GetMetric("timestamp") + timestamp := curMat.GetMetric(timestampMetricName) if timestamp == nil { return nil, errs.New(errs.ErrConfig, "missing timestamp metric") // @TODO errconfig?? } @@ -775,7 +776,7 @@ func (z *ZapiPerf) PollData() (map[string]*matrix.Matrix, error) { // calculate timestamp delta first since many counters require it for postprocessing. // Timestamp has "raw" property, so it isn't post-processed automatically - if _, err = curMat.Delta("timestamp", prevMat, z.Logger); err != nil { + if _, err = curMat.Delta(timestampMetricName, prevMat, z.Logger); err != nil { z.Logger.Error().Err(err).Msg("(timestamp) calculate delta:") // @TODO terminate since other counters will be incorrect } @@ -842,7 +843,7 @@ func (z *ZapiPerf) PollData() (map[string]*matrix.Matrix, error) { if property == "average" || property == "percent" { if strings.HasSuffix(metric.GetName(), "latency") { - skips, err = curMat.DivideWithThreshold(key, metric.GetComment(), z.latencyIoReqd, cachedData, prevMat, "timestamp", z.Logger) + skips, err = curMat.DivideWithThreshold(key, metric.GetComment(), z.latencyIoReqd, cachedData, prevMat, timestampMetricName, z.Logger) } else { skips, err = curMat.Divide(key, metric.GetComment()) } @@ -874,7 +875,7 @@ func (z *ZapiPerf) PollData() (map[string]*matrix.Matrix, error) { // calculate rates (which we deferred to calculate averages/percents first) for i, metric := range orderedMetrics { if metric.GetProperty() == "rate" { - if skips, err = curMat.Divide(orderedKeys[i], "timestamp"); err != nil { + if skips, err = curMat.Divide(orderedKeys[i], timestampMetricName); err != nil { z.Logger.Error().Err(err). Int("i", i). Str("key", orderedKeys[i]). @@ -1185,8 +1186,8 @@ func (z *ZapiPerf) PollCounter() (map[string]*matrix.Matrix, error) { // Create an artificial metric to hold timestamp of each instance data. // The reason we don't keep a single timestamp for the whole data // is because we might get instances in different batches - if !oldMetrics.Has("timestamp") { - m, err := mat.NewMetricFloat64("timestamp") + if !oldMetrics.Has(timestampMetricName) { + m, err := mat.NewMetricFloat64(timestampMetricName) if err != nil { z.Logger.Error().Err(err).Msg("add timestamp metric") } @@ -1275,7 +1276,7 @@ func (z *ZapiPerf) PollCounter() (map[string]*matrix.Matrix, error) { for key := range oldMetrics.Iter() { // temporary fix: prevent removing array counters // @TODO - if key != "timestamp" && !strings.Contains(key, ".") { + if key != timestampMetricName && !strings.Contains(key, ".") { mat.RemoveMetric(key) z.Logger.Debug().Msgf("removed metric [%s]", key) }