@@ -135,8 +135,7 @@ func confugureEvaluator() {
135135}
136136
137137func Evaluate (ctx context.Context , event * mqueue.PlatformEvent , inventoryID , evaluationType string ) error {
138- tStart := time .Now ()
139- defer utils .ObserveSecondsSince (tStart , evaluationDuration .WithLabelValues (evaluationType ))
138+ defer utils .ObserveSecondsSince (time .Now (), evaluationDuration .WithLabelValues (evaluationType ))
140139
141140 utils .LogInfo ("inventoryID" , inventoryID , "Evaluating system" )
142141 if enableBypass {
@@ -282,8 +281,7 @@ func tryGetYumUpdates(system *models.SystemPlatformV2) (*vmaas.UpdatesV3Response
282281
283282func evaluateWithVmaas (updatesData * vmaas.UpdatesV3Response ,
284283 system * models.SystemPlatformV2 , event * mqueue.PlatformEvent ) (* vmaas.UpdatesV3Response , error ) {
285- tStart := time .Now ()
286- defer utils .ObserveSecondsSince (tStart , evaluationPartDuration .WithLabelValues ("evaluate-with-vmaas-full" ))
284+ defer utils .ObserveSecondsSince (time .Now (), evaluationPartDuration .WithLabelValues ("evaluate-with-vmaas-full" ))
287285
288286 err := evaluateAndStore (system , updatesData , event )
289287 if err != nil {
@@ -293,8 +291,7 @@ func evaluateWithVmaas(updatesData *vmaas.UpdatesV3Response,
293291}
294292
295293func getUpdatesData (ctx context.Context , system * models.SystemPlatformV2 ) (* vmaas.UpdatesV3Response , error ) {
296- tStart := time .Now ()
297- defer utils .ObserveSecondsSince (tStart , evaluationPartDuration .WithLabelValues ("get-updates-data" ))
294+ defer utils .ObserveSecondsSince (time .Now (), evaluationPartDuration .WithLabelValues ("get-updates-data" ))
298295
299296 var yumUpdates * vmaas.UpdatesV3Response
300297 var yumErr error
@@ -335,8 +332,7 @@ func getUpdatesData(ctx context.Context, system *models.SystemPlatformV2) (*vmaa
335332}
336333
337334func getVmaasUpdates (ctx context.Context , system * models.SystemPlatformV2 ) (* vmaas.UpdatesV3Response , error ) {
338- tStart := time .Now ()
339- defer utils .ObserveSecondsSince (tStart , evaluationPartDuration .WithLabelValues ("vmaas-updates-prepare" ))
335+ defer utils .ObserveSecondsSince (time .Now (), evaluationPartDuration .WithLabelValues ("vmaas-updates-prepare" ))
340336
341337 var vmaasDataCopy vmaas.UpdatesV3Response
342338 // first check if we have data in cache
@@ -448,8 +444,7 @@ func tryGetSystem(accountID int, inventoryID string,
448444}
449445
450446func commitWithObserve (tx * gorm.DB ) error {
451- tStart := time .Now ()
452- defer utils .ObserveSecondsSince (tStart , evaluationPartDuration .WithLabelValues ("commit-to-db" ))
447+ defer utils .ObserveSecondsSince (time .Now (), evaluationPartDuration .WithLabelValues ("commit-to-db" ))
453448
454449 err := tx .Commit ().Error
455450 if err != nil {
@@ -528,8 +523,7 @@ func analyzeRepos(system *models.SystemPlatformV2) (thirdParty bool, err error)
528523 return false , nil
529524 }
530525
531- tStart := time .Now ()
532- defer utils .ObserveSecondsSince (tStart , evaluationPartDuration .WithLabelValues ("repo-analysis" ))
526+ defer utils .ObserveSecondsSince (time .Now (), evaluationPartDuration .WithLabelValues ("repo-analysis" ))
533527
534528 // if system has associated at least one third party repo
535529 // it's marked as third party system
@@ -563,8 +557,7 @@ func incrementAdvisoryTypeCounts(advisory models.AdvisoryMetadata, enhCount, bug
563557// nolint: funlen
564558func updateSystemPlatform (tx * gorm.DB , system * models.SystemPlatformV2 ,
565559 advisories SystemAdvisoryMap , installed , installable , applicable int ) error {
566- tStart := time .Now ()
567- defer utils .ObserveSecondsSince (tStart , evaluationPartDuration .WithLabelValues ("system-update" ))
560+ defer utils .ObserveSecondsSince (time .Now (), evaluationPartDuration .WithLabelValues ("system-update" ))
568561 if system .Inventory .LastUpload != nil {
569562 defer utils .ObserveSecondsSince (* system .Inventory .LastUpload , uploadEvaluationDelay )
570563 }
@@ -652,8 +645,7 @@ func updateSystemPlatform(tx *gorm.DB, system *models.SystemPlatformV2,
652645}
653646
654647func callVMaas (ctx context.Context , request * vmaas.UpdatesV3Request ) (* vmaas.UpdatesV3Response , error ) {
655- tStart := time .Now ()
656- defer utils .ObserveSecondsSince (tStart , evaluationPartDuration .WithLabelValues ("vmaas-updates-call" ))
648+ defer utils .ObserveSecondsSince (time .Now (), evaluationPartDuration .WithLabelValues ("vmaas-updates-call" ))
657649
658650 vmaasCallFunc := func () (interface {}, * http.Response , error ) {
659651 utils .LogTrace ("request" , * request , "vmaas /updates request" )
@@ -677,8 +669,7 @@ func callVMaas(ctx context.Context, request *vmaas.UpdatesV3Request) (*vmaas.Upd
677669}
678670
679671func loadSystemData (accountID int , inventoryID string ) (* models.SystemPlatformV2 , error ) {
680- tStart := time .Now ()
681- defer utils .ObserveSecondsSince (tStart , evaluationPartDuration .WithLabelValues ("data-loading" ))
672+ defer utils .ObserveSecondsSince (time .Now (), evaluationPartDuration .WithLabelValues ("data-loading" ))
682673
683674 var system models.SystemPlatformV2
684675 err := database .DB .Table ("system_inventory si" ).
@@ -704,8 +695,7 @@ func validSystem(accountID int, systemID int64) bool {
704695}
705696
706697func parseVmaasJSON (inv * models.SystemInventory ) (vmaas.UpdatesV3Request , error ) {
707- tStart := time .Now ()
708- defer utils .ObserveSecondsSince (tStart , evaluationPartDuration .WithLabelValues ("parse-vmaas-json" ))
698+ defer utils .ObserveSecondsSince (time .Now (), evaluationPartDuration .WithLabelValues ("parse-vmaas-json" ))
709699 return utils .ParseVmaasJSON (inv )
710700}
711701
0 commit comments