Instrumentation: Improve instrumentation for database migrations (#74659)

This commit is contained in:
Marcus Efraimsson 2023-09-11 13:10:21 +02:00 committed by GitHub
parent 247d91be2b
commit edc34fc836
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -239,6 +239,7 @@ func (mg *Migrator) run() (err error) {
}
func (mg *Migrator) exec(m Migration, sess *xorm.Session) error {
start := time.Now()
mg.Logger.Info("Executing migration", "id", m.Id())
condition := m.GetCondition()
@ -271,10 +272,12 @@ func (mg *Migrator) exec(m Migration, sess *xorm.Session) error {
}
if err != nil {
mg.Logger.Error("Executing migration failed", "id", m.Id(), "error", err)
mg.Logger.Error("Executing migration failed", "id", m.Id(), "error", err, "duration", time.Since(start))
return err
}
mg.Logger.Info("Migration successfully executed", "id", m.Id(), "duration", time.Since(start))
return nil
}