Skip to content

Commit e74bb27

Browse files
authored
feat: Expose resource stats in traces as separate event (#1973)
Looks like: <img width="922" alt="Screenshot 2024-11-20 at 11 30 09" src="https://github.com/user-attachments/assets/57075f1a-423d-41c3-8aff-4a74349bad82">
1 parent 566409d commit e74bb27

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

scheduler/queue/worker.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ func (w *worker) resolveTable(ctx context.Context, table *schema.Table, client s
8080
logger.Info().Msg("top level table resolver started")
8181
}
8282
tableMetrics := w.metrics.TableClient[table.Name][clientName]
83+
defer func() {
84+
span.AddEvent("sync.finish.stats", trace.WithAttributes(
85+
attribute.Key("sync.resources").Int64(int64(atomic.LoadUint64(&tableMetrics.Resources))),
86+
attribute.Key("sync.errors").Int64(int64(atomic.LoadUint64(&tableMetrics.Errors))),
87+
attribute.Key("sync.panics").Int64(int64(atomic.LoadUint64(&tableMetrics.Panics))),
88+
))
89+
}()
8390
tableMetrics.OtelStartTime(ctx, startTime)
8491

8592
res := make(chan any)

scheduler/scheduler_dfs.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,15 @@ func (s *syncClient) resolveTableDfs(ctx context.Context, table *schema.Table, c
9191
if parent == nil { // Log only for root tables, otherwise we spam too much.
9292
logger.Info().Msg("top level table resolver started")
9393
}
94+
9495
tableMetrics := s.metrics.TableClient[table.Name][clientName]
96+
defer func() {
97+
span.AddEvent("sync.finish.stats", trace.WithAttributes(
98+
attribute.Key("sync.resources").Int64(int64(atomic.LoadUint64(&tableMetrics.Resources))),
99+
attribute.Key("sync.errors").Int64(int64(atomic.LoadUint64(&tableMetrics.Errors))),
100+
attribute.Key("sync.panics").Int64(int64(atomic.LoadUint64(&tableMetrics.Panics))),
101+
))
102+
}()
95103
tableMetrics.OtelStartTime(ctx, startTime)
96104

97105
res := make(chan any)

0 commit comments

Comments
 (0)