diff --git a/pkg/gorm_tracing/middleware.go b/pkg/gorm_tracing/middleware.go index b538ca9..deffcdd 100644 --- a/pkg/gorm_tracing/middleware.go +++ b/pkg/gorm_tracing/middleware.go @@ -187,18 +187,17 @@ func (p *gormPlugin) after() gormHookFunc { attrs = append(attrs, sys) } - vars := tx.Statement.Vars + query := "" if p.excludeQueryVars { - // Replace query variables with '?' to mask them - vars = make([]interface{}, len(tx.Statement.Vars)) - - for i := 0; i < len(vars); i++ { - vars[i] = "?" + // cat query at VALUES and add tree dots + pos := strings.Index(tx.Statement.SQL.String(), "VALUES (") + if pos != -1 { + query = tx.Statement.SQL.String()[:pos+len("VALUES ")] + " ..." + } else { + query = tx.Statement.SQL.String() } } - query := tx.Dialector.Explain(tx.Statement.SQL.String(), vars...) - attrs = append(attrs, semconv.DBStatementKey.String(p.formatQuery(query))) if tx.Statement.Table != "" { attrs = append(attrs, semconv.DBSQLTableKey.String(tx.Statement.Table))