@@ -21,6 +21,14 @@ import (
21
21
base "code.gitea.io/gitea/modules/migration"
22
22
"code.gitea.io/gitea/modules/setting"
23
23
"code.gitea.io/gitea/modules/util"
24
+
25
+ "github.com/prometheus/client_golang/prometheus"
26
+ "github.com/prometheus/client_golang/prometheus/promauto"
27
+ )
28
+
29
+ var (
30
+ repoMigrationsInflightGauge = promauto .NewGauge (prometheus.GaugeOpts {Namespace : "gitea" , Subsystem : "repository" , Name : "inflight_migrations" , Help : "Number of inflight repository migrations" })
31
+ repoMigrationsCounter = promauto .NewGaugeVec (prometheus.GaugeOpts {Namespace : "gitea" , Subsystem : "repository" , Name : "migrations" , Help : "Total migrations" }, []string {"result" })
24
32
)
25
33
26
34
// MigrateOptions is equal to base.MigrateOptions
@@ -124,6 +132,9 @@ func MigrateRepository(ctx context.Context, doer *user_model.User, ownerName str
124
132
return nil , err
125
133
}
126
134
135
+ repoMigrationsInflightGauge .Inc ()
136
+ defer repoMigrationsInflightGauge .Dec ()
137
+
127
138
uploader := NewGiteaLocalUploader (ctx , doer , ownerName , opts .RepoName )
128
139
uploader .gitServiceType = opts .GitServiceType
129
140
@@ -134,8 +145,10 @@ func MigrateRepository(ctx context.Context, doer *user_model.User, ownerName str
134
145
if err2 := system_model .CreateRepositoryNotice (fmt .Sprintf ("Migrate repository from %s failed: %v" , opts .OriginalURL , err )); err2 != nil {
135
146
log .Error ("create respotiry notice failed: " , err2 )
136
147
}
148
+ repoMigrationsCounter .WithLabelValues ("fail" ).Inc ()
137
149
return nil , err
138
150
}
151
+ repoMigrationsCounter .WithLabelValues ("success" ).Inc ()
139
152
return uploader .repo , nil
140
153
}
141
154
0 commit comments