Repository navigation
Commit 6a4eb20
authored
### Description
`capture_checkin` returned a check-in id even when the check-in wasn't
sent, because it ignored the return value of `capture_event`. That
happens when there is no active client, or when `before_send` drops the
event. A caller that hands the id to another process (as in the issue:
the scheduler opens the check-in, the worker closes it, and opens its
own only when no id arrives) can't tell that the check-in never reached
Sentry.
It now returns `None` in that case, the same way `capture_event` does.
`monitor` and the Celery Beat integration pass the returned id into the
closing `capture_checkin` call, which generates a new id when it gets
`None`, so they behave as before. The return type becomes
`Optional[str]`, so type-checked code that uses the result as a `str`
will now get a mypy error until it handles `None`.
`test_capture_checkin_sdk_not_initialized` expected the passed-in id
back when the SDK isn't initialized and now expects `None`.
The alternative was keeping the `str` return type and adding a separate
way to ask whether the check-in went out, but `None` matches
`capture_event` and needs no new API.
#### Issues
* resolves: #7845
* resolves: PY-2924
1 parent c5f80df commit 6a4eb20
2 files changed
Lines changed: 39 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
| 45 | + | |
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
| 55 | + | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
321 | 321 | | |
322 | 322 | | |
323 | 323 | | |
324 | | - | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
325 | 360 | | |
326 | 361 | | |
327 | 362 | | |
| |||
0 commit comments