@@ -101,8 +101,17 @@ func atoi(stringValue string) int {
101101 return intValue
102102}
103103
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+
104113func connect (dsn string ) * sql.DB {
105- log .Debugln ("Launching connection: " , dsn )
114+ log .Debugln ("Launching connection: " , maskDsn ( dsn ) )
106115 db , err := sql .Open ("oci8" , dsn )
107116 if err != nil {
108117 log .Errorln ("Error while connecting to" , dsn )
@@ -112,7 +121,7 @@ func connect(dsn string) *sql.DB {
112121 db .SetMaxIdleConns (* maxIdleConns )
113122 log .Debugln ("set max open connections to " , * maxOpenConns )
114123 db .SetMaxOpenConns (* maxOpenConns )
115- log .Debugln ("Successfully connected to: " , dsn )
124+ log .Debugln ("Successfully connected to: " , maskDsn ( dsn ) )
116125 return db
117126}
118127
@@ -217,7 +226,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) {
217226 e .up .Set (0 )
218227 return
219228 } else {
220- log .Debugln ("Successfully pinged Oracle database: " )
229+ log .Debugln ("Successfully pinged Oracle database: " , maskDsn ( e . dsn ) )
221230 e .up .Set (1 )
222231 }
223232
@@ -266,7 +275,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) {
266275
267276 scrapeStart := time .Now ()
268277 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 )
270279 e .scrapeErrors .WithLabelValues (metric .Context ).Inc ()
271280 } else {
272281 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
396405 }
397406 return nil
398407 }
408+ log .Debugln ("Calling function GeneratePrometheusMetrics()" )
399409 err := GeneratePrometheusMetrics (db , genericParser , request )
400410 log .Debugln ("ScrapeGenericValues() - metricsCount: " , metricsCount )
401411 if err != nil {
0 commit comments