Commit 9334a4d
committed
feat(observability): record Redis connection state on failed slot operations
A Redis command that never gets a reply fails identically whether the
connection was still being established, was reconnecting with the command
parked in the offline queue, or was a socket that had silently died. ioredis
reports all three the same way — `Error: Command timed out` with only its own
timer frames in the stack, no app frame naming the call, and no lifecycle event
saying which happened. Nothing recorded anywhere distinguishes them, so the
cause can only be inferred from timing.
Adds `describeRedisConnection()`: client status, connection and ready ages,
offline-queue depth, lifecycle counters, and whether the configured host is an
IP or a DNS name. `status` alone usually decides it; queue depth confirms, since
a parked command was waiting on connection setup while one written to a `ready`
socket that never answered means the socket died unreported. Host kind rules DNS
resolution in or out, which no server-side telemetry can see.
Attaches it to the usage-reservation slot operations — the first Redis calls a
queued workflow makes, so an unusable connection surfaces there first. Connect
and ready now log elapsed-since-construction, making the wait before a
connection becomes usable directly measurable; today it is spent inside a
command's deadline, where it reads as a command timeout rather than as
connection latency.
Purely additive. Redis call arguments are unchanged, the wrapper rethrows the
original error object, and `describeRedisConnection` never throws — it runs
inside catch blocks where a throw would replace the real failure. All three have
tests that fail if the behavior is removed. Only non-sensitive facts are derived
from REDIS_URL, which carries the AUTH token and is never logged.1 parent 603f1c2 commit 9334a4d
5 files changed
Lines changed: 353 additions & 16 deletions
File tree
- apps/sim/lib
- billing/calculations
- core/config
- packages/testing/src/mocks
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
339 | 339 | | |
340 | 340 | | |
341 | 341 | | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
342 | 349 | | |
343 | 350 | | |
344 | 351 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
425 | 425 | | |
426 | 426 | | |
427 | 427 | | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
428 | 456 | | |
429 | 457 | | |
430 | 458 | | |
| |||
510 | 538 | | |
511 | 539 | | |
512 | 540 | | |
| 541 | + | |
513 | 542 | | |
514 | 543 | | |
515 | 544 | | |
| |||
622 | 651 | | |
623 | 652 | | |
624 | 653 | | |
625 | | - | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
626 | 659 | | |
627 | 660 | | |
628 | 661 | | |
| |||
633 | 666 | | |
634 | 667 | | |
635 | 668 | | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
| 669 | + | |
| 670 | + | |
640 | 671 | | |
641 | | - | |
642 | | - | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
643 | 681 | | |
644 | 682 | | |
645 | 683 | | |
646 | | - | |
647 | | - | |
648 | | - | |
649 | | - | |
650 | | - | |
651 | | - | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
652 | 688 | | |
653 | 689 | | |
654 | 690 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
| 43 | + | |
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
| |||
159 | 162 | | |
160 | 163 | | |
161 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
162 | 280 | | |
163 | 281 | | |
164 | 282 | | |
| |||
0 commit comments