Skip to content

Commit

Permalink
feat: add metric count
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulguptajss committed Jul 21, 2023
1 parent f2c7784 commit 60d9b8f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmd/poller/plugin/changelog/change_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type ChangeLog struct {
changeLogMap map[string]*matrix.Matrix
changeLogConfig Entry
index int
metricsCount int
}

// Change represents a single change entry in the ChangeLog
Expand Down Expand Up @@ -246,8 +247,14 @@ func (c *ChangeLog) Run(dataMap map[string]*matrix.Matrix) ([]*matrix.Matrix, er
// The `index` variable is used to differentiate between changes to the same label in a Grafana dashboard.
// It has a value between 0 and 100 and is used in the `change_log` query as `last_over_time`.
c.index = (c.index + 1) % 100
c.Logger.Info().Int("instances", len(changeMat.GetInstances())).
Int("metrics", c.metricsCount).
Msg("Collected")
}

// reset metric count
c.metricsCount = 0

return matricesArray, nil
}

Expand All @@ -272,6 +279,7 @@ func (c *ChangeLog) createChangeLogInstance(mat *matrix.Matrix, change *Change)
for k, v := range change.labels {
cInstance.SetLabel(k, v)
}
c.metricsCount += cInstance.GetLabels().Size()
m := mat.GetMetric("log")
if m == nil {
if m, err = mat.NewMetricFloat64("log"); err != nil {
Expand Down

0 comments on commit 60d9b8f

Please sign in to comment.