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
8 changes: 6 additions & 2 deletions collector/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func NewMetricsCache(metrics map[string]*Metric) *MetricsCache {

for _, metric := range metrics {
c[metric] = &MetricCacheRecord{
PrometheusMetrics: map[string]prometheus.Metric{},
PrometheusMetrics: nil,
LastScraped: nil,
}
}
Expand All @@ -36,7 +36,11 @@ func (c *MetricsCache) SendAll(ch chan<- prometheus.Metric, m *Metric) {
}
}

func (c *MetricsCache) Reset(m *Metric) {
c.cache[m].PrometheusMetrics = nil
}

func (c *MetricsCache) CacheAndSend(ch chan<- prometheus.Metric, m *Metric, metric prometheus.Metric) {
c.cache[m].PrometheusMetrics[metric.Desc().String()] = metric
c.cache[m].PrometheusMetrics = append(c.cache[m].PrometheusMetrics, metric)
ch <- metric
}
4 changes: 3 additions & 1 deletion collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,9 @@ func (e *Exporter) scrapeGenericValues(d *Database, ch chan<- prometheus.Metric,

// Build metric desc
suffix := metricNameSuffix(row, metric, m.FieldToAppend)
fqname := prometheus.BuildFQName(namespace, m.Context, suffix)
desc := prometheus.NewDesc(
prometheus.BuildFQName(namespace, m.Context, suffix),
fqname,
metricHelp,
m.GetLabels(),
constLabels,
Expand Down Expand Up @@ -467,6 +468,7 @@ func (e *Exporter) scrapeGenericValues(d *Database, ch chan<- prometheus.Metric,
return nil
}
e.logger.Debug("Calling function GeneratePrometheusMetrics()")
d.MetricsCache.Reset(m)
err := e.generatePrometheusMetrics(d, genericParser, m.Request, getQueryTimeout(e.logger, m, d))
e.logger.Debug("ScrapeGenericValues() - metricsCount: " + strconv.Itoa(metricsCount))
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion collector/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ type MetricsCache struct {
type MetricCacheRecord struct {
// PrometheusMetrics stores cached prometheus metric values.
// Used when custom scrape intervals are used, and the metric must be returned to the collector, but not scraped.
PrometheusMetrics map[string]prometheus.Metric
PrometheusMetrics []prometheus.Metric
// LastScraped is the collector tick time when the metric was last computed.
LastScraped *time.Time
}
Expand Down
3 changes: 2 additions & 1 deletion site/docs/releases/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ List of upcoming and historic changes to the exporter.
Our current priorities to support metrics for advanced database features and use cases, like Exadata, GoldenGate, and views included in the Oracle Diagnostics Pack.

- Move `oracledb_dbtype` metric to the default metrics. You may now disable or override this metric like any other database metric.
- Document required database permissions for the exporter
- Document required database permissions for the exporter.
- Fix an issue where some metrics would not be cached when using a per-metric scrape interval with a global scrape interval.

Thank you to the following people for their suggestions and contributions:
- [@MansuyDavid](https://github.com/MansuyDavid)
Expand Down