Skip to content

Commit e4e7b69

Browse files
Set BackupSession duration before sending metrics. (#1466)
Signed-off-by: piyush1146115 <piyush@appscode.com>
1 parent cd9bcec commit e4e7b69

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pkg/controller/backup_session.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,8 +900,13 @@ func (c *StashController) sendBackupMetrics(inv invoker.BackupInvoker, session *
900900
JobName: fmt.Sprintf("%s-%s-%s", strings.ToLower(inv.GetTypeMeta().Kind), inv.GetObjectMeta().Namespace, inv.GetObjectMeta().Name),
901901
}
902902

903+
status := session.GetStatus()
904+
if status.SessionDuration == "" {
905+
status.SessionDuration = time.Since(session.GetObjectMeta().CreationTimestamp.Time).Round(time.Second).String()
906+
}
907+
903908
// send backup session related metrics
904-
err := metricsOpt.SendBackupSessionMetrics(inv, session.GetStatus())
909+
err := metricsOpt.SendBackupSessionMetrics(inv, status)
905910
if err != nil {
906911
return err
907912
}

0 commit comments

Comments
 (0)