metrics: fix panic in replication stats reporting (#17979)

This commit is contained in:
Poorna 2023-09-05 10:26:18 -07:00 committed by GitHub
parent 19f70dbfbf
commit 812f5a02d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2085,8 +2085,10 @@ func getReplicationClusterMetrics() *MetricsGroup {
)
mg.RegisterRead(func(_ context.Context) []Metric {
var ml []Metric
// common operational metrics for bucket replication and site replication - published
// at cluster level
if globalReplicationStats != nil {
qs := globalReplicationStats.getNodeQueueStatsSummary()
activeWorkersCount := Metric{
Description: getClusterReplActiveWorkersCountMD(),
@ -2162,7 +2164,7 @@ func getReplicationClusterMetrics() *MetricsGroup {
avgTransferRate.Value = tots.Avg
maxTransferRate.Value = tots.Peak
}
ml := []Metric{
ml = []Metric{
activeWorkersCount,
avgActiveWorkersCount,
maxActiveWorkersCount,
@ -2177,7 +2179,7 @@ func getReplicationClusterMetrics() *MetricsGroup {
maxTransferRate,
mrfCount,
}
}
for ep, health := range globalBucketTargetSys.healthStats() {
// link latency current
m := Metric{
@ -3019,7 +3021,10 @@ func getBucketUsageMetrics() *MetricsGroup {
})
}
if !globalSiteReplicationSys.isEnabled() {
stats := bucketReplStats[bucket].ReplicationStats
var stats BucketReplicationStats
s, ok := bucketReplStats[bucket]
if ok {
stats = s.ReplicationStats
metrics = append(metrics, Metric{
Description: getRepReceivedBytesMD(bucketMetricNamespace),
Value: float64(stats.ReplicaSize),
@ -3030,6 +3035,7 @@ func getBucketUsageMetrics() *MetricsGroup {
Value: float64(stats.ReplicaCount),
VariableLabels: map[string]string{"bucket": bucket},
})
}
if stats.hasReplicationUsage() {
for arn, stat := range stats.Stats {
metrics = append(metrics, Metric{