mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-11-24 16:53:14 +08:00
metrics with generation
This commit is contained in:
@@ -23,11 +23,12 @@ type EcVolumeShard struct {
|
||||
ecdFile *os.File
|
||||
ecdFileSize int64
|
||||
DiskType types.DiskType
|
||||
Generation uint32 // generation for metrics labeling
|
||||
}
|
||||
|
||||
func NewEcVolumeShard(diskType types.DiskType, dirname string, collection string, id needle.VolumeId, shardId ShardId, generation uint32) (v *EcVolumeShard, e error) {
|
||||
|
||||
v = &EcVolumeShard{dir: dirname, Collection: collection, VolumeId: id, ShardId: shardId, DiskType: diskType}
|
||||
v = &EcVolumeShard{dir: dirname, Collection: collection, VolumeId: id, ShardId: shardId, DiskType: diskType, Generation: generation}
|
||||
|
||||
baseFileName := v.FileNameWithGeneration(generation)
|
||||
|
||||
@@ -51,11 +52,13 @@ func NewEcVolumeShard(diskType types.DiskType, dirname string, collection string
|
||||
}
|
||||
|
||||
func (shard *EcVolumeShard) Mount() {
|
||||
stats.VolumeServerVolumeGauge.WithLabelValues(shard.Collection, "ec_shards").Inc()
|
||||
generationLabel := fmt.Sprintf("%d", shard.Generation)
|
||||
stats.VolumeServerVolumeGauge.WithLabelValues(shard.Collection, "ec_shards", generationLabel).Inc()
|
||||
}
|
||||
|
||||
func (shard *EcVolumeShard) Unmount() {
|
||||
stats.VolumeServerVolumeGauge.WithLabelValues(shard.Collection, "ec_shards").Dec()
|
||||
generationLabel := fmt.Sprintf("%d", shard.Generation)
|
||||
stats.VolumeServerVolumeGauge.WithLabelValues(shard.Collection, "ec_shards", generationLabel).Dec()
|
||||
}
|
||||
|
||||
func (shard *EcVolumeShard) Size() int64 {
|
||||
|
||||
@@ -359,11 +359,11 @@ func (s *Store) CollectHeartbeat() *master_pb.Heartbeat {
|
||||
}
|
||||
|
||||
for col, size := range collectionVolumeSize {
|
||||
stats.VolumeServerDiskSizeGauge.WithLabelValues(col, "normal").Set(float64(size))
|
||||
stats.VolumeServerDiskSizeGauge.WithLabelValues(col, "normal", "0").Set(float64(size))
|
||||
}
|
||||
|
||||
for col, deletedBytes := range collectionVolumeDeletedBytes {
|
||||
stats.VolumeServerDiskSizeGauge.WithLabelValues(col, "deleted_bytes").Set(float64(deletedBytes))
|
||||
stats.VolumeServerDiskSizeGauge.WithLabelValues(col, "deleted_bytes", "0").Set(float64(deletedBytes))
|
||||
}
|
||||
|
||||
for col, types := range collectionVolumeReadOnlyCount {
|
||||
|
||||
@@ -24,21 +24,31 @@ import (
|
||||
|
||||
func (s *Store) CollectErasureCodingHeartbeat() *master_pb.Heartbeat {
|
||||
var ecShardMessages []*master_pb.VolumeEcShardInformationMessage
|
||||
collectionEcShardSize := make(map[string]int64)
|
||||
// Track sizes by collection+generation combination
|
||||
collectionGenerationEcShardSize := make(map[string]map[uint32]int64)
|
||||
for diskId, location := range s.Locations {
|
||||
location.ecVolumesLock.RLock()
|
||||
for _, ecShards := range location.ecVolumes {
|
||||
ecShardMessages = append(ecShardMessages, ecShards.ToVolumeEcShardInformationMessage(uint32(diskId))...)
|
||||
|
||||
// Initialize collection map if needed
|
||||
if collectionGenerationEcShardSize[ecShards.Collection] == nil {
|
||||
collectionGenerationEcShardSize[ecShards.Collection] = make(map[uint32]int64)
|
||||
}
|
||||
|
||||
for _, ecShard := range ecShards.Shards {
|
||||
collectionEcShardSize[ecShards.Collection] += ecShard.Size()
|
||||
collectionGenerationEcShardSize[ecShards.Collection][ecShards.Generation] += ecShard.Size()
|
||||
}
|
||||
}
|
||||
location.ecVolumesLock.RUnlock()
|
||||
}
|
||||
|
||||
for col, size := range collectionEcShardSize {
|
||||
stats.VolumeServerDiskSizeGauge.WithLabelValues(col, "ec").Set(float64(size))
|
||||
// Update metrics with generation labels
|
||||
for col, generationSizes := range collectionGenerationEcShardSize {
|
||||
for generation, size := range generationSizes {
|
||||
generationLabel := fmt.Sprintf("%d", generation)
|
||||
stats.VolumeServerDiskSizeGauge.WithLabelValues(col, "ec", generationLabel).Set(float64(size))
|
||||
}
|
||||
}
|
||||
|
||||
return &master_pb.Heartbeat{
|
||||
|
||||
@@ -248,7 +248,7 @@ func (v *Volume) doClose() {
|
||||
glog.Warningf("Volume Close fail to sync volume %d", v.Id)
|
||||
}
|
||||
v.DataBackend = nil
|
||||
stats.VolumeServerVolumeGauge.WithLabelValues(v.Collection, "volume").Dec()
|
||||
stats.VolumeServerVolumeGauge.WithLabelValues(v.Collection, "volume", "0").Dec()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -216,7 +216,7 @@ func (v *Volume) load(alsoLoadIndex bool, createDatIfMissing bool, needleMapKind
|
||||
}
|
||||
}
|
||||
|
||||
stats.VolumeServerVolumeGauge.WithLabelValues(v.Collection, "volume").Inc()
|
||||
stats.VolumeServerVolumeGauge.WithLabelValues(v.Collection, "volume", "0").Inc()
|
||||
|
||||
if err == nil {
|
||||
hasLoadedVolume = true
|
||||
|
||||
@@ -136,7 +136,7 @@ func (v *Volume) CommitCompact() error {
|
||||
}
|
||||
}
|
||||
v.DataBackend = nil
|
||||
stats.VolumeServerVolumeGauge.WithLabelValues(v.Collection, "volume").Dec()
|
||||
stats.VolumeServerVolumeGauge.WithLabelValues(v.Collection, "volume", "0").Dec()
|
||||
|
||||
var e error
|
||||
if e = v.makeupDiff(v.FileName(".cpd"), v.FileName(".cpx"), v.FileName(".dat"), v.FileName(".idx")); e != nil {
|
||||
|
||||
Reference in New Issue
Block a user