mirror of
https://github.com/grafana/grafana.git
synced 2025-08-03 05:08:36 +08:00
chore (replstore): fix registration with multiple sql drivers, again (#90990)
* replstore: fix registration with multiple sql drivers, again * only compile regex once
This commit is contained in:
@ -61,7 +61,7 @@ func WrapDatabaseDriverWithHooks(dbType string, tracer tracing.Tracer) string {
|
||||
// WrapDatabaseDriverWithHooks creates a fake database driver that
|
||||
// executes pre and post functions which we use to gather metrics about
|
||||
// database queries. It also registers the metrics.
|
||||
func WrapDatabaseReplDriverWithHooks(dbType string, tracer tracing.Tracer) string {
|
||||
func WrapDatabaseReplDriverWithHooks(dbType string, index uint, tracer tracing.Tracer) string {
|
||||
drivers := map[string]driver.Driver{
|
||||
migrator.SQLite: &sqlite3.SQLiteDriver{},
|
||||
migrator.MySQL: &mysql.MySQLDriver{},
|
||||
@ -73,7 +73,7 @@ func WrapDatabaseReplDriverWithHooks(dbType string, tracer tracing.Tracer) strin
|
||||
return dbType
|
||||
}
|
||||
|
||||
driverWithHooks := dbType + "ReplicaWithHooks"
|
||||
driverWithHooks := dbType + fmt.Sprintf("ReplicaWithHooks%d", index)
|
||||
sql.Register(driverWithHooks, sqlhooks.Wrap(d, &databaseQueryWrapper{log: log.New("sqlstore.metrics"), tracer: tracer}))
|
||||
core.RegisterDriver(driverWithHooks, &databaseQueryWrapperDriver{dbType: dbType})
|
||||
return driverWithHooks
|
||||
|
Reference in New Issue
Block a user