Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
add gc metrics
Browse files Browse the repository at this point in the history
Signed-off-by: yeya24 <[email protected]>
  • Loading branch information
yeya24 committed Sep 26, 2019
1 parent 6bc8da9 commit 16de4be
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions docs/user_guide/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ dragonfly_supernode_cdn_download_failed_total |
dragonfly_supernode_pieces_downloaded_size_bytes_total | | counter | Total size of pieces downloaded from supernode in bytes.
dragonfly_supernode_gc_peers_total | | counter | Total number of peers that have been garbage collected.
dragonfly_supernode_gc_tasks_total | | counter | Total number of tasks that have been garbage collected.
dragonfly_supernode_gc_disks_total | | counter | Total number of garbage collecting the task data in disks.
dragonfly_supernode_last_gc_disks_timestamp_seconds | | gauge | Timestamp of the last disk gc.

## Dfdaemon

Expand Down
4 changes: 2 additions & 2 deletions supernode/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ type BaseProperties struct {
// IntervalThreshold is the threshold of the interval at which the task file is accessed.
IntervalThreshold time.Duration `yaml:"IntervalThreshold"`

// CleanRatio the ratio to clean the disk and based on 10.
// And the value of CleanRatio should be [1-10].
// CleanRatio is the ratio to clean the disk and it is based on 10.
// It means the value of CleanRatio should be [1-10].
//
// default: 1
CleanRatio int
Expand Down
2 changes: 2 additions & 0 deletions supernode/daemon/mgr/gc/gc_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ func (gcm *Manager) deleteTaskDisk(ctx context.Context, gcTaskIDs []string) {
util.ReleaseLock(taskID, false)
count++
}
gcm.metrics.gcDisksCount.WithLabelValues().Add(float64(count))
gcm.metrics.lastGCDisksTime.WithLabelValues().SetToCurrentTime()

logrus.Debugf("gc disk: success to gc task count(%d), remainder count(%d)", count, len(gcTaskIDs)-count)
}
13 changes: 11 additions & 2 deletions supernode/daemon/mgr/gc/gc_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,25 @@ import (
var _ mgr.GCMgr = &Manager{}

type metrics struct {
gcTasksCount *prometheus.CounterVec
gcPeersCount *prometheus.CounterVec
gcTasksCount *prometheus.CounterVec
gcPeersCount *prometheus.CounterVec
gcDisksCount *prometheus.CounterVec
lastGCDisksTime *prometheus.GaugeVec
}

func newMetrics(register prometheus.Registerer) *metrics {
return &metrics{
gcTasksCount: metricsutils.NewCounter(config.SubsystemSupernode, "gc_tasks_total",
"Total number of tasks that have been garbage collected", []string{}, register),

gcPeersCount: metricsutils.NewCounter(config.SubsystemSupernode, "gc_peers_total",
"Total number of peers that have been garbage collected", []string{}, register),

gcDisksCount: metricsutils.NewCounter(config.SubsystemSupernode, "gc_disks_total",
"Total number of garbage collecting the task data in disks", []string{}, register),

lastGCDisksTime: metricsutils.NewGauge(config.SubsystemSupernode, "last_gc_disks_timestamp_seconds",
"Timestamp of the last disk gc", []string{}, register),
}
}

Expand Down

0 comments on commit 16de4be

Please sign in to comment.