Skip to content

Commit 795e4e7

Browse files
jentingroboquat
authored andcommitted
Calculate the time of taking the volume snapshot
Signed-off-by: JenTing Hsiao <[email protected]>
1 parent 5d22d4a commit 795e4e7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

components/ws-manager/pkg/manager/monitor.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,7 @@ func (m *Monitor) finalizeWorkspaceContent(ctx context.Context, wso *workspaceOb
880880
log.WithError(err).Warn("cannot determine workspace type - assuming this is a regular")
881881
tpe = api.WorkspaceType_REGULAR
882882
}
883+
wsType := api.WorkspaceType_name[int32(tpe)]
883884

884885
var (
885886
createdVolumeSnapshot bool
@@ -891,6 +892,8 @@ func (m *Monitor) finalizeWorkspaceContent(ctx context.Context, wso *workspaceOb
891892
pvcVolumeSnapshotName string = workspaceID
892893
pvcVolumeSnapshotContentName string
893894
pvcVolumeSnapshotClassName string
895+
896+
volumeSnapshotTime time.Time
894897
)
895898
if wso.Pod != nil {
896899
_, pvcFeatureEnabled = wso.Pod.Labels[pvcWorkspaceFeatureAnnotation]
@@ -973,6 +976,7 @@ func (m *Monitor) finalizeWorkspaceContent(ctx context.Context, wso *workspaceOb
973976
return true, nil, err
974977
}
975978
createdVolumeSnapshot = true
979+
volumeSnapshotTime = time.Now()
976980
}
977981
if createdVolumeSnapshot {
978982
backoff := wait.Backoff{
@@ -1016,6 +1020,11 @@ func (m *Monitor) finalizeWorkspaceContent(ctx context.Context, wso *workspaceOb
10161020
return true, nil, err
10171021
}
10181022
readyVolumeSnapshot = true
1023+
hist, err := m.manager.metrics.volumeSnapshotTimeHistVec.GetMetricWithLabelValues(wsType)
1024+
if err != nil {
1025+
log.WithError(err).WithField("type", wsType).Warn("cannot get volume snapshot time histogram metric")
1026+
}
1027+
hist.Observe(time.Since(volumeSnapshotTime).Seconds())
10191028
}
10201029
if readyVolumeSnapshot && !markVolumeSnapshotAnnotation {
10211030
log = log.WithField("VolumeSnapshotContent.Name", pvcVolumeSnapshotContentName)
@@ -1154,7 +1163,7 @@ func (m *Monitor) finalizeWorkspaceContent(ctx context.Context, wso *workspaceOb
11541163
}
11551164
break
11561165
}
1157-
wsType := api.WorkspaceType_name[int32(tpe)]
1166+
11581167
hist, err := m.manager.metrics.finalizeTimeHistVec.GetMetricWithLabelValues(wsType)
11591168
if err != nil {
11601169
log.WithError(err).WithField("type", wsType).Warn("cannot get finalize time histogram metric")

0 commit comments

Comments
 (0)