Skip to content

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

Description

@praneshnikhar

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

  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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions