@@ -101,8 +101,17 @@ func atoi(stringValue string) int {
101
101
return intValue
102
102
}
103
103
104
+ func maskDsn (dsn string ) string {
105
+ parts := strings .Split (dsn , "@" )
106
+ if len (parts ) > 1 {
107
+ maskedUrl := "***@" + parts [1 ]
108
+ return maskedUrl
109
+ }
110
+ return dsn
111
+ }
112
+
104
113
func connect (dsn string ) * sql.DB {
105
- log .Debugln ("Launching connection: " , dsn )
114
+ log .Debugln ("Launching connection: " , maskDsn ( dsn ) )
106
115
db , err := sql .Open ("oci8" , dsn )
107
116
if err != nil {
108
117
log .Errorln ("Error while connecting to" , dsn )
@@ -112,7 +121,7 @@ func connect(dsn string) *sql.DB {
112
121
db .SetMaxIdleConns (* maxIdleConns )
113
122
log .Debugln ("set max open connections to " , * maxOpenConns )
114
123
db .SetMaxOpenConns (* maxOpenConns )
115
- log .Debugln ("Successfully connected to: " , dsn )
124
+ log .Debugln ("Successfully connected to: " , maskDsn ( dsn ) )
116
125
return db
117
126
}
118
127
@@ -217,7 +226,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) {
217
226
e .up .Set (0 )
218
227
return
219
228
} else {
220
- log .Debugln ("Successfully pinged Oracle database: " )
229
+ log .Debugln ("Successfully pinged Oracle database: " , maskDsn ( e . dsn ) )
221
230
e .up .Set (1 )
222
231
}
223
232
@@ -266,7 +275,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) {
266
275
267
276
scrapeStart := time .Now ()
268
277
if err = ScrapeMetric (e .db , ch , metric ); err != nil {
269
- log .Errorln ("Error scraping for" , metric .Context , "_" , metric .MetricsDesc , ":" , err )
278
+ log .Errorln ("Error scraping for" , metric .Context , "_" , metric .MetricsDesc , time . Since ( scrapeStart ), ":" , err )
270
279
e .scrapeErrors .WithLabelValues (metric .Context ).Inc ()
271
280
} else {
272
281
log .Debugln ("Successfully scraped metric: " , metric .Context , metric .MetricsDesc , time .Since (scrapeStart ))
@@ -396,6 +405,7 @@ func ScrapeGenericValues(db *sql.DB, ch chan<- prometheus.Metric, context string
396
405
}
397
406
return nil
398
407
}
408
+ log .Debugln ("Calling function GeneratePrometheusMetrics()" )
399
409
err := GeneratePrometheusMetrics (db , genericParser , request )
400
410
log .Debugln ("ScrapeGenericValues() - metricsCount: " , metricsCount )
401
411
if err != nil {
0 commit comments