Skip to content

Commit 6a5d049

Browse files
author
Yannig Perré
committed
Fix for custom metrics option.
Do not overwrite default metrics when providing custom metrics file.
1 parent 4c757c5 commit 6a5d049

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ type Metrics struct {
5353
}
5454

5555
// Metrics to scrap. Use external file (default-metrics.toml and custom if provided)
56-
var metricsToScrap Metrics
56+
var (
57+
metricsToScrap Metrics
58+
additionalMetrics Metrics
59+
)
5760

5861
// Exporter collects Oracle DB metrics. It implements prometheus.Collector.
5962
type Exporter struct {
@@ -327,10 +330,11 @@ func main() {
327330

328331
// If custom metrics, load it
329332
if strings.Compare(*customMetrics, "") != 0 {
330-
if _, err := toml.DecodeFile(*customMetrics, &metricsToScrap); err != nil {
333+
if _, err := toml.DecodeFile(*customMetrics, &additionalMetrics); err != nil {
331334
log.Errorln(err)
332335
panic(errors.New("Error while loading " + *customMetrics))
333336
}
337+
metricsToScrap.Metric = append(metricsToScrap.Metric, additionalMetrics.Metric...)
334338
}
335339
exporter := NewExporter(dsn)
336340
prometheus.MustRegister(exporter)

0 commit comments

Comments
 (0)