Conversation
|
Validated with below template changes, |
There was a problem hiding this comment.
Pull request overview
This PR updates the MetricAgent plugin so compute_metric rules can operate when the required operands are split across multiple matrices (instead of assuming a single object-keyed matrix), and adjusts/adds unit tests to cover the multi-matrix scenario.
Changes:
- Changed
MetricAgent.actionsto accept the fulldataMap(map[string]*matrix.Matrix) rather than a single*matrix.Matrix. - Updated
computeMetricsto select operand matrices per rule/operand (enabling multi-matrix support). - Updated the single-matrix test to run through
Run(), and added a new multi-matrix test case.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cmd/poller/plugin/metricagent/parse_rules.go | Updates action function signature to accept the full matrix map. |
| cmd/poller/plugin/metricagent/metric_agent.go | Passes dataMap through actions and updates compute logic for multi-matrix operands. |
| cmd/poller/plugin/metricagent/metric_agent_test.go | Renames/updates existing test to call Run() and adds a multi-matrix test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
cmd/poller/plugin/metricagent/metric_agent.go:155
- If an operand metric isn't found, this appends
err(typically nil from the precedingAtoifailure) and breaks out without settingskipMetric, so the derived metric can be written with a partial/incorrect result and the missing-metric details are lost. Append a concrete error and markskipMetricbefore breaking.
} else {
metricNotFound = append(metricNotFound, err)
break
}
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
cmd/poller/plugin/metricagent/metric_agent.go:155
- When an operand metric is missing, this appends
errtometricNotFound, buterrhere is the strconv.Atoi parse error for the metric name (or nil) rather than a "missing metric" error. Record a concrete error tied to the missing metric so the warning at the end is actionable.
} else {
metricNotFound = append(metricNotFound, err)
break
}
|
I agree with these review comments from Sonnet 4.6 sgMatrix / sgIndex embed a StorageGrid-specific name in a general pluginThe MetricAgent plugin isn't StorageGrid-specific, but these variable names suggest it is. Names like isMultiMatrix and instanceIndex would better convey intent. The instance key convention (metricName + "-" + index) is unexplainedThe key parsing via strings.LastIndex(iKey, "-") only works because StorageGrid's collector always constructs keys as metricName + "-" + strconv.Itoa(i) (confirmed at storagegrid.go:219). There's no comment noting this contract. A future maintainer reading only metric_agent.go would have no idea why the index is extracted by splitting on the last -. |
handled. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
cmd/poller/plugin/metricagent/metric_agent.go:194
- This warning logs an empty message and uses a field key containing spaces/colon, which makes the structured log harder to query. Consider using a clear message and a stable field name.
if len(metricNotFound) > 0 {
a.SLogger.Warn("", slog.Any("computeMetrics: errors for metric not found", metricNotFound))
}
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
cmd/poller/plugin/metricagent/metric_agent.go:200
computeMetricsaccumulatesmetricNotFounderrors, but currently only logs them (with an empty log message) and then returnsnil. This preventsRunfrom surfacing missing-metric failures via itserrors.Joinreturn, making misconfiguredcompute_metricrules easy to miss (andmetricNotFoundconstruction effectively unused).
if len(metricNotFound) > 0 {
a.SLogger.Warn("", slog.Any("computeMetrics: errors for metric not found", metricNotFound))
}
return nil
| } | ||
| } | ||
| if m[0] == nil { | ||
| return errs.New(errs.ErrMissingMetric, "matrix not found for metric "+r.metricNames[0]) |
There was a problem hiding this comment.
Should here we use continue? a missing matrix for one rule shouldn't abort all remaining rules
| if val, ok := metricVal.GetValueFloat64(otherInstance); ok { | ||
| v = val | ||
| } else { | ||
| continue |
There was a problem hiding this comment.
Should this be
skipMetric = true
break
like other checks?

Added supporting test cases as well.