Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: histogram issues #1598

Merged
merged 2 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/collectors/restperf/restperf.go
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,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(strings.ToLower(r.perfProp.counterInfo[name].description), "histogram") {
key := name + ".bucket"
histogramMetric = curMat.GetMetric(key)
if histogramMetric != nil {
Expand Down Expand Up @@ -828,7 +828,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" && !strings.Contains(key, ".bucket") {
counter := r.counterLookup(metric, key)
if counter != nil {
if counter.denominator == "" {
Expand Down
6 changes: 3 additions & 3 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() == "" && !strings.Contains(key, ".bucket") { // 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() != "" && !strings.Contains(key, ".bucket") { // requires base counter
orderedMetrics = append(orderedMetrics, metric)
orderedKeys = append(orderedKeys, key)
}
Expand Down Expand Up @@ -1168,7 +1168,7 @@ func (z *ZapiPerf) addCounter(counter *node.Node, name, display string, enabled
// 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(description, "histogram") {
if len(labels) > 0 && strings.Contains(strings.ToLower(description), "histogram") {
key := name + ".bucket"
histogramMetric = mat.GetMetric(key)
if histogramMetric != nil {
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