Skip to content

Commit b36c8a0

Browse files
Document Oracle Linux build (#379)
Signed-off-by: Anders Swanson <[email protected]>
1 parent cfc08fa commit b36c8a0

File tree

3 files changed

+46
-11
lines changed

3 files changed

+46
-11
lines changed

collector/collector.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ func (e *Exporter) scrapeDatabase(ch chan<- prometheus.Metric, errChan chan<- er
254254
metricsToScrape := 0
255255
for _, metric := range e.metricsToScrape {
256256
metric := metric //https://golang.org/doc/faq#closures_and_goroutines
257-
isScrapeMetric := e.isScrapeMetric(tick, metric, d)
257+
isScrapeMetric := isScrapeMetric(e.logger, tick, metric, d)
258258
metricsToScrape++
259259
go func() {
260260
// If the metric doesn't need to be scraped, send the cached values
@@ -419,7 +419,7 @@ func (e *Exporter) scrapeGenericValues(d *Database, ch chan<- prometheus.Metric,
419419
}
420420
// Construct Prometheus values to sent back
421421
for metric, metricHelp := range m.MetricsDesc {
422-
value, ok := e.parseFloat(metric, metricHelp, row)
422+
value, ok := parseFloat(e.logger, metric, metricHelp, row)
423423
if !ok {
424424
// Skip invalid metric values
425425
continue
@@ -468,7 +468,7 @@ func (e *Exporter) scrapeGenericValues(d *Database, ch chan<- prometheus.Metric,
468468
return nil
469469
}
470470
e.logger.Debug("Calling function GeneratePrometheusMetrics()")
471-
err := e.generatePrometheusMetrics(d, genericParser, m.Request, e.getQueryTimeout(m, d))
471+
err := e.generatePrometheusMetrics(d, genericParser, m.Request, getQueryTimeout(e.logger, m, d))
472472
e.logger.Debug("ScrapeGenericValues() - metricsCount: " + strconv.Itoa(metricsCount))
473473
if err != nil {
474474
return err

collector/metrics.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package collector
55

66
import (
7+
"log/slog"
78
"slices"
89
"strconv"
910
"strings"
@@ -13,7 +14,7 @@ import (
1314
// isScrapeMetric returns true if a metric should be scraped. Metrics may not be scraped if they have a custom scrape interval,
1415
// and the time since the last scrape is less than the custom scrape interval.
1516
// If there is no tick time or last known tick, the metric is always scraped.
16-
func (e *Exporter) isScrapeMetric(tick *time.Time, metric *Metric, d *Database) bool {
17+
func isScrapeMetric(logger *slog.Logger, tick *time.Time, metric *Metric, d *Database) bool {
1718
// If the metric isn't enabled for the database, don't scrape it.
1819
if !metric.IsEnabledForDatabase(d) {
1920
return false
@@ -24,7 +25,7 @@ func (e *Exporter) isScrapeMetric(tick *time.Time, metric *Metric, d *Database)
2425
return true
2526
}
2627
// If the metric doesn't have a custom scrape interval, scrape it.
27-
interval, ok := e.getScrapeInterval(metric.Context, metric.ScrapeInterval)
28+
interval, ok := getScrapeInterval(logger, metric.Context, metric.ScrapeInterval)
2829
if !ok {
2930
return true
3031
}
@@ -39,39 +40,39 @@ func (e *Exporter) isScrapeMetric(tick *time.Time, metric *Metric, d *Database)
3940
return shouldScrape
4041
}
4142

42-
func (e *Exporter) getScrapeInterval(context, scrapeInterval string) (time.Duration, bool) {
43+
func getScrapeInterval(logger *slog.Logger, context, scrapeInterval string) (time.Duration, bool) {
4344
if len(scrapeInterval) > 0 {
4445
si, err := time.ParseDuration(scrapeInterval)
4546
if err != nil {
46-
e.logger.Error("Unable to convert scrapeinterval to duration (metric=" + context + ")")
47+
logger.Error("Unable to convert scrapeinterval to duration (metric=" + context + ")")
4748
return 0, false
4849
}
4950
return si, true
5051
}
5152
return 0, false
5253
}
5354

54-
func (e *Exporter) getQueryTimeout(metric *Metric, d *Database) time.Duration {
55+
func getQueryTimeout(logger *slog.Logger, metric *Metric, d *Database) time.Duration {
5556
if len(metric.QueryTimeout) > 0 {
5657
qt, err := time.ParseDuration(metric.QueryTimeout)
5758
if err != nil {
58-
e.logger.Error("Unable to convert querytimeout to duration (metric=" + metric.Context + ")")
59+
logger.Error("Unable to convert querytimeout to duration (metric=" + metric.Context + ")")
5960
return time.Duration(d.Config.GetQueryTimeout()) * time.Second
6061
}
6162
return qt
6263
}
6364
return time.Duration(d.Config.GetQueryTimeout()) * time.Second
6465
}
6566

66-
func (e *Exporter) parseFloat(metric, metricHelp string, row map[string]string) (float64, bool) {
67+
func parseFloat(logger *slog.Logger, metric, metricHelp string, row map[string]string) (float64, bool) {
6768
value, ok := row[metric]
6869
if !ok || value == "<nil>" {
6970
// treat nil value as 0
7071
return 0.0, ok
7172
}
7273
valueFloat, err := strconv.ParseFloat(strings.TrimSpace(value), 64)
7374
if err != nil {
74-
e.logger.Error("Unable to convert current value to float (metric=" + metric +
75+
logger.Error("Unable to convert current value to float (metric=" + metric +
7576
",metricHelp=" + metricHelp + ",value=<" + row[metric] + ">)")
7677
return -1, false
7778
}

site/docs/releases/builds.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,37 @@ Creates multi-arch container builds for linux/amd64 and linux/arm64:
6565
```
6666
make podman-build
6767
```
68+
69+
### Build on Oracle Linux
70+
71+
To build on Oracle Linux, follow these steps.
72+
73+
#### 1. Install build tools
74+
75+
```bash
76+
dnf install -y git golang make
77+
```
78+
79+
#### 2. Clone the exporter git repository
80+
81+
```bash
82+
git clone [email protected]:oracle/oracle-db-appdev-monitoring.git
83+
```
84+
85+
#### 3. Build the binary
86+
87+
```bash
88+
cd oracle-db-appdev-monitoring
89+
make go-build
90+
```
91+
92+
You will now have a tar.gz and binary file in the `dist/` directory, named according to your target platform.
93+
94+
For example, for the darwin-arm64 platform:
95+
96+
```
97+
dist/
98+
├── oracledb_exporter-2.1.0.darwin-arm64
99+
│ └── oracledb_exporter
100+
└── oracledb_exporter-2.1.0.darwin-arm64.tar.gz
101+
```

0 commit comments

Comments
 (0)