Skip to content

Commit

Permalink
PMM-11632 rds_exporter ignores DisableEnhancedMetrics (percona#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkadej authored and mprokopov committed Jul 9, 2024
1 parent 593746c commit efb2cee
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions enhanced/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ func NewCollector(sessions *sessions.Sessions, logger log.Logger) *Collector {
}

for session, instances := range sessions.AllSessions() {
s := newScraper(session, instances, logger)
enabledInstances := getEnabledInstances(instances)
s := newScraper(session, enabledInstances, logger)

interval := maxInterval
for _, instance := range instances {
for _, instance := range enabledInstances {
if instance.EnhancedMonitoringInterval > 0 && instance.EnhancedMonitoringInterval < interval {
interval = instance.EnhancedMonitoringInterval
}
Expand All @@ -66,6 +67,18 @@ func NewCollector(sessions *sessions.Sessions, logger log.Logger) *Collector {
return c
}

func getEnabledInstances(instances []sessions.Instance) []sessions.Instance {
enabledInstances := make([]sessions.Instance, 0, len(instances))
for _, instance := range instances {
if instance.DisableEnhancedMetrics {
continue
}
enabledInstances = append(enabledInstances, instance)
}

return enabledInstances
}

// setMetrics saves latest scraped metrics.
func (c *Collector) setMetrics(m map[string][]prometheus.Metric) {
c.rw.Lock()
Expand Down

0 comments on commit efb2cee

Please sign in to comment.