Skip to content

Commit 4368453

Browse files
committed
fix test
Signed-off-by: Ben Ye <[email protected]>
1 parent b6b69d0 commit 4368453

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

pkg/util/metrics_helper.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ func (m *MergedMetricFamily) CreateMetricFamily() *dto.MetricFamily {
831831

832832
for _, metric := range m.metricMap.metrics {
833833
for _, m := range metric {
834-
metrics = append(metrics, &m.metric)
834+
metrics = append(metrics, m.metric)
835835
}
836836
}
837837

@@ -855,7 +855,7 @@ func MergeMetricFamilies(metricFamilies []MetricFamilyMap) (MetricFamilyMap, err
855855
}
856856

857857
for _, metric := range metricFamily.Metric {
858-
(mergedMap[metricName].metricMap).AddOrSetMetric(*metric, mergeFunc)
858+
(mergedMap[metricName].metricMap).AddOrSetMetric(metric, mergeFunc)
859859
}
860860
}
861861
}
@@ -923,7 +923,7 @@ type MetricMap struct {
923923
}
924924

925925
type Metric struct {
926-
metric dto.Metric
926+
metric *dto.Metric
927927
lock sync.Mutex
928928
}
929929

@@ -935,7 +935,7 @@ func NewMetricMap() MetricMap {
935935

936936
// AddOrSetMetric - given a metric, see if there's another metric with the same labels. If not, add metric to list
937937
// If yes, call mergeFn to merge the two metrics in-place, and updating existing metric
938-
func (m *MetricMap) AddOrSetMetric(metric dto.Metric, mergeFn func(existing *dto.Metric, new *dto.Metric)) {
938+
func (m *MetricMap) AddOrSetMetric(metric *dto.Metric, mergeFn func(existing *dto.Metric, new *dto.Metric)) {
939939
var metricLabels []string
940940
for _, labelPair := range metric.GetLabel() {
941941
metricLabels = append(metricLabels, fmt.Sprintf("%s=%s", labelPair.GetName(), labelPair.GetValue()))
@@ -952,7 +952,7 @@ func (m *MetricMap) AddOrSetMetric(metric dto.Metric, mergeFn func(existing *dto
952952
same := m.compareLabels(existingMetric.metric.GetLabel(), metric.GetLabel())
953953
if same {
954954
existingMetric.lock.Lock()
955-
mergeFn(&existingMetric.metric, &metric)
955+
mergeFn(existingMetric.metric, metric)
956956
existingMetric.lock.Unlock()
957957
return
958958
}

0 commit comments

Comments
 (0)