Skip to content

Commit b6a3154

Browse files
john-from-corelightvitorsavian
authored andcommitted
fix: only log slow sql query parameters if trace logging is enabled
Signed-off-by: john.mezger <[email protected]>
1 parent be5e94c commit b6a3154

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/metrics/metrics.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ func ObserveSQL(start time.Time, errCode string, sql util.Stripped, args ...inte
4343
duration := time.Since(start)
4444
SQLTime.WithLabelValues(errCode).Observe(duration.Seconds())
4545
if SlowSQLThreshold > 0 && duration >= SlowSQLThreshold {
46-
logrus.Infof("Slow SQL (started: %v) (total time: %v): %s : %v", start, duration, sql, args)
46+
if logrus.GetLevel() == logrus.TraceLevel {
47+
logrus.Tracef("Slow SQL (started: %v) (total time: %v): %s : %v", start, duration, sql, args)
48+
} else {
49+
logrus.Infof("Slow SQL (started: %v) (total time: %v): %s", start, duration, sql)
50+
}
4751
}
4852
}

0 commit comments

Comments
 (0)