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 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:
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 sync with a source plugin that fetches real data.
- Check the analytics event payload —
resources and errors fields are always 0 regardless of how many resources were actually synced.
CLI: Zero metrics sent to analytics in
cli/cmd/sync_v3.goFile:
cli/cmd/sync_v3.go:623Problem: The variable
mt metrics.Metricsis declared as a local variable but never populated. When the sync finishes andTrackSyncCompletedfires, 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:
The
mtvariable is used later in the function to build the analytics event, butstatsPerTabledata is available on the very next line (line 623:tableProgress := statsPerTable.GetAll()).Fix: Build
mtfromstatsPerTabledata immediately after it's available:Reproduction
CLOUDQUERY_API_KEY).cloudquery syncwith a source plugin that fetches real data.resourcesanderrorsfields are always 0 regardless of how many resources were actually synced.