@@ -71,6 +71,11 @@ func (impl *SyncServiceImpl) Sync() (interface{}, error) {
71
71
ociRegistries []* sql.DockerArtifactStore
72
72
ociRegistry * sql.DockerArtifactStore
73
73
)
74
+ // Track overall sync time
75
+ start := time .Now ()
76
+ defer func () {
77
+ internals .RepoSyncDuration .WithLabelValues ("all" , "all" ).Observe (time .Since (start ).Seconds ())
78
+ }()
74
79
if impl .configuration .ChartProviderId == "*" {
75
80
ociRegistries , err = impl .dockerArtifactStoreRepository .FindAllChartProviders ()
76
81
if err != nil {
@@ -134,8 +139,14 @@ func extractChartRepoRepositoryList(repositoryList string) []string {
134
139
}
135
140
136
141
func (impl * SyncServiceImpl ) syncOCIRepo (ociRepo * sql.DockerArtifactStore ) error {
137
- // prometheus event for OCI registry sync
138
- internals .SyncOCIRepo .WithLabelValues ().Inc ()
142
+ // Track OCI repo sync time
143
+ start := time .Now ()
144
+ defer func () {
145
+ internals .RepoSyncDuration .WithLabelValues ("oci" , ociRepo .RegistryURL ).Observe (time .Since (start ).Seconds ())
146
+ }()
147
+
148
+ // prometheus event for OCI registry sync (already present)
149
+ internals .SyncOCIRepo .WithLabelValues (ociRepo .RegistryURL ).Inc ()
139
150
140
151
applications , err := impl .appStoreRepository .FindByStoreId (ociRepo .Id )
141
152
if err != nil {
@@ -239,6 +250,8 @@ func (impl *SyncServiceImpl) syncOCIRepo(ociRepo *sql.DockerArtifactStore) error
239
250
impl .logger .Errorw ("error in saving app" , "app" , app , "err" , err )
240
251
continue
241
252
}
253
+ // Increment app stores created counter
254
+ internals .AppStoresCreated .Inc ()
242
255
} else {
243
256
continue
244
257
}
@@ -253,6 +266,7 @@ func (impl *SyncServiceImpl) syncOCIRepo(ociRepo *sql.DockerArtifactStore) error
253
266
err = impl .updateOCIRegistryChartVersionsV2 (client , id , chartVersions , ociRepo , chartName )
254
267
}
255
268
if err != nil {
269
+ internals .RepoSyncErrors .WithLabelValues ("oci" , "process_error" ).Inc ()
256
270
impl .logger .Errorw ("error in updating chart versions" , "err" , err , "appId" , id )
257
271
continue
258
272
}
@@ -261,8 +275,14 @@ func (impl *SyncServiceImpl) syncOCIRepo(ociRepo *sql.DockerArtifactStore) error
261
275
}
262
276
263
277
func (impl * SyncServiceImpl ) syncRepo (repo * sql.ChartRepo ) error {
264
- // prometheus event for registry sync
265
- internals .SyncRepo .WithLabelValues ().Inc ()
278
+ // Track standard repo sync time
279
+ start := time .Now ()
280
+ defer func () {
281
+ internals .RepoSyncDuration .WithLabelValues ("standard" , repo .Name ).Observe (time .Since (start ).Seconds ())
282
+ }()
283
+
284
+ // prometheus event for registry sync (already present)
285
+ internals .SyncRepo .WithLabelValues (repo .Name ).Inc ()
266
286
267
287
indexFile , err := impl .helmRepoManager .LoadIndexFile (repo )
268
288
if err != nil {
@@ -294,13 +314,17 @@ func (impl *SyncServiceImpl) syncRepo(repo *sql.ChartRepo) error {
294
314
impl .logger .Errorw ("error in saving app" , "app" , app , "err" , err )
295
315
continue
296
316
}
317
+ // Increment app stores created counter
318
+ internals .AppStoresCreated .Inc ()
319
+
297
320
applicationId [name ] = app .Id
298
321
id = app .Id
299
322
}
300
323
//update entries if any id, chartVersions
301
324
impl .logger .Infow ("handling all versions of chart" , "repoName" , repo .Name , "chartName" , name , "chartVersions" , len (chartVersions ))
302
325
err := impl .updateChartVersions (id , & chartVersions , repo .Url , repo .Username , repo .Password , repo .AllowInsecureConnection )
303
326
if err != nil {
327
+ internals .RepoSyncErrors .WithLabelValues ("standard" , "process_error" ).Inc ()
304
328
impl .logger .Errorw ("error in updating chart versions" , "err" , err , "appId" , id )
305
329
continue
306
330
}
@@ -388,9 +412,12 @@ func (impl *SyncServiceImpl) updateChartVersions(appId int, chartVersions *repo.
388
412
impl .logger .Infow ("saving chart versions into DB" , "versions" , len (appVersions ))
389
413
err = impl .appStoreApplicationVersionRepository .Save (& appVersions )
390
414
if err != nil {
415
+ internals .RepoSyncErrors .WithLabelValues ("standard" , "db_save_error" ).Inc ()
391
416
impl .logger .Errorw ("error in updating" , "totalIn" , len (* chartVersions ), "totalOut" , len (appVersions ), "err" , err )
392
417
return err
393
418
}
419
+ // Count app versions created
420
+ internals .AppVersionsCreated .Add (float64 (len (appVersions )))
394
421
// reset the array
395
422
appVersions = nil
396
423
}
@@ -430,10 +457,14 @@ func (impl *SyncServiceImpl) updateOCIRegistryChartVersions(client *registry.Cli
430
457
431
458
chartData , err := impl .helmRepoManager .OCIRepoValuesJson (client , ociRepo .RegistryURL , chartName , chartVersion )
432
459
if err != nil {
460
+ internals .ChartVersionsFailedProcessing .WithLabelValues ("oci" , chartName , "processing_error" ).Inc ()
433
461
impl .logger .Errorw ("error in getting values yaml" , "err" , err )
434
462
continue
435
463
}
436
464
465
+ // Track successful processing
466
+ internals .ChartVersionsProcessed .WithLabelValues ("oci" , chartName ).Inc ()
467
+
437
468
if ! isAnyChartVersionFound {
438
469
isAnyChartVersionFound = true
439
470
}
0 commit comments