Commit 62c122b
otelriver: treat JobSnoozeError as flow control, not a failure (#59)
Today a job that returns JobSnoozeError (the standard way to ask River
to re-schedule it) flows through the same path as a real failure:
- the span status is set to codes.Error with the snooze error as the
description
- the river.work_count metric records status:error,snooze:true
That means snoozes pollute span error rates in tracing UIs and force
every chart that wants a true error rate to defensively exclude
snooze:true. Snoozes aren't failures; they're flow control - the job
asked to run later and will be retried.
This change makes setStatus recognize *rivertype.JobSnoozeError and
return status:ok + codes.Ok. The snooze:true span/metric attribute
(already set by the existing switch on errors.As) is preserved so
snoozes remain queryable as a dimension. river.work_count snooze data
points are now emitted as status:ok,snooze:true.
It also adds a snooze.duration string attribute to the span (e.g.
"5s"), making it easy to see how long the job asked to be deferred
without having to parse the error string. The duration is span-only
because attaching it to the metric would explode cardinality.
Tests cover both the wrapped-error path (JobSnoozeError test) and the
batch-result path (WorkBatchResultWithJobSnoozeError test).
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 4291d07 commit 62c122b
3 files changed
Lines changed: 61 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
213 | 218 | | |
214 | 219 | | |
215 | 220 | | |
| |||
218 | 223 | | |
219 | 224 | | |
220 | 225 | | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | 226 | | |
227 | 227 | | |
228 | 228 | | |
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
246 | 247 | | |
247 | 248 | | |
248 | 249 | | |
| |||
316 | 317 | | |
317 | 318 | | |
318 | 319 | | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
319 | 327 | | |
320 | 328 | | |
321 | 329 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
387 | 387 | | |
388 | 388 | | |
389 | 389 | | |
390 | | - | |
| 390 | + | |
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
394 | 394 | | |
395 | 395 | | |
396 | | - | |
| 396 | + | |
397 | 397 | | |
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
401 | 401 | | |
402 | 402 | | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
403 | 421 | | |
404 | 422 | | |
405 | 423 | | |
| |||
476 | 494 | | |
477 | 495 | | |
478 | 496 | | |
479 | | - | |
| 497 | + | |
480 | 498 | | |
481 | 499 | | |
482 | 500 | | |
| |||
488 | 506 | | |
489 | 507 | | |
490 | 508 | | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
491 | 522 | | |
492 | 523 | | |
493 | 524 | | |
| |||
0 commit comments