Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions estream/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package estream

//go:generate stringer -type=blockID -trimprefix=block
//go:generate go tool stringer -type=blockID -trimprefix=block
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. you can do that. Neat.


type blockID int8

Expand All @@ -36,7 +36,7 @@ const (

type checksumType uint8

//go:generate stringer -type=checksumType -trimprefix=checksumType
//go:generate go tool stringer -type=checksumType -trimprefix=checksumType

const (
checksumTypeNone checksumType = iota
Expand Down
6 changes: 3 additions & 3 deletions heal-commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ type SetStatus struct {
Disks []Disk `json:"disks"`
}

//go:generate stringer -type=HealingDriveReason -output=heal-commands-drive-reason_gen.go -trimprefix=HealingReason $GOFILE
//go:generate go tool stringer -type=HealingDriveReason -output=heal-commands-drive-reason_gen.go -trimprefix=HealingReason $GOFILE
type HealingDriveReason int8

const (
Expand All @@ -374,7 +374,7 @@ const (
HealingReasonOfflineDisk
)

//go:generate stringer -type=OfflineReason -output=heal-commands-offline-reason_gen.go -trimprefix=OfflineReason $GOFILE
//go:generate go tool stringer -type=OfflineReason -output=heal-commands-offline-reason_gen.go -trimprefix=OfflineReason $GOFILE
type OfflineReason int8

const (
Expand All @@ -385,7 +385,7 @@ const (
OfflineReasonDriveTimeout
)

//go:generate stringer -type=OfflineDecision -output=heal-commands-offline-decision_gen.go -trimprefix=OfflineDecision $GOFILE
//go:generate go tool stringer -type=OfflineDecision -output=heal-commands-offline-decision_gen.go -trimprefix=OfflineDecision $GOFILE
type OfflineDecision int8

const (
Expand Down
44 changes: 44 additions & 0 deletions metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,34 @@ func (r *Metrics) Merge(other *Metrics) {
}
}

// BucketILMStats reports the cumulative ILM action counters for a single
// bucket carried in a ScannerMetrics value.
type BucketILMStats struct {
Bucket string `json:"bucket,omitempty" msg:"bucket,omitempty"`
ActionCounters map[string]uint64 `json:"action_counters,omitempty" msg:"action_counters,omitempty"`
}

// Merge adds other.ActionCounters into b.ActionCounters. b.Bucket is preserved
// when set, otherwise adopted from other (even when other has no counters). A
// nil other is a no-op.
func (b *BucketILMStats) Merge(other *BucketILMStats) {
if other == nil {
return
}
if b.Bucket == "" {
b.Bucket = other.Bucket
}
if len(other.ActionCounters) == 0 {
return
}
if b.ActionCounters == nil {
b.ActionCounters = make(map[string]uint64, len(other.ActionCounters))
}
for action, n := range other.ActionCounters {
b.ActionCounters[action] += n
}
}

// ScannerMetrics contains scanner information.
type ScannerMetrics struct {
// Time these metrics were collected
Expand All @@ -476,6 +504,11 @@ type ScannerMetrics struct {
// Number of accumulated ILM operations by type since server restart.
LifeTimeILM map[string]uint64 `json:"ilm_ops,omitempty"`

// BucketLifeTimeILM reports cumulative ILM action counters per bucket,
// keyed by bucket name. Populated only when a specific bucket is
// requested; nil otherwise.
BucketLifeTimeILM map[string]*BucketILMStats `json:"bucket_ilm_stats,omitempty"`

// Last minute operation statistics.
LastMinute struct {
// Scanner actions.
Expand Down Expand Up @@ -603,6 +636,17 @@ func (s *ScannerMetrics) Merge(other *ScannerMetrics) {
total := s.LifeTimeILM[k] + v
s.LifeTimeILM[k] = total
}
for bucket, otherStats := range other.BucketLifeTimeILM {
if s.BucketLifeTimeILM == nil {
s.BucketLifeTimeILM = make(map[string]*BucketILMStats, len(other.BucketLifeTimeILM))
}
dst, ok := s.BucketLifeTimeILM[bucket]
if !ok {
dst = &BucketILMStats{Bucket: bucket}
s.BucketLifeTimeILM[bucket] = dst
}
dst.Merge(otherStats)
}
if s.LastMinute.ILM == nil && len(other.LastMinute.ILM) > 0 {
s.LastMinute.ILM = make(map[string]TimedAction, len(other.LastMinute.ILM))
}
Expand Down
Loading
Loading