@@ -216,12 +216,12 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric, tick *time.Time) {
216
216
begun := time .Now ()
217
217
218
218
if connectionError := e .db .Ping (); connectionError != nil {
219
- e .logger .Debug ("error = " + connectionError . Error () )
219
+ e .logger .Debug ("connection error" , "error" , connectionError )
220
220
if strings .Contains (connectionError .Error (), "sql: database is closed" ) {
221
221
e .logger .Info ("Reconnecting to DB" )
222
222
connectionError = e .connect ()
223
223
if connectionError != nil {
224
- e .logger .Error ("Error reconnecting to DB" , connectionError )
224
+ e .logger .Error ("Error reconnecting to DB" , "error" , connectionError )
225
225
}
226
226
}
227
227
}
@@ -327,7 +327,7 @@ func (e *Exporter) connect() error {
327
327
var P godror.ConnectionParams
328
328
// If password is not specified, externalAuth will be true and we'll ignore user input
329
329
e .externalAuth = e .password == ""
330
- e .logger .Debug ("external authentication set to " , e .externalAuth )
330
+ e .logger .Debug (fmt . Sprintf ( "external authentication set to %t " , e .externalAuth ) )
331
331
msg := "Using Username/Password Authentication."
332
332
if e .externalAuth {
333
333
msg = "Database Password not specified; will attempt to use external authentication (ignoring user input)."
@@ -341,15 +341,15 @@ func (e *Exporter) connect() error {
341
341
P .Username , P .Password , P .ConnectString , P .ExternalAuth = e .user , godror .NewPassword (e .password ), e .connectString , externalAuth
342
342
343
343
if e .config .PoolIncrement > 0 {
344
- e .logger .Debug ("set pool increment to " , e .config .PoolIncrement )
344
+ e .logger .Debug (fmt . Sprintf ( "set pool increment to %d " , e .config .PoolIncrement ) )
345
345
P .PoolParams .SessionIncrement = e .config .PoolIncrement
346
346
}
347
347
if e .config .PoolMaxConnections > 0 {
348
- e .logger .Debug ("set pool max connections to " , e .config .PoolMaxConnections )
348
+ e .logger .Debug (fmt . Sprintf ( "set pool max connections to %d " , e .config .PoolMaxConnections ) )
349
349
P .PoolParams .MaxSessions = e .config .PoolMaxConnections
350
350
}
351
351
if e .config .PoolMinConnections > 0 {
352
- e .logger .Debug ("set pool min connections to " , e .config .PoolMinConnections )
352
+ e .logger .Debug (fmt . Sprintf ( "set pool min connections to %d " , e .config .PoolMinConnections ) )
353
353
P .PoolParams .MinSessions = e .config .PoolMinConnections
354
354
}
355
355
@@ -377,17 +377,15 @@ func (e *Exporter) connect() error {
377
377
P .AdminRole = dsn .NoRole
378
378
}
379
379
380
- e .logger .Debug ("connection properties: " + fmt .Sprint (P ))
381
-
382
380
// note that this just configures the connection, it does not actually connect until later
383
381
// when we call db.Ping()
384
382
db := sql .OpenDB (godror .NewConnector (P ))
385
- e .logger .Debug ("set max idle connections to " , e .config .MaxIdleConns )
383
+ e .logger .Debug (fmt . Sprintf ( "set max idle connections to %d " , e .config .MaxIdleConns ) )
386
384
db .SetMaxIdleConns (e .config .MaxIdleConns )
387
- e .logger .Debug ("set max open connections to " , e .config .MaxOpenConns )
385
+ e .logger .Debug (fmt . Sprintf ( "set max open connections to %d " , e .config .MaxOpenConns ) )
388
386
db .SetMaxOpenConns (e .config .MaxOpenConns )
389
387
db .SetConnMaxLifetime (0 )
390
- e .logger .Debug ("Successfully configured connection to " + maskDsn (e .connectString ))
388
+ e .logger .Debug (fmt . Sprintf ( "Successfully configured connection to %d " + maskDsn (e .connectString ) ))
391
389
e .db = db
392
390
393
391
if _ , err := db .Exec (`
@@ -399,13 +397,13 @@ func (e *Exporter) connect() error {
399
397
400
398
var result int
401
399
if err := db .QueryRow ("select sys_context('USERENV', 'CON_ID') from dual" ).Scan (& result ); err != nil {
402
- e .logger .Info ("dbtype err =" + string ( err . Error ()) )
400
+ e .logger .Info ("dbtype err" , "error" , err )
403
401
}
404
402
e .dbtype = result
405
403
406
404
var sysdba string
407
405
if err := db .QueryRow ("select sys_context('USERENV', 'ISDBA') from dual" ).Scan (& sysdba ); err != nil {
408
- e .logger .Info ( "got error checking my database role" )
406
+ e .logger .Error ( " error checking my database role", "error" , err )
409
407
}
410
408
e .logger .Info ("Connected as SYSDBA? " + sysdba )
411
409
@@ -463,7 +461,7 @@ func (e *Exporter) reloadMetrics() {
463
461
for _ , _customMetrics := range strings .Split (e .config .CustomMetrics , "," ) {
464
462
metrics := & Metrics {}
465
463
if _ , err := toml .DecodeFile (_customMetrics , metrics ); err != nil {
466
- e .logger .Error ("failed to load custom metrics" , err )
464
+ e .logger .Error ("failed to load custom metrics" , "error" , err )
467
465
panic (errors .New ("Error while loading " + _customMetrics ))
468
466
} else {
469
467
e .logger .Info ("Successfully loaded custom metrics from " + _customMetrics )
0 commit comments