Skip to content

Commit

Permalink
fix(metrics): snapshot size was collected before with the same name a…
Browse files Browse the repository at this point in the history
…nd label values

ref: 5869

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
  • Loading branch information
c3y1huang authored and David Ko committed Dec 22, 2023
1 parent cc7f120 commit db28aba
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions metrics_collector/snapshot_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func NewSnapshotCollector(
Desc: prometheus.NewDesc(
prometheus.BuildFQName(longhornName, subsystemSnapshot, "actual_size_bytes"),
"Actual size of this snapshot",
[]string{volumeLabel, userCreatedLabel},
[]string{snapshotLabel, volumeLabel, userCreatedLabel},
nil,
),
Type: prometheus.GaugeValue,
Expand Down Expand Up @@ -75,6 +75,6 @@ func (c *SnapshotCollector) Collect(ch chan<- prometheus.Metric) {
isUserCreated = "true"
}

ch <- prometheus.MustNewConstMetric(c.sizeMetric.Desc, c.sizeMetric.Type, float64(snapshot.Status.Size), volume.Name, isUserCreated)
ch <- prometheus.MustNewConstMetric(c.sizeMetric.Desc, c.sizeMetric.Type, float64(snapshot.Status.Size), snapshot.Name, volume.Name, isUserCreated)
}
}
1 change: 1 addition & 0 deletions metrics_collector/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const (
instanceManagerType = "instance_manager_type"
managerLabel = "manager"
backupLabel = "backup"
snapshotLabel = "snapshot"
pvcLabel = "pvc"
pvcNamespaceLabel = "pvc_namespace"
userCreatedLabel = "user_created"
Expand Down

0 comments on commit db28aba

Please sign in to comment.