Skip to content

Commit

Permalink
feat: enable ChangeLog plugin to monitor metric value change
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulguptajss committed Jul 9, 2024
1 parent d67a543 commit 3b1f197
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cmd/poller/plugin/changelog/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,15 +301,19 @@ func (c *ChangeLog) copyPreviousData(cur *matrix.Matrix) {
labels := c.changeLogConfig.PublishLabels
var met []string
for _, t := range c.changeLogConfig.Track {
_, ok := cur.GetMetrics()[t]
if ok {
met = append(met, t)
mKey := cur.DisplayMetricKey(t)
if mKey != "" {
met = append(met, mKey)
} else {
labels = append(labels, t)
}
}
labels = append(labels, "uuid")
c.previousData = cur.Clone(matrix.With{Data: true, Metrics: true, Instances: true, ExportInstances: false, Labels: labels, MetricsNames: met})
withMetrics := false
if len(met) > 0 {
withMetrics = true
}
c.previousData = cur.Clone(matrix.With{Data: true, Metrics: withMetrics, Instances: true, ExportInstances: false, Labels: labels, MetricsNames: met})
}

// createChangeLogInstance creates a new ChangeLog instance with the given change data
Expand Down
7 changes: 7 additions & 0 deletions pkg/matrix/matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ func (m *Matrix) DisplayMetric(name string) *Metric {
return nil
}

func (m *Matrix) DisplayMetricKey(name string) string {
if metricKey, has := m.displayMetrics[name]; has {
return metricKey
}
return ""
}

func (m *Matrix) GetMetric(key string) *Metric {
if metric, has := m.metrics[key]; has {
return metric
Expand Down

0 comments on commit 3b1f197

Please sign in to comment.