🐛 fix closed async backlog accounting

This commit is contained in:
Nanaloveyuki
2026-06-14 02:06:59 +08:00
parent d9b609d064
commit 9af489336d
5 changed files with 36 additions and 3 deletions
+1
View File
@@ -36,6 +36,7 @@ Detailed rules explaining key parameters and behaviors
- The counter increases when overflow policy discards records.
- The counter can also increase when `close(clear=true)` or `shutdown(clear=true)` abandons queued records.
- It can also increase when shutdown fallback logic converts remaining pending records into dropped records during a clear-close path.
- Later log attempts against an already closed queue do not add to this counter by themselves.
- This is a cumulative counter for the lifetime of the logger value.
- Use this helper when you need a focused loss metric rather than a full `state()` snapshot.
+3
View File
@@ -47,6 +47,7 @@ Detailed rules explaining key parameters and behaviors
- Context fields, patch logic, and filter logic are applied before enqueue.
- If timestamping is enabled, `@env.now()` is captured before the record enters the queue.
- Overflow behavior depends on the configured `AsyncOverflowPolicy`.
- Closed-on-log behavior is runtime-dependent: compatibility runtimes short-circuit before enqueue work, while native-worker runtimes may still reach the queue operations and then treat a closed queue as a non-accepted write.
### How to Use
@@ -82,6 +83,8 @@ e.g.:
- If the logger is closed or overflow policy rejects the record, enqueue may not proceed as a normal accepted write.
- A closed queue does not count as a newly accepted pending record.
### Notes
1. Use this API when the call site needs full control instead of a fixed severity helper.
+1
View File
@@ -36,6 +36,7 @@ Detailed rules explaining key parameters and behaviors
- The count increases when records are accepted into the queue.
- The count decreases as the worker drains records.
- The count is also reset to `0` when queued records are abandoned through clear-close paths such as `close(clear=true)`.
- Log attempts against a closed queue do not create new pending backlog.
- This is a point-in-time metric and may change immediately after it is read.
- Use this helper when a single backlog number is enough and a full `state()` snapshot is unnecessary.