mirror of
https://github.com/minio/minio.git
synced 2025-01-11 15:03:22 -05:00
add lock metrics per node (#16943)
This commit is contained in:
parent
5fe1b46bfd
commit
3b7781835e
@ -213,12 +213,41 @@ func (l *localLocker) RUnlock(_ context.Context, args dsync.LockArgs) (reply boo
|
||||
return reply, nil
|
||||
}
|
||||
|
||||
type lockStats struct {
|
||||
Total int
|
||||
Writes int
|
||||
Reads int
|
||||
}
|
||||
|
||||
func (l *localLocker) stats() lockStats {
|
||||
l.mutex.Lock()
|
||||
defer l.mutex.Unlock()
|
||||
|
||||
st := lockStats{Total: len(l.lockMap)}
|
||||
for _, v := range l.lockMap {
|
||||
if len(v) == 0 {
|
||||
continue
|
||||
}
|
||||
entry := v[0]
|
||||
if entry.Writer {
|
||||
st.Writes++
|
||||
} else {
|
||||
st.Reads += len(v)
|
||||
}
|
||||
}
|
||||
return st
|
||||
}
|
||||
|
||||
func (l *localLocker) DupLockMap() map[string][]lockRequesterInfo {
|
||||
l.mutex.Lock()
|
||||
defer l.mutex.Unlock()
|
||||
|
||||
lockCopy := make(map[string][]lockRequesterInfo, len(l.lockMap))
|
||||
for k, v := range l.lockMap {
|
||||
if len(v) == 0 {
|
||||
delete(l.lockMap, k)
|
||||
continue
|
||||
}
|
||||
lockCopy[k] = append(make([]lockRequesterInfo, 0, len(v)), v...)
|
||||
}
|
||||
return lockCopy
|
||||
|
@ -77,7 +77,7 @@ func init() {
|
||||
return allMetrics
|
||||
}()
|
||||
|
||||
nodeCollector = newMinioCollectorNode([]*MetricsGroup{
|
||||
nodeGroups := []*MetricsGroup{
|
||||
getNodeHealthMetrics(),
|
||||
getLocalDriveStorageMetrics(),
|
||||
getCacheMetrics(),
|
||||
@ -86,7 +86,10 @@ func init() {
|
||||
getMinioVersionMetrics(),
|
||||
getS3TTFBMetric(),
|
||||
getNotificationMetrics(),
|
||||
})
|
||||
getDistLockMetrics(),
|
||||
}
|
||||
|
||||
nodeCollector = newMinioCollectorNode(nodeGroups)
|
||||
clusterCollector = newMinioClusterCollector(allMetricsGroups)
|
||||
}
|
||||
|
||||
@ -1663,6 +1666,53 @@ func getCacheMetrics() *MetricsGroup {
|
||||
return mg
|
||||
}
|
||||
|
||||
func getDistLockMetrics() *MetricsGroup {
|
||||
mg := &MetricsGroup{
|
||||
cacheInterval: 1 * time.Second,
|
||||
}
|
||||
mg.RegisterRead(func(ctx context.Context) []Metric {
|
||||
if !globalIsDistErasure {
|
||||
return []Metric{}
|
||||
}
|
||||
|
||||
st := globalLockServer.stats()
|
||||
|
||||
metrics := make([]Metric, 0, 3)
|
||||
metrics = append(metrics, Metric{
|
||||
Description: MetricDescription{
|
||||
Namespace: minioNamespace,
|
||||
Subsystem: "locks",
|
||||
Name: "total",
|
||||
Help: "Number of current locks on this peer",
|
||||
Type: gaugeMetric,
|
||||
},
|
||||
Value: float64(st.Total),
|
||||
})
|
||||
metrics = append(metrics, Metric{
|
||||
Description: MetricDescription{
|
||||
Namespace: minioNamespace,
|
||||
Subsystem: "locks",
|
||||
Name: "write_total",
|
||||
Help: "Number of current WRITE locks on this peer",
|
||||
Type: gaugeMetric,
|
||||
},
|
||||
Value: float64(st.Writes),
|
||||
})
|
||||
metrics = append(metrics, Metric{
|
||||
Description: MetricDescription{
|
||||
Namespace: minioNamespace,
|
||||
Subsystem: "locks",
|
||||
Name: "read_total",
|
||||
Help: "Number of current READ locks on this peer",
|
||||
Type: gaugeMetric,
|
||||
},
|
||||
Value: float64(st.Reads),
|
||||
})
|
||||
return metrics
|
||||
})
|
||||
return mg
|
||||
}
|
||||
|
||||
func getNotificationMetrics() *MetricsGroup {
|
||||
mg := &MetricsGroup{
|
||||
cacheInterval: 10 * time.Second,
|
||||
|
Loading…
Reference in New Issue
Block a user