Commit 6b8ed9c
feat: implement retries (#103)
Azure Application Insights frequently times out, returns HTTP 503
errors, or only accepts partial payloads. This adds transparent retries.
Users of this crate won't have to configure anything.
Using `backon` crate, because it seems small and easy to use.
Design decisions:
- Don't expose implementation. Add default retries that should work for
everyone:
- min_delay = 500ms
- max_delay = 5s
- with jitter (to avoid thundering herds when multiple exports run in parallel)
We wanted no max_times or total delay, because the BatchSpanProcessor
already provides a `max_export_timeout` option. This automatically
ensures that the exporter will stop. However, it's only available in the
experimental async version of the BatchSpanProcessor. And it's missing
in the SimpleSpanProcessor and metric and logs processors. Therefore
this sets a total delay of 35s.
- Add a `with_retry_notify` option. Can be used to log retries and
thereby debug exporter flakyness.
- Use `futures-timer` crate to provide sleep functionality during
retries. Ideally we could use
opentelemetry_sdk::runtime::Runtime::delay for that. But that's behind
an experimental feature and we the SDK doesn't provide the exporters
with a runtime. We'd have to add a configuration to the exporter where
users would need to specify their choosen runtime, which then has to
fit to the rest of their setup, otherwise they see runtime errors.
E.g. tokio-sleep fails if not executed in the context of a Tokio
reactor with:
there is no reactor running, must be called from the context of a Tokio 1.x runtime
This error would also only happen if a retry has to happen, which
means when a call to AppInsights fails. This would make it very hard
to debug.
We're using futures-timer instead, which works with all runtimes,
including tokio and futures-executor. The OpenTelemetry SDK uses the
latter for most default processors right now.
---------
Co-authored-by: Jan Kuehle <[email protected]>1 parent c4cbd2b commit 6b8ed9c
File tree
7 files changed
+416
-75
lines changed- src
7 files changed
+416
-75
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
372 | 372 | | |
373 | 373 | | |
374 | 374 | | |
375 | | - | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
376 | 382 | | |
377 | 383 | | |
378 | 384 | | |
| |||
386 | 392 | | |
387 | 393 | | |
388 | 394 | | |
| 395 | + | |
389 | 396 | | |
390 | 397 | | |
391 | 398 | | |
| |||
436 | 443 | | |
437 | 444 | | |
438 | 445 | | |
| 446 | + | |
439 | 447 | | |
440 | 448 | | |
441 | 449 | | |
| |||
475 | 483 | | |
476 | 484 | | |
477 | 485 | | |
| 486 | + | |
478 | 487 | | |
479 | 488 | | |
480 | 489 | | |
| |||
484 | 493 | | |
485 | 494 | | |
486 | 495 | | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
487 | 506 | | |
488 | 507 | | |
489 | 508 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
88 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
89 | 94 | | |
90 | 95 | | |
91 | 96 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
74 | | - | |
75 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
76 | 81 | | |
77 | 82 | | |
78 | 83 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
149 | | - | |
150 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
151 | 156 | | |
152 | 157 | | |
153 | 158 | | |
| |||
0 commit comments