cat query string at VALUES if is set to not log values in query
This commit is contained in:
parent
1230538295
commit
e6016ceed8
@ -187,18 +187,17 @@ func (p *gormPlugin) after() gormHookFunc {
|
|||||||
attrs = append(attrs, sys)
|
attrs = append(attrs, sys)
|
||||||
}
|
}
|
||||||
|
|
||||||
vars := tx.Statement.Vars
|
query := ""
|
||||||
if p.excludeQueryVars {
|
if p.excludeQueryVars {
|
||||||
// Replace query variables with '?' to mask them
|
// cat query at VALUES and add tree dots
|
||||||
vars = make([]interface{}, len(tx.Statement.Vars))
|
pos := strings.Index(tx.Statement.SQL.String(), "VALUES (")
|
||||||
|
if pos != -1 {
|
||||||
for i := 0; i < len(vars); i++ {
|
query = tx.Statement.SQL.String()[:pos+len("VALUES ")] + " ..."
|
||||||
vars[i] = "?"
|
} else {
|
||||||
|
query = tx.Statement.SQL.String()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
query := tx.Dialector.Explain(tx.Statement.SQL.String(), vars...)
|
|
||||||
|
|
||||||
attrs = append(attrs, semconv.DBStatementKey.String(p.formatQuery(query)))
|
attrs = append(attrs, semconv.DBStatementKey.String(p.formatQuery(query)))
|
||||||
if tx.Statement.Table != "" {
|
if tx.Statement.Table != "" {
|
||||||
attrs = append(attrs, semconv.DBSQLTableKey.String(tx.Statement.Table))
|
attrs = append(attrs, semconv.DBSQLTableKey.String(tx.Statement.Table))
|
||||||
|
Loading…
Reference in New Issue
Block a user