From 029ac4d3deb74ca1bc776b5b2a8e79b4e5eb18f1 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Mon, 3 Mar 2025 09:08:07 -0500 Subject: [PATCH 1/8] preparing for 1.5.4 release Signed-off-by: Mark Nelson --- THIRD_PARTY_LICENSES.txt | 57 ++++++++++++++++++++-------------------- changelog.md | 14 +++++----- go.mod | 2 +- go.sum | 2 ++ 4 files changed, 40 insertions(+), 35 deletions(-) diff --git a/THIRD_PARTY_LICENSES.txt b/THIRD_PARTY_LICENSES.txt index f3765b2..e3db305 100644 --- a/THIRD_PARTY_LICENSES.txt +++ b/THIRD_PARTY_LICENSES.txt @@ -8,7 +8,6 @@ UPL-1.0 Copyright (c) 2016 Seth Miller Copyright (c) 2016, 2025, Oracle and/or its affiliates. - -------------------------- Fourth Party Dependencies --------------------------- ----------------------------------- Licenses ----------------------------------- @@ -95,19 +94,6 @@ This product includes software developed at CoreOS, Inc. (http://www.coreos.com/). ---------------------------------- (separator) ---------------------------------- - -== Dependency -github.com/go-kit/log - -== License Type -SPDX:MIT - -== Copyright -Copyright (c) 2014 Simon Eskildsen -Copyright (c) 2021 Go kit -Copyright 2013 The Go Authors. All rights reserved. - --------------------------------- (separator) ---------------------------------- == Dependency @@ -126,12 +112,12 @@ Copyright 2010 The Go Authors. All rights reserved. github.com/godror/godror == License Type -=== MIT-039067db +=== MIT-e4e92e20 === BSD-3-Clause--modified-by-Google === BSD-3-Clause--modified-by-Google === UPL-1.0 godror -======= +======== Copyright 2017, 2020 Tamás Gulácsi @@ -455,10 +441,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. == Copyright Copyright (c) 2015 go-logfmt -Copyright (c) 2016, 2024 Oracle and/or its affiliates. +Copyright (c) 2016, 2018 Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2016, 2025, Oracle and/or its affiliates. Copyright (c) 2017 The Go Authors. All rights reserved. -Copyright 2016, 2023 Tamás Gulácsi +Copyright 2016, 2020 Tamás Gulácsi Copyright 2017, 2024 The Godror Authors +Copyright 2022, 2023 Tamás Gulácsi. All rights reserved. --------------------------------- (separator) ---------------------------------- @@ -469,7 +457,7 @@ github.com/godror/knownpb SPDX:Apache-2.0 == Copyright -Copyright 2019, 2021 Tamás Gulácsi +Copyright 2014, 2021 Tamás Gulácsi --------------------------------- (separator) ---------------------------------- @@ -510,6 +498,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. == Copyright Copyright (c) 2015-2020, Tim Heckman +Copyright 2015 Tim Heckman. All rights reserved. Copyright 2018 The Go Authors. All rights reserved. Copyright 2018 The Gofrs. All rights reserved. Copyright 2019 Tim Heckman. All rights reserved. Use of this source code is @@ -568,7 +557,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------ Files: gzhttp/* -SPDX: Apache-2.0 + +SPDX:Apache-2.0 ------------------ @@ -782,18 +772,19 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - The Apache Software License, Version 2.0 Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. -SPDX: Apache-2.0 +Licensed under the Apache License, Version 2.0 (the "License"); You may not use this product except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. A copy of the license is also reproduced below. Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + +SPDX:Apache-2.0 == Copyright -Copyright (c) 2016, 2024, Oracle and/or its affiliates. +Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. == Notices -Copyright (c) 2016, 2014, Oracle and/or its affiliates. +Copyright (c) 2016, 2020, Oracle and/or its affiliates. --------------------------------- (separator) ---------------------------------- @@ -840,6 +831,7 @@ SPDX:Apache-2.0 == Copyright Copyright 2012-2015 The Prometheus Authors +Copyright 2013 Prometheus Team == Notices Data model artifacts for Prometheus. @@ -858,6 +850,7 @@ github.com/prometheus/common SPDX:Apache-2.0 == Copyright +Copyright 2020 The Prometheus-operator Authors Copyright 2024 The Prometheus Authors == Notices @@ -889,14 +882,14 @@ github.com/prometheus/procfs SPDX:Apache-2.0 == Copyright -Copyright 2014-2023 The Prometheus Authors -Copyright 2017-2023 Prometheus Team +Copyright 2023 Prometheus Team +Copyright 2023 The Prometheus Authors == Notices procfs provides functions to retrieve system, kernel and process metrics from the pseudo-filesystem proc. -Copyright 2014-2023 The Prometheus Authors +Copyright 2014-2015 The Prometheus Authors This product includes software developed at SoundCloud Ltd. (http://soundcloud.com/). @@ -963,6 +956,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. == Copyright +Copyright 2009 The Go Authors. Copyright 2024 The Go Authors. All rights reserved. == Patents @@ -1028,6 +1022,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. == Copyright +Copyright 2009 The Go Authors. Copyright 2024 The Go Authors. All rights reserved. == Patents @@ -1093,6 +1088,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. == Copyright +Copyright 2009 The Go Authors. +Copyright 2018 The oauth2 Authors. All rights reserved. Copyright 2024 The Go Authors. All rights reserved. --------------------------------- (separator) ---------------------------------- @@ -1133,6 +1130,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. == Copyright +Copyright 2009 The Go Authors. Copyright 2023 The Go Authors. All rights reserved. == Patents @@ -1198,6 +1196,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. == Copyright +Copyright 2009 The Go Authors. Copyright 2024 The Go Authors. All rights reserved. == Patents @@ -1263,6 +1262,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. == Copyright +Copyright 2009 The Go Authors. Copyright 2021 The Go Authors. All rights reserved. == Patents @@ -1299,6 +1299,7 @@ google.golang.org/protobuf SPDX:BSD-3-Clause--modified-by-Google == Copyright +Copyright 2024 Google Inc. All rights reserved. Copyright 2024 The Go Authors. All rights reserved. == Patents @@ -1414,4 +1415,4 @@ SOFTWARE. === ATTRIBUTION-HELPER-GENERATED: === Attribution helper version: {Major:0 Minor:11 GitVersion:0.10.0-114-g3747dab9 GitCommit:3747dab92eb29c0dbe6409ffbb824b9ae3a04b87 GitTreeState:clean BuildDate:2024-05-31T13:48:06Z GoVersion:go1.21.4 Compiler:gc Platform:linux/amd64} -=== License file based on go.mod with md5 sum: 9703204c5fd5c441310d943839abdc4b +=== License file based on go.mod with md5 sum: 771c94b3ddce81ff2e234b02d85209e4 diff --git a/changelog.md b/changelog.md index 0fefc93..384580c 100644 --- a/changelog.md +++ b/changelog.md @@ -2,13 +2,13 @@ ### Version 1.5.4, March 3, 2025 -Our current priorities are support for RAC and mutliple databases (inculding #84 and #89), and intermittent connection issues -with ADB-S when exporter is run in a container (including #169). We expect to address these in an upcoming release. +Our current priorities are support for RAC and mutliple databases (inculding #84 and #89). We expect to address these in an upcoming release. -- Fix malloc error (#177) -- Fix Multiple custom metrics files overwrite one another (#179) -- Replace go-kit/log with log/slog, due to upstream changes in prometheus/common -- Add support for additional admin roles, exapnding list of options for `DB_ROILE` to `SYSDBA`, `SYSOPER`, `SYSBACKUP`, `SYSDG`, `SYSKM`, `SYSRAC` and `SYSASM` (#180) +- Fix malloc error (#177, #181). +- Fix Multiple custom metrics files overwrite one another (#179). +- Fix intermittent connection issues with ADB-S when exporter is run in a container (#169). +- Replace go-kit/log with log/slog, due to upstream changes in prometheus/common. +- Add support for additional admin roles, exapnding list of options for `DB_ROILE` to `SYSDBA`, `SYSOPER`, `SYSBACKUP`, `SYSDG`, `SYSKM`, `SYSRAC` and `SYSASM` (#180). - Updated some third-party dependencies. Thank you to the following people for their suggestions and contributions: @@ -21,6 +21,8 @@ Thank you to the following people for their suggestions and contributions: - [@rlagyu0](https://github.com/rlagyu0) - [@Sycri](https://github.com/Sycri) +Thank you to [@tgulacsi](https://github.com/tgulacsi) for changes in godror (https://github.com/godror/godror/issues/361, https://github.com/godror/godror/issues/360), and to [@cjbj](https://github.com/cjbj) and [@sudarshan12s](https://github.com/sudarshan12s) for support and guidance from ODPI-C (https://github.com/oracle/odpi). + In this release, we also continued some minor code refactoring. ### Version 1.5.3, January 28, 2025 diff --git a/go.mod b/go.mod index c78a3e3..75c98e4 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ toolchain go1.22.4 require ( github.com/BurntSushi/toml v1.4.0 github.com/alecthomas/kingpin/v2 v2.4.0 - github.com/godror/godror v0.46.1-0.20250226074503-67aeda640090 + github.com/godror/godror v0.47.0 github.com/oracle/oci-go-sdk/v65 v65.84.0 github.com/prometheus/client_golang v1.21.0 github.com/prometheus/common v0.62.0 diff --git a/go.sum b/go.sum index 7850327..4437a6e 100644 --- a/go.sum +++ b/go.sum @@ -22,6 +22,8 @@ github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbV github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/godror/godror v0.46.1-0.20250226074503-67aeda640090 h1:9/ZPRz24+4QrrU/xB0I+AAXKzLV2xtG+mn+9zb3cQCg= github.com/godror/godror v0.46.1-0.20250226074503-67aeda640090/go.mod h1:44hxVDzvFSwc+yGyRM+riCLNAY5SwZkUfLzVTh5MXCg= +github.com/godror/godror v0.47.0 h1:GZsaMOIvLqgTPPVXFIavRI4mqwNIhmcFfEZbzWeabGE= +github.com/godror/godror v0.47.0/go.mod h1:44hxVDzvFSwc+yGyRM+riCLNAY5SwZkUfLzVTh5MXCg= github.com/godror/knownpb v0.1.2 h1:icMyYsYVpGmzhoVA01xyd0o4EaubR31JPK1UxQWe4kM= github.com/godror/knownpb v0.1.2/go.mod h1:zs9hH+lwj7mnPHPnKCcxdOGz38Axa9uT+97Ng+Nnu5s= github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= From 6861e381e2ba40806c75cf60cac3d649a5a4124c Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Mon, 3 Mar 2025 09:13:30 -0500 Subject: [PATCH 2/8] typos Signed-off-by: Mark Nelson --- changelog.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/changelog.md b/changelog.md index 384580c..7cdbea3 100644 --- a/changelog.md +++ b/changelog.md @@ -1,8 +1,11 @@ ## Release Notes -### Version 1.5.4, March 3, 2025 +### Unreleased + +Our current priorities are support for RAC and mutliple databases (including #84 and #89). We expect to address these in an upcoming release. -Our current priorities are support for RAC and mutliple databases (inculding #84 and #89). We expect to address these in an upcoming release. + +### Version 1.5.4, March 3, 2025 - Fix malloc error (#177, #181). - Fix Multiple custom metrics files overwrite one another (#179). @@ -30,9 +33,6 @@ In this release, we also continued some minor code refactoring. *Known issue*: This release has a known issue that results in the error message `malloc(): unsorted double linked list corrupted`. We recommend staying on 1.5.2 until a new release with a fix is available. We hope to have a fix by early March. -Our current priorities are support for RAC and mutliple databases (inculding #84 and #89), and intermittent connection issues -with ADB-S when exporter is run in a container (including #169). We expect to address these in an upcoming release. - This release includes the following changes: - Fix over-zealous supression of errors when `ignorezeroresult = true` (#168). From 04c815cf51135bf7fef019d03ff7d8211e6e602f Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Mon, 3 Mar 2025 09:14:00 -0500 Subject: [PATCH 3/8] typos Signed-off-by: Mark Nelson --- changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 7cdbea3..fd8bcb6 100644 --- a/changelog.md +++ b/changelog.md @@ -11,7 +11,7 @@ Our current priorities are support for RAC and mutliple databases (including #84 - Fix Multiple custom metrics files overwrite one another (#179). - Fix intermittent connection issues with ADB-S when exporter is run in a container (#169). - Replace go-kit/log with log/slog, due to upstream changes in prometheus/common. -- Add support for additional admin roles, exapnding list of options for `DB_ROILE` to `SYSDBA`, `SYSOPER`, `SYSBACKUP`, `SYSDG`, `SYSKM`, `SYSRAC` and `SYSASM` (#180). +- Add support for additional admin roles, exapnding list of options for `DB_ROLE` to `SYSDBA`, `SYSOPER`, `SYSBACKUP`, `SYSDG`, `SYSKM`, `SYSRAC` and `SYSASM` (#180). - Updated some third-party dependencies. Thank you to the following people for their suggestions and contributions: From f97a76c307a4e94a59becc507a2e763f6d353ca3 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Mon, 3 Mar 2025 09:18:08 -0500 Subject: [PATCH 4/8] typos Signed-off-by: Mark Nelson --- changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index fd8bcb6..b6028fe 100644 --- a/changelog.md +++ b/changelog.md @@ -11,7 +11,7 @@ Our current priorities are support for RAC and mutliple databases (including #84 - Fix Multiple custom metrics files overwrite one another (#179). - Fix intermittent connection issues with ADB-S when exporter is run in a container (#169). - Replace go-kit/log with log/slog, due to upstream changes in prometheus/common. -- Add support for additional admin roles, exapnding list of options for `DB_ROLE` to `SYSDBA`, `SYSOPER`, `SYSBACKUP`, `SYSDG`, `SYSKM`, `SYSRAC` and `SYSASM` (#180). +- Add support for additional admin roles, expanding list of options for `DB_ROLE` to `SYSDBA`, `SYSOPER`, `SYSBACKUP`, `SYSDG`, `SYSKM`, `SYSRAC` and `SYSASM` (#180). - Updated some third-party dependencies. Thank you to the following people for their suggestions and contributions: From df5ef90b078f9748630f41a6131452e2ebcd3fb8 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Mon, 3 Mar 2025 09:26:15 -0500 Subject: [PATCH 5/8] typos Signed-off-by: Mark Nelson --- changelog.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index b6028fe..2772de1 100644 --- a/changelog.md +++ b/changelog.md @@ -7,9 +7,12 @@ Our current priorities are support for RAC and mutliple databases (including #84 ### Version 1.5.4, March 3, 2025 +This release includes the following changes: + +- Based of this recommendation from [godror](https://github.com/godror/godror?tab=readme-ov-file#pooling), which relates to the two following items, and in discussion with the ODPI-C team, we have introduced additional parameters to allow you to set connection pool parameters, and have set defaults which will avoid fast connect cycling. It is our expectation that a fix may be produced in the underlying ODPI-C library for the underlying issue. In the mean time, these changes will avoid the conditions under which the error can occur. - Fix malloc error (#177, #181). -- Fix Multiple custom metrics files overwrite one another (#179). - Fix intermittent connection issues with ADB-S when exporter is run in a container (#169). +- Fix Multiple custom metrics files overwrite one another (#179). - Replace go-kit/log with log/slog, due to upstream changes in prometheus/common. - Add support for additional admin roles, expanding list of options for `DB_ROLE` to `SYSDBA`, `SYSOPER`, `SYSBACKUP`, `SYSDG`, `SYSKM`, `SYSRAC` and `SYSASM` (#180). - Updated some third-party dependencies. From 771b191b06b1056cbe9caabc317083a4b8fe0962 Mon Sep 17 00:00:00 2001 From: Anders Swanson Date: Mon, 3 Mar 2025 08:13:19 -0800 Subject: [PATCH 6/8] Float and log processing Signed-off-by: Anders Swanson --- collector/collector.go | 12 +++++------- collector/metrics.go | 8 +++++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/collector/collector.go b/collector/collector.go index 100e28a..23bf691 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -290,7 +290,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric, tick *time.Time) { e.logger.Error("Error scraping metric", "Context", metric.Context, "MetricsDesc", fmt.Sprint(metric.MetricsDesc), - "time", time.Since(scrapeStart), + "duration", time.Since(scrapeStart), "error", scrapeError) } e.scrapeErrors.WithLabelValues(metric.Context).Inc() @@ -298,7 +298,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric, tick *time.Time) { e.logger.Debug("Successfully scraped metric", "Context", metric.Context, "MetricDesc", fmt.Sprint(metric.MetricsDesc), - "time", time.Since(scrapeStart)) + "duration", time.Since(scrapeStart)) } }() } @@ -500,11 +500,9 @@ func (e *Exporter) scrapeGenericValues(db *sql.DB, ch chan<- prometheus.Metric, } // Construct Prometheus values to sent back for metric, metricHelp := range metricsDesc { - value, err := strconv.ParseFloat(strings.TrimSpace(row[metric]), 64) - // If not a float, skip current metric - if err != nil { - e.logger.Error("Unable to convert current value to float (metric=" + metric + - ",metricHelp=" + metricHelp + ",value=<" + row[metric] + ">)") + value, ok := e.parseFloat(metric, metricHelp, row) + if !ok { + // Skip invalid metric values continue } e.logger.Debug("Query result", diff --git a/collector/metrics.go b/collector/metrics.go index f6d98c8..cf44b5a 100644 --- a/collector/metrics.go +++ b/collector/metrics.go @@ -5,6 +5,7 @@ package collector import ( "strconv" + "strings" "time" ) @@ -52,10 +53,11 @@ func (e *Exporter) getQueryTimeout(metric Metric) time.Duration { func (e *Exporter) parseFloat(metric, metricHelp string, row map[string]string) (float64, bool) { value, ok := row[metric] - if !ok { - return -1, ok + if !ok || value == "" { + // treat nil value as 0 + return 0.0, ok } - valueFloat, err := strconv.ParseFloat(value, 64) + valueFloat, err := strconv.ParseFloat(strings.TrimSpace(value), 64) if err != nil { e.logger.Error("Unable to convert current value to float (metric=" + metric + ",metricHelp=" + metricHelp + ",value=<" + row[metric] + ">)") From 3b2441022403dcb2fd177588164bc44a0fcab5be Mon Sep 17 00:00:00 2001 From: Anders Swanson Date: Mon, 3 Mar 2025 08:54:32 -0800 Subject: [PATCH 7/8] slog fixes Signed-off-by: Anders Swanson --- collector/collector.go | 26 ++++++++++++-------------- collector/default_metrics.go | 2 +- main.go | 3 ++- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/collector/collector.go b/collector/collector.go index 23bf691..e43a36f 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -216,12 +216,12 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric, tick *time.Time) { begun := time.Now() if connectionError := e.db.Ping(); connectionError != nil { - e.logger.Debug("error = " + connectionError.Error()) + e.logger.Debug("connection error", "error", connectionError) if strings.Contains(connectionError.Error(), "sql: database is closed") { e.logger.Info("Reconnecting to DB") connectionError = e.connect() if connectionError != nil { - e.logger.Error("Error reconnecting to DB", connectionError) + e.logger.Error("Error reconnecting to DB", "error", connectionError) } } } @@ -327,7 +327,7 @@ func (e *Exporter) connect() error { var P godror.ConnectionParams // If password is not specified, externalAuth will be true and we'll ignore user input e.externalAuth = e.password == "" - e.logger.Debug("external authentication set to ", e.externalAuth) + e.logger.Debug(fmt.Sprintf("external authentication set to %t", e.externalAuth)) msg := "Using Username/Password Authentication." if e.externalAuth { msg = "Database Password not specified; will attempt to use external authentication (ignoring user input)." @@ -341,15 +341,15 @@ func (e *Exporter) connect() error { P.Username, P.Password, P.ConnectString, P.ExternalAuth = e.user, godror.NewPassword(e.password), e.connectString, externalAuth if e.config.PoolIncrement > 0 { - e.logger.Debug("set pool increment to ", e.config.PoolIncrement) + e.logger.Debug(fmt.Sprintf("set pool increment to %d", e.config.PoolIncrement)) P.PoolParams.SessionIncrement = e.config.PoolIncrement } if e.config.PoolMaxConnections > 0 { - e.logger.Debug("set pool max connections to ", e.config.PoolMaxConnections) + e.logger.Debug(fmt.Sprintf("set pool max connections to %d", e.config.PoolMaxConnections)) P.PoolParams.MaxSessions = e.config.PoolMaxConnections } if e.config.PoolMinConnections > 0 { - e.logger.Debug("set pool min connections to ", e.config.PoolMinConnections) + e.logger.Debug(fmt.Sprintf("set pool min connections to %d", e.config.PoolMinConnections)) P.PoolParams.MinSessions = e.config.PoolMinConnections } @@ -377,17 +377,15 @@ func (e *Exporter) connect() error { P.AdminRole = dsn.NoRole } - e.logger.Debug("connection properties: " + fmt.Sprint(P)) - // note that this just configures the connection, it does not actually connect until later // when we call db.Ping() db := sql.OpenDB(godror.NewConnector(P)) - e.logger.Debug("set max idle connections to ", e.config.MaxIdleConns) + e.logger.Debug(fmt.Sprintf("set max idle connections to %d", e.config.MaxIdleConns)) db.SetMaxIdleConns(e.config.MaxIdleConns) - e.logger.Debug("set max open connections to ", e.config.MaxOpenConns) + e.logger.Debug(fmt.Sprintf("set max open connections to %d", e.config.MaxOpenConns)) db.SetMaxOpenConns(e.config.MaxOpenConns) db.SetConnMaxLifetime(0) - e.logger.Debug("Successfully configured connection to " + maskDsn(e.connectString)) + e.logger.Debug(fmt.Sprintf("Successfully configured connection to %d" + maskDsn(e.connectString))) e.db = db if _, err := db.Exec(` @@ -399,13 +397,13 @@ func (e *Exporter) connect() error { var result int if err := db.QueryRow("select sys_context('USERENV', 'CON_ID') from dual").Scan(&result); err != nil { - e.logger.Info("dbtype err =" + string(err.Error())) + e.logger.Info("dbtype err", "error", err) } e.dbtype = result var sysdba string if err := db.QueryRow("select sys_context('USERENV', 'ISDBA') from dual").Scan(&sysdba); err != nil { - e.logger.Info("got error checking my database role") + e.logger.Error("error checking my database role", "error", err) } e.logger.Info("Connected as SYSDBA? " + sysdba) @@ -463,7 +461,7 @@ func (e *Exporter) reloadMetrics() { for _, _customMetrics := range strings.Split(e.config.CustomMetrics, ",") { metrics := &Metrics{} if _, err := toml.DecodeFile(_customMetrics, metrics); err != nil { - e.logger.Error("failed to load custom metrics", err) + e.logger.Error("failed to load custom metrics", "error", err) panic(errors.New("Error while loading " + _customMetrics)) } else { e.logger.Info("Successfully loaded custom metrics from " + _customMetrics) diff --git a/collector/default_metrics.go b/collector/default_metrics.go index af087af..f46e36e 100644 --- a/collector/default_metrics.go +++ b/collector/default_metrics.go @@ -28,7 +28,7 @@ func (e *Exporter) DefaultMetrics() Metrics { } if _, err := toml.Decode(defaultMetricsToml, &metricsToScrape); err != nil { - e.logger.Error("failed to load default metrics", err) + e.logger.Error("failed to load default metrics", "error", err) panic(errors.New("Error while loading " + defaultMetricsToml)) } return metricsToScrape diff --git a/main.go b/main.go index 035840c..2eff4c0 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ package main import ( "context" + "fmt" "github.com/prometheus/common/promslog" "github.com/prometheus/common/promslog/flag" "net/http" @@ -172,7 +173,7 @@ func main() { if *logDisable == 1 { logger.Info("log.disable set to 1, so will not export the alert logs") } else { - logger.Info("Exporting alert logs to ", *logDestination) + logger.Info(fmt.Sprintf("Exporting alert logs to %s", *logDestination)) logTicker := time.NewTicker(*logInterval) defer logTicker.Stop() From cef691164c95ceda686513813cfc3f90d57ac4fb Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Mon, 3 Mar 2025 13:46:58 -0500 Subject: [PATCH 8/8] typo Signed-off-by: Mark Nelson --- collector/collector.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/collector/collector.go b/collector/collector.go index e43a36f..65e46a3 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -385,7 +385,7 @@ func (e *Exporter) connect() error { e.logger.Debug(fmt.Sprintf("set max open connections to %d", e.config.MaxOpenConns)) db.SetMaxOpenConns(e.config.MaxOpenConns) db.SetConnMaxLifetime(0) - e.logger.Debug(fmt.Sprintf("Successfully configured connection to %d" + maskDsn(e.connectString))) + e.logger.Debug(fmt.Sprintf("Successfully configured connection to %d", maskDsn(e.connectString))) e.db = db if _, err := db.Exec(`