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:
var mt metrics.Metrics
// ... mt is never assigned before useThe 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:
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
- Configure analytics (set
CLOUDQUERY_API_KEY). - Run
cloudquery syncwith a source plugin that fetches real data. - Check the analytics event payload —
resourcesanderrorsfields are always 0 regardless of how many resources were actually synced.
Source: cloudquery/cloudquery