Skip to content

Commit 80e01b3

Browse files
authored
feat: Add sync duration ms to sync summary (#21712)
1 parent 4a64df1 commit 80e01b3

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

cli/cmd/summary.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type syncSummary struct {
3535
SourceTables []string `json:"source_tables"`
3636
SyncID string `json:"sync_id"`
3737
SyncTime time.Time `json:"sync_time"`
38+
SyncDurationMs uint64 `json:"sync_duration_ms"`
3839
SyncGroupID *string `json:"sync_group_id,omitempty"`
3940
ShardNum *int `json:"shard_num,omitempty"`
4041
ShardTotal *int `json:"shard_total,omitempty"`

cli/cmd/sync_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,13 @@ func TestSync(t *testing.T) {
373373
if len(tc.summary) > 0 {
374374
summaries := readSummaries(t, summaryPath)
375375
// Ignore random fields or fields that are updated over time
376-
diff := cmp.Diff(tc.summary, summaries, cmpopts.IgnoreFields(syncSummary{}, "SyncID", "DestinationVersion", "SourceVersion", "SyncTime"))
376+
diff := cmp.Diff(tc.summary, summaries, cmpopts.IgnoreFields(syncSummary{}, "SyncID", "DestinationVersion", "SourceVersion", "SyncTime", "SyncDurationMs"))
377377
for _, s := range summaries {
378378
assert.NotEmpty(t, s.SyncID)
379379
assert.NotEmpty(t, s.SyncTime)
380380
assert.NotEmpty(t, s.DestinationVersion)
381381
assert.NotEmpty(t, s.SourceVersion)
382+
assert.Greater(t, s.SyncDurationMs, uint64(0))
382383
}
383384
require.Empty(t, diff, "unexpected summaries: %v", diff)
384385
}

cli/cmd/sync_v3.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ func syncConnectionV3(ctx context.Context, syncOptions syncV3Options) (syncErr e
632632
return acc
633633
}, durationsPerTable)
634634
}
635-
635+
syncTimeTook = time.Since(syncTime)
636636
for i := range destinationsClients {
637637
if destinationSpecs[i].WriteMode == specs.WriteModeOverwriteDeleteStale {
638638
// Table names might have changed due to transformers
@@ -652,6 +652,7 @@ func syncConnectionV3(ctx context.Context, syncOptions syncV3Options) (syncErr e
652652
SyncID: uid,
653653
SyncTime: syncTime,
654654
SourceName: sourceSpec.Name,
655+
SyncDurationMs: uint64(syncTimeTook.Milliseconds()),
655656
SourceVersion: sourceSpec.Version,
656657
SourcePath: sourceSpec.Path,
657658
SourceTables: tableNameChanger.UpdateTableNamesSlice(destinationSpecs[i].Name, sourceTableNames),
@@ -702,7 +703,7 @@ func syncConnectionV3(ctx context.Context, syncOptions syncV3Options) (syncErr e
702703
}
703704

704705
atomic.StoreInt64(&isComplete, 1)
705-
syncTimeTook = time.Since(syncTime)
706+
706707
exitReason = ExitReasonCompleted
707708

708709
msg := "Sync completed successfully"

0 commit comments

Comments
 (0)