Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import (
)

type dataMetric struct {
Name string
Namespace string
UID string
Phase v1alpha2.VirtualDiskSnapshotPhase
Name string
Namespace string
UID string
Phase v1alpha2.VirtualDiskSnapshotPhase
VirtualDisk string
}

// DO NOT mutate VirtualDiskSnapshot!
Expand All @@ -34,9 +35,10 @@ func newDataMetric(vds *v1alpha2.VirtualDiskSnapshot) *dataMetric {
}

return &dataMetric{
Name: vds.Name,
Namespace: vds.Namespace,
UID: string(vds.UID),
Phase: vds.Status.Phase,
Name: vds.Name,
Namespace: vds.Namespace,
UID: string(vds.UID),
Phase: vds.Status.Phase,
VirtualDisk: vds.Spec.VirtualDiskName,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

const (
MetricVDSnapshotStatusPhase = "virtualdisksnapshot_status_phase"
MetricVDSnapshotInfo = "virtualdisksnapshot_info"
)

var baseLabels = []string{"name", "namespace", "uid"}
Expand Down Expand Up @@ -52,4 +53,12 @@ var vdsnapshotMetrics = map[string]metrics.MetricInfo{
WithBaseLabels("phase"),
nil,
),

MetricVDSnapshotInfo: metrics.NewMetricInfo(
MetricVDSnapshotInfo,
"The virtualdisksnapshot virtualdisk name.",
prometheus.GaugeValue,
WithBaseLabels("virtualdisk"),
nil,
),
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type scraper struct {

func (s *scraper) Report(m *dataMetric) {
s.updateMetricVDSnapshotStatusPhase(m)
s.updateMetricVDSnapshotInfo(m)
}

func (s *scraper) updateMetricVDSnapshotStatusPhase(m *dataMetric) {
Expand All @@ -61,6 +62,10 @@ func (s *scraper) updateMetricVDSnapshotStatusPhase(m *dataMetric) {
}
}

func (s *scraper) updateMetricVDSnapshotInfo(m *dataMetric) {
s.defaultUpdate(MetricVDSnapshotInfo, 1, m, m.VirtualDisk)
}

func (s *scraper) defaultUpdate(descName string, value float64, m *dataMetric, labels ...string) {
info := vdsnapshotMetrics[descName]
metric, err := prometheus.NewConstMetric(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ import (
)

type dataMetric struct {
Name string
Namespace string
UID string
Phase v1alpha2.VirtualMachineSnapshotPhase
Name string
Namespace string
UID string
Phase v1alpha2.VirtualMachineSnapshotPhase
VirtualMachine string
}

// DO NOT mutate VirtualMachineSnapshot!
Expand All @@ -34,9 +35,10 @@ func newDataMetric(vms *v1alpha2.VirtualMachineSnapshot) *dataMetric {
}

return &dataMetric{
Name: vms.Name,
Namespace: vms.Namespace,
UID: string(vms.UID),
Phase: vms.Status.Phase,
Name: vms.Name,
Namespace: vms.Namespace,
UID: string(vms.UID),
Phase: vms.Status.Phase,
VirtualMachine: vms.Spec.VirtualMachineName,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

const (
MetricVMSnapshotStatusPhase = "virtualmachinesnapshot_status_phase"
MetricVMSnapshotInfo = "virtualmachinesnapshot_info"
)

var baseLabels = []string{"name", "namespace", "uid"}
Expand Down Expand Up @@ -52,4 +53,12 @@ var vmsnapshotMetrics = map[string]metrics.MetricInfo{
WithBaseLabels("phase"),
nil,
),

MetricVMSnapshotInfo: metrics.NewMetricInfo(
MetricVMSnapshotInfo,
"The virtualmachinesnapshot virtualmachine name.",
prometheus.GaugeValue,
WithBaseLabels("virtualmachine"),
nil,
),
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type scraper struct {

func (s *scraper) Report(m *dataMetric) {
s.updateMetricVMSnapshotStatusPhase(m)
s.updateMetricVMSnapshotInfo(m)
}

func (s *scraper) updateMetricVMSnapshotStatusPhase(m *dataMetric) {
Expand All @@ -61,6 +62,10 @@ func (s *scraper) updateMetricVMSnapshotStatusPhase(m *dataMetric) {
}
}

func (s *scraper) updateMetricVMSnapshotInfo(m *dataMetric) {
s.defaultUpdate(MetricVMSnapshotInfo, 1, m, m.VirtualMachine)
}

func (s *scraper) defaultUpdate(descName string, value float64, m *dataMetric, labels ...string) {
info := vmsnapshotMetrics[descName]
metric, err := prometheus.NewConstMetric(
Expand Down
Loading