Skip to content

Commit 8fec1fa

Browse files
committed
add case in otelriver middleware to handle the batch result from riverpro/riverbatch
1 parent db5bf99 commit 8fec1fa

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

otelriver/middleware.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,18 @@ func (m *Middleware) Work(ctx context.Context, job *rivertype.JobRow, doInner fu
211211
duration := m.durationInPreferredUnit(time.Since(begin))
212212

213213
if err != nil {
214+
var batchResult interface {
215+
ErrorsByID() map[int64]error // Matches *riverbatch.withJobsError
216+
}
217+
if errors.As(err, &batchResult) {
218+
err = batchResult.ErrorsByID()[job.ID]
219+
}
220+
214221
var (
215222
cancelErr *river.JobCancelError
216223
snoozeErr *river.JobSnoozeError
217224
)
225+
218226
switch {
219227
case errors.As(err, &cancelErr):
220228
attrs = append(attrs, attribute.Bool("cancel", true))

0 commit comments

Comments
 (0)