Skip to content

Commit

Permalink
feat: matrics pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
wsalles committed Sep 23, 2021
1 parent 77ca6b7 commit 41d4a69
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Metrics struct {
CullingTimestamp *prometheus.GaugeVec
}

// Register new service metrics
func NewMetrics(cli client.Client, name string) *Metrics {
m := &Metrics{
cli: cli,
Expand Down Expand Up @@ -80,7 +81,7 @@ func (m *Metrics) Collect(ch chan<- prometheus.Metric) {
m.FailCreation.Collect(ch)
}

// scrape gets current running statefulsets.
// Scrape gets current running statefulsets.
func (m *Metrics) scrape() {
stsList := &appsv1.StatefulSetList{}
err := m.cli.List(context.TODO(), stsList)
Expand All @@ -91,7 +92,7 @@ func (m *Metrics) scrape() {
for _, v := range stsList.Items {
name, ok := v.Spec.Template.GetLabels()[m.name+"-name"]
if ok && name == v.Name {
stsCache[v.Namespace] += 1
stsCache[v.Namespace]++
}
}

Expand Down

0 comments on commit 41d4a69

Please sign in to comment.