Skip to content

Commit

Permalink
fix: histogram issues (#1598)
Browse files Browse the repository at this point in the history
* fix: histogram issues

* feat: address review comments
  • Loading branch information
rahulguptajss committed Dec 7, 2022
1 parent 67a4ab7 commit e3b210e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
5 changes: 3 additions & 2 deletions cmd/collectors/restperf/restperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ func (r *RestPerf) PollData() (map[string]*matrix.Matrix, error) {
for name, metric := range r.Prop.Metrics {
f := parseMetricResponse(instanceData, name)
if f.value != "" {
description := strings.ToLower(r.perfProp.counterInfo[name].description)
// special case for workload_detail
if isWorkloadDetailObject(r.Prop.Query) {
if name == "wait_time" || name == "service_time" {
Expand Down Expand Up @@ -680,7 +681,7 @@ func (r *RestPerf) PollData() (map[string]*matrix.Matrix, error) {
// ONTAP does not have a `type` for histogram. Harvest tests the `desc` field to determine
// if a counter is a histogram
isHistogram = false
if len(labels) > 0 && strings.Contains(r.perfProp.counterInfo[name].description, "histogram") {
if len(labels) > 0 && strings.Contains(description, "histogram") {
key := name + ".bucket"
histogramMetric = curMat.GetMetric(key)
if histogramMetric != nil {
Expand Down Expand Up @@ -828,7 +829,7 @@ func (r *RestPerf) PollData() (map[string]*matrix.Matrix, error) {
orderedDenominatorKeys := make([]string, 0, len(orderedDenominatorMetrics))

for key, metric := range curMat.GetMetrics() {
if metric.GetName() != "timestamp" {
if metric.GetName() != "timestamp" && metric.Buckets() == nil {
counter := r.counterLookup(metric, key)
if counter != nil {
if counter.denominator == "" {
Expand Down
4 changes: 2 additions & 2 deletions cmd/collectors/zapiperf/zapiperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,13 +557,13 @@ func (z *ZapiPerf) PollData() (map[string]*matrix.Matrix, error) {
orderedKeys := make([]string, 0, len(orderedMetrics))

for key, metric := range curMat.GetMetrics() {
if metric.GetComment() == "" { // does not require base counter
if metric.GetComment() == "" && metric.Buckets() == nil { // does not require base counter
orderedMetrics = append(orderedMetrics, metric)
orderedKeys = append(orderedKeys, key)
}
}
for key, metric := range curMat.GetMetrics() {
if metric.GetComment() != "" { // requires base counter
if metric.GetComment() != "" && metric.Buckets() == nil { // requires base counter
orderedMetrics = append(orderedMetrics, metric)
orderedKeys = append(orderedKeys, key)
}
Expand Down
11 changes: 10 additions & 1 deletion pkg/matrix/matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (m *Matrix) NewMetricType(key string, dataType string, display ...string) (

func newAbstract(key string, dataType string, display ...string) *Metric {
name := key
if len(display) > 0 {
if len(display) > 0 && display[0] != "" {
name = display[0]
}
return &Metric{name: name, dataType: dataType, exportable: true}
Expand Down Expand Up @@ -330,6 +330,7 @@ func (m *Matrix) Delta(metricKey string, prevMat *Matrix, logger *logging.Logger
skips++
logger.Trace().
Str("metric", curMetric.GetName()).
Str("key", key).
Float64("currentRaw", curRaw).
Float64("previousRaw", prevRaw[prevIndex]).
Str("instKey", key).
Expand All @@ -340,6 +341,7 @@ func (m *Matrix) Delta(metricKey string, prevMat *Matrix, logger *logging.Logger
skips++
logger.Trace().
Str("metric", curMetric.GetName()).
Str("key", key).
Float64("currentRaw", curRaw).
Float64("previousRaw", prevRaw[prevIndex]).
Str("instKey", key).
Expand All @@ -350,6 +352,7 @@ func (m *Matrix) Delta(metricKey string, prevMat *Matrix, logger *logging.Logger
skips++
logger.Trace().
Str("metric", curMetric.GetName()).
Str("key", key).
Float64("currentRaw", curRaw).
Str("instKey", key).
Msg("New instance added")
Expand Down Expand Up @@ -377,6 +380,7 @@ func (m *Matrix) Divide(metricKey string, baseKey string, logger *logging.Logger
skips++
logger.Trace().
Str("metric", metric.GetName()).
Str("key", metricKey).
Float64("numerator", metric.values[i]).
Float64("denominator", sValues[i]).
Msg("Divide calculation skipped")
Expand All @@ -390,6 +394,7 @@ func (m *Matrix) Divide(metricKey string, baseKey string, logger *logging.Logger
skips++
logger.Trace().
Str("metric", metric.GetName()).
Str("key", metricKey).
Float64("numerator", metric.values[i]).
Float64("denominator", sValues[i]).
Msg("Divide calculation skipped")
Expand Down Expand Up @@ -417,6 +422,7 @@ func (m *Matrix) DivideWithThreshold(metricKey string, baseKey string, threshold
skips++
logger.Trace().
Str("metric", metric.GetName()).
Str("key", metricKey).
Float64("numerator", v).
Float64("denominator", sValues[i]).
Msg("Negative values")
Expand All @@ -433,6 +439,7 @@ func (m *Matrix) DivideWithThreshold(metricKey string, baseKey string, threshold
skips++
logger.Trace().
Str("metric", metric.GetName()).
Str("key", metricKey).
Float64("numerator", metric.values[i]).
Float64("denominator", sValues[i]).
Msg("Divide threshold calculation skipped")
Expand All @@ -453,6 +460,7 @@ func (m *Matrix) MultiplyByScalar(metricKey string, s uint, logger *logging.Logg
skips++
logger.Trace().
Str("metric", metric.GetName()).
Str("key", metricKey).
Float64("currentRaw", metric.values[i]).
Uint("scalar", s).
Msg("Negative value")
Expand All @@ -463,6 +471,7 @@ func (m *Matrix) MultiplyByScalar(metricKey string, s uint, logger *logging.Logg
skips++
logger.Trace().
Str("metric", metric.GetName()).
Str("key", metricKey).
Float64("currentRaw", metric.values[i]).
Uint("scalar", s).
Msg("Scalar multiplication skipped")
Expand Down

0 comments on commit e3b210e

Please sign in to comment.