#23166·cloudquery

cli/cmd/sync_v3.go: sync metrics always sent as zeros — mt metrics.Metrics declared but never populated

Author: praneshnikharCreated Jul 27, 2026Updated Jul 27, 2026

CLI: Zero metrics sent to analytics in cli/cmd/sync_v3.go

File: cli/cmd/sync_v3.go:623

Problem: The variable mt metrics.Metrics is declared as a local variable but never populated. When the sync finishes and TrackSyncCompleted fires, all metric payload fields (Resources, Errors, etc.) are sent as zero values. This means analytics dashboards show every sync as having 0 resources synced.

Current code:

go
var mt metrics.Metrics
// ... mt is never assigned before use

The mt variable is used later in the function to build the analytics event, but statsPerTable data is available on the very next line (line 623: tableProgress := statsPerTable.GetAll()).

Fix: Build mt from statsPerTable data immediately after it's available:

go
tableClients := make(map[string]map[string]*metrics.TableClientMetrics, len(tableProgress))
for tableName, progress := range tableProgress {
    tableClients[tableName] = map[string]*metrics.TableClientMetrics{
        sourceSpec.Name: {
            Resources: uint64(progress.Rows),
            Errors:    uint64(progress.Errors),
        },
    }
}
mt = metrics.Metrics{TableClient: tableClients}

Reproduction

  1. Configure analytics (set CLOUDQUERY_API_KEY).
  2. Run cloudquery sync with a source plugin that fetches real data.
  3. Check the analytics event payload — resources and errors fields are always 0 regardless of how many resources were actually synced.