Skip to content

Commit da36396

Browse files
authored
fix: Add better logging/metric per table (#513)
currently we silently drop metrics from child tables. This add them back when root table sync is finished so it is printed once per table/client (and not per object like it was before with millions of log lines)
1 parent 6733785 commit da36396

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

plugins/source/scheduler_dfs.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,24 @@ func (p *Plugin) syncDfs(ctx context.Context, spec specs.Source, client schema.C
7474
wg.Wait()
7575
}
7676

77+
func (p *Plugin) logTablesMetrics(tables schema.Tables, client schema.ClientMeta) {
78+
clientName := client.ID()
79+
for _, table := range tables {
80+
metrics := p.metrics.TableClient[table.Name][clientName]
81+
p.logger.Info().Str("table", table.Name).Str("client", clientName).Uint64("resources", metrics.Resources).Uint64("errors", metrics.Errors).Msg("table sync finished")
82+
p.logTablesMetrics(table.Relations, client)
83+
}
84+
}
85+
7786
func (p *Plugin) resolveTableDfs(ctx context.Context, table *schema.Table, client schema.ClientMeta, parent *schema.Resource, resolvedResources chan<- *schema.Resource, depth int) {
7887
clientName := client.ID()
7988
logger := p.logger.With().Str("table", table.Name).Str("client", clientName).Logger()
8089

8190
if parent == nil { // Log only for root tables, otherwise we spam too much.
82-
logger.Info().Msg("table resolver started")
91+
logger.Info().Msg("top level table resolver started")
8392
}
84-
8593
tableMetrics := p.metrics.TableClient[table.Name][clientName]
94+
8695
res := make(chan interface{})
8796
go func() {
8897
defer func() {
@@ -109,8 +118,9 @@ func (p *Plugin) resolveTableDfs(ctx context.Context, table *schema.Table, clien
109118
}
110119

111120
// we don't need any waitgroups here because we are waiting for the channel to close
112-
if parent == nil { // Log only for root tables, otherwise we spam too much.
113-
logger.Info().Uint64("resources", tableMetrics.Resources).Uint64("errors", tableMetrics.Errors).Msg("fetch table finished")
121+
if parent == nil { // Log only for root tables and relations only after resolving is done, otherwise we spam per object instead of per table.
122+
logger.Info().Uint64("resources", tableMetrics.Resources).Uint64("errors", tableMetrics.Errors).Msg("table sync finished")
123+
p.logTablesMetrics(table.Relations, client)
114124
}
115125
}
116126

0 commit comments

Comments
 (0)