mirror of
https://github.com/minio/minio.git
synced 2024-12-26 15:15:55 -05:00
parent
22aa16ab12
commit
92180bc793
@ -420,14 +420,14 @@ func (g *MetricsGroup) RegisterRead(read func(ctx context.Context) []Metric) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Metric) copyMetric() Metric {
|
func (m *Metric) clone() Metric {
|
||||||
metric := Metric{
|
metric := Metric{
|
||||||
Description: m.Description,
|
Description: m.Description,
|
||||||
Value: m.Value,
|
Value: m.Value,
|
||||||
HistogramBucketLabel: m.HistogramBucketLabel,
|
HistogramBucketLabel: m.HistogramBucketLabel,
|
||||||
StaticLabels: make(map[string]string),
|
StaticLabels: make(map[string]string, len(m.StaticLabels)),
|
||||||
VariableLabels: make(map[string]string),
|
VariableLabels: make(map[string]string, len(m.VariableLabels)),
|
||||||
Histogram: make(map[string]uint64),
|
Histogram: make(map[string]uint64, len(m.Histogram)),
|
||||||
}
|
}
|
||||||
for k, v := range m.StaticLabels {
|
for k, v := range m.StaticLabels {
|
||||||
metric.StaticLabels[k] = v
|
metric.StaticLabels[k] = v
|
||||||
@ -453,7 +453,7 @@ func (g *MetricsGroup) Get() (metrics []Metric) {
|
|||||||
|
|
||||||
metrics = make([]Metric, 0, len(m))
|
metrics = make([]Metric, 0, len(m))
|
||||||
for i := range m {
|
for i := range m {
|
||||||
metrics = append(metrics, m[i].copyMetric())
|
metrics = append(metrics, m[i].clone())
|
||||||
}
|
}
|
||||||
return metrics
|
return metrics
|
||||||
}
|
}
|
||||||
|
@ -1007,21 +1007,29 @@ func (s *peerRESTServer) GetBandwidth(params *grid.URLValues) (*bandwidth.Bucket
|
|||||||
|
|
||||||
// GetPeerMetrics gets the metrics to be federated across peers.
|
// GetPeerMetrics gets the metrics to be federated across peers.
|
||||||
func (s *peerRESTServer) GetPeerMetrics(_ *grid.MSS) (*grid.Array[*Metric], *grid.RemoteErr) {
|
func (s *peerRESTServer) GetPeerMetrics(_ *grid.MSS) (*grid.Array[*Metric], *grid.RemoteErr) {
|
||||||
m := ReportMetrics(context.Background(), peerMetricsGroups)
|
res := make([]*Metric, 0, len(peerMetricsGroups))
|
||||||
res := make([]*Metric, 0, len(m))
|
populateAndPublish(peerMetricsGroups, func(m Metric) bool {
|
||||||
for m := range m {
|
if m.VariableLabels == nil {
|
||||||
res = append(res, &m)
|
m.VariableLabels = make(map[string]string, 1)
|
||||||
}
|
}
|
||||||
|
m.VariableLabels[serverName] = globalLocalNodeName
|
||||||
|
res = append(res, &m)
|
||||||
|
return true
|
||||||
|
})
|
||||||
return aoMetricsGroup.NewWith(res), nil
|
return aoMetricsGroup.NewWith(res), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPeerBucketMetrics gets the metrics to be federated across peers.
|
// GetPeerBucketMetrics gets the metrics to be federated across peers.
|
||||||
func (s *peerRESTServer) GetPeerBucketMetrics(_ *grid.MSS) (*grid.Array[*Metric], *grid.RemoteErr) {
|
func (s *peerRESTServer) GetPeerBucketMetrics(_ *grid.MSS) (*grid.Array[*Metric], *grid.RemoteErr) {
|
||||||
m := ReportMetrics(context.Background(), bucketPeerMetricsGroups)
|
res := make([]*Metric, 0, len(bucketPeerMetricsGroups))
|
||||||
res := make([]*Metric, 0, len(m))
|
populateAndPublish(bucketPeerMetricsGroups, func(m Metric) bool {
|
||||||
for m := range m {
|
if m.VariableLabels == nil {
|
||||||
res = append(res, &m)
|
m.VariableLabels = make(map[string]string, 1)
|
||||||
}
|
}
|
||||||
|
m.VariableLabels[serverName] = globalLocalNodeName
|
||||||
|
res = append(res, &m)
|
||||||
|
return true
|
||||||
|
})
|
||||||
return aoMetricsGroup.NewWith(res), nil
|
return aoMetricsGroup.NewWith(res), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,8 +595,10 @@ func (p *ArrayOf[T]) newA(sz uint32) []T {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *ArrayOf[T]) putA(v []T) {
|
func (p *ArrayOf[T]) putA(v []T) {
|
||||||
for _, t := range v {
|
var zero T // nil
|
||||||
|
for i, t := range v {
|
||||||
p.ePool.Put(t)
|
p.ePool.Put(t)
|
||||||
|
v[i] = zero
|
||||||
}
|
}
|
||||||
if v != nil {
|
if v != nil {
|
||||||
v = v[:0]
|
v = v[:0]
|
||||||
|
Loading…
Reference in New Issue
Block a user