Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Commit 16de4be

Browse files
committed
add gc metrics
Signed-off-by: yeya24 <[email protected]>
1 parent 6bc8da9 commit 16de4be

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

docs/user_guide/metrics.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ dragonfly_supernode_cdn_download_failed_total |
2626
dragonfly_supernode_pieces_downloaded_size_bytes_total | | counter | Total size of pieces downloaded from supernode in bytes.
2727
dragonfly_supernode_gc_peers_total | | counter | Total number of peers that have been garbage collected.
2828
dragonfly_supernode_gc_tasks_total | | counter | Total number of tasks that have been garbage collected.
29+
dragonfly_supernode_gc_disks_total | | counter | Total number of garbage collecting the task data in disks.
30+
dragonfly_supernode_last_gc_disks_timestamp_seconds | | gauge | Timestamp of the last disk gc.
2931

3032
## Dfdaemon
3133

supernode/config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,8 @@ type BaseProperties struct {
237237
// IntervalThreshold is the threshold of the interval at which the task file is accessed.
238238
IntervalThreshold time.Duration `yaml:"IntervalThreshold"`
239239

240-
// CleanRatio the ratio to clean the disk and based on 10.
241-
// And the value of CleanRatio should be [1-10].
240+
// CleanRatio is the ratio to clean the disk and it is based on 10.
241+
// It means the value of CleanRatio should be [1-10].
242242
//
243243
// default: 1
244244
CleanRatio int

supernode/daemon/mgr/gc/gc_disk.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ func (gcm *Manager) deleteTaskDisk(ctx context.Context, gcTaskIDs []string) {
6969
util.ReleaseLock(taskID, false)
7070
count++
7171
}
72+
gcm.metrics.gcDisksCount.WithLabelValues().Add(float64(count))
73+
gcm.metrics.lastGCDisksTime.WithLabelValues().SetToCurrentTime()
7274

7375
logrus.Debugf("gc disk: success to gc task count(%d), remainder count(%d)", count, len(gcTaskIDs)-count)
7476
}

supernode/daemon/mgr/gc/gc_manager.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,25 @@ import (
3131
var _ mgr.GCMgr = &Manager{}
3232

3333
type metrics struct {
34-
gcTasksCount *prometheus.CounterVec
35-
gcPeersCount *prometheus.CounterVec
34+
gcTasksCount *prometheus.CounterVec
35+
gcPeersCount *prometheus.CounterVec
36+
gcDisksCount *prometheus.CounterVec
37+
lastGCDisksTime *prometheus.GaugeVec
3638
}
3739

3840
func newMetrics(register prometheus.Registerer) *metrics {
3941
return &metrics{
4042
gcTasksCount: metricsutils.NewCounter(config.SubsystemSupernode, "gc_tasks_total",
4143
"Total number of tasks that have been garbage collected", []string{}, register),
44+
4245
gcPeersCount: metricsutils.NewCounter(config.SubsystemSupernode, "gc_peers_total",
4346
"Total number of peers that have been garbage collected", []string{}, register),
47+
48+
gcDisksCount: metricsutils.NewCounter(config.SubsystemSupernode, "gc_disks_total",
49+
"Total number of garbage collecting the task data in disks", []string{}, register),
50+
51+
lastGCDisksTime: metricsutils.NewGauge(config.SubsystemSupernode, "last_gc_disks_timestamp_seconds",
52+
"Timestamp of the last disk gc", []string{}, register),
4453
}
4554
}
4655

0 commit comments

Comments
 (0)