Skip to content

Commit 5916516

Browse files
authored
fix: Send resource validation errors to Sentry (#601)
Resource validation errors, like a row missing a PK value, are non-recoverable and need to be fixed by the plugin author. As such, we should know about them when they happen, even though they do not cause a panic in the code. I tried to minimize the number of duplicate messages we send in this case by using a `sync.Map`
1 parent 107006c commit 5916516

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

plugins/source/scheduler_dfs.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ func (p *Plugin) resolveResourcesDfs(ctx context.Context, table *schema.Table, c
141141
go func() {
142142
defer close(resourcesChan)
143143
var wg sync.WaitGroup
144+
sentValidationErrors := sync.Map{}
144145
for i := range resourcesSlice {
145146
i := i
146147
if err := p.resourceSem.Acquire(ctx, 1); err != nil {
@@ -161,6 +162,14 @@ func (p *Plugin) resolveResourcesDfs(ctx context.Context, table *schema.Table, c
161162
if err := resolvedResource.Validate(); err != nil {
162163
tableMetrics := p.metrics.TableClient[table.Name][client.ID()]
163164
p.logger.Error().Err(err).Str("table", table.Name).Str("client", client.ID()).Msg("resource resolver finished with validation error")
165+
if _, found := sentValidationErrors.LoadOrStore(table.Name, struct{}{}); !found {
166+
// send resource validation errors to Sentry only once per table,
167+
// to avoid sending too many duplicate messages
168+
sentry.WithScope(func(scope *sentry.Scope) {
169+
scope.SetTag("table", table.Name)
170+
sentry.CurrentHub().CaptureMessage(err.Error())
171+
})
172+
}
164173
atomic.AddUint64(&tableMetrics.Errors, 1)
165174
return
166175
}

0 commit comments

Comments
 (0)