Assign one owner
Một thread/task duy nhất gọi bounded wait; snapshot readers khác không sở hữu wait lane.
Product knowledge · Advanced · Monitoring
Health và fresh liveness là direct observations. Optional Monitor mới collect bounded aggregates/events; exporter sao chép facts ra ngoài bằng queue và deadline do application sở hữu.
01 · Choose the observation
| Câu hỏi | Surface đúng | Không được suy |
|---|---|---|
| Service đang ở lifecycle nào và còn nhận request không? | Direct health snapshot | Ready không chứng minh event loop vừa tiến triển. |
| Runtime có acknowledge một fresh probe trong deadline không? | Bounded fresh-liveness probe | Probe pass không chứng minh dependency hay business handler healthy. |
| Core đã accept configuration/capability nào? | Runtime information + effective configuration | Builder input không phải observed fact. |
| Traffic/exchange/control/latency đang diễn biến thế nào? | Optional bounded Monitor | Monitor tắt không làm direct health biến mất; wait không tự bật collection. |
02 · Ownership model
Sở hữu health/progress, effective monitor policy, aggregates, bounded event ring, cursor/loss accounting và wait/interrupt lifecycle.
Chiếu typed values, giữ exact integer/enum identity, copy ra host values đúng lifetime và không dựng default hay category riêng.
Chọn signal/cadence, map metrics/alerts, sở hữu exporter queue, batching, network I/O, credentials, retry và shutdown order.
Sở hữu health endpoint exposure, scrape/service discovery, alert routing, retention, access control và replica-level interpretation.
03 · Direct health
CREATED, RUNNING, DRAINING hoặc STOPPED; đọc cùng readiness/admission thay vì tự suy từ process/socket.Trong khi live-control observation còn unresolved, health/liveness/route snapshot có thể trả CONTROL_UNRESOLVED mà không đổi output. Không gắn nhãn last confirmed cut là current.
04 · Fresh liveness
health snapshot = non-blocking state observed now
fresh liveness probe = ask runtime progress lane to acknowledge within timeout
probe timeout ≠ business request timeout
probe pass ≠ downstream dependency health
probe failure = keep structured evidence; do not fabricate ready=trueDùng finite timeout phù hợp với scheduler/host. Liveness endpoint không chạy unbounded work, không gọi mọi dependency và không dùng một cached success làm fresh proof.
05 · Collection policy
| Field | Ý nghĩa trong SDK 2.3.0 |
|---|---|
| Collection | DISABLED, AGGREGATES hoặc AGGREGATES_AND_EVENTS. Mặc định disabled. |
| Notification | POLL hoặc SIGNAL; signal chỉ dùng được khi startup đã reserve. |
| Latency | NONE hoặc fixed pre-reserved buckets; không tạo histogram tùy ý giữa runtime. |
| Active event capacity | Phần đang dùng trong reserved ring; live apply không vượt reserved event capacity. |
| Aggregate/event categories | SDK 2.3.0 nhận bitmask LIFECYCLE, EXCHANGE, CONTROL, LATENCY. Supported mask từ Core là authoritative. |
| Max events per read | Startup bound cho mỗi page; caller vẫn chọn finite maximum và cung cấp đủ capacity. |
Policy apply dùng expected configuration generation. Invalid enum/category relationship, unsupported category, reservation exceeded, signal not reserved, generation conflict, invalid lifecycle, sequence exhaustion hoặc internal failure đều giữ complete policy cũ.
06 · Identity map
Compare-and-apply identity của effective policy. Hai controller cùng đọc một generation thì chỉ operation hợp lệ đầu tiên có thể advance nó.
Context/interval để hiểu counters và reset. Epoch change chia time series; nó không thay expected generation khi apply.
Monotonic observation identity cho policy/collection changes trong instance; không phải wall clock.
Cursor identity của retained event stream; gap/overwrite phải được báo thay vì che bằng timestamp.
Export generation, epoch và sequence cùng values. Không merge samples từ hai epochs thành một continuous interval.
07 · Aggregate snapshot
| Nhóm | Fields cần hiểu |
|---|---|
| Quality | collecting, stale, partial, snapshot/change sequence và observed monotonic time. Stale/partial không được export như complete fresh sample. |
| Traffic/exchange | Admitted requests/bytes; completed, failed, timed out, disconnected, cancelled; response status-family counters. |
| Event channel | Retained, overwritten, dropped events; signal notifications, coalesced signals và signal failures. |
| Failure/latency | Bounded stable failure rows và fixed latency buckets đã reserve; unknown reason vẫn giữ numeric identity. |
| Effective context | Complete monitor config + direct health embedded trong snapshot để sample không mất generation/epoch/lifecycle context. |
Traffic/response/failure/signal là snapshot fields, không phải policy category riêng trong SDK 2.3.0. Snapshot không báo độ dài hàng đợi hiện tại của connector. Xuất chỉ số này riêng nếu connector cung cấp.
08 · Event cursor
wait(finite timeout)
→ read(after_sequence, finite maximum, finite output capacity)
→ process retained events in sequence
→ record oldest / latest / remaining / overwritten
→ advance cursor only from returned facts| Fact | Luật đọc |
|---|---|
| Event | Giữ kind, sequence/change sequence, config generation, collection epoch, monotonic time, category, stable failure reason và exchange identity. |
| Oldest/latest | Xác định retained window; không suy continuity chỉ vì latest tăng. |
| Overwritten | Báo history gap rõ ràng, đánh dấu interval incomplete và resync bằng snapshot; không bịa lại event đã mất. |
| Remaining | Cho biết còn page trong retained ring; tiếp tục bounded reads thay vì tăng page vô hạn. |
| Queue-shaped fields | Chỉ dùng khi exact producer/capability xác nhận; field tồn tại không chứng minh mọi category phát queue depth. |
09 · Wait and shutdown
Một thread/task duy nhất gọi bounded wait; snapshot readers khác không sở hữu wait lane.
Notifications có thể coalesce. Sau wake luôn đọc snapshot/page; đừng đếm wakeup như event count.
Giữ monitoring sống khi cần quan sát accepted work trong finite drain interval.
Lifecycle owner ra tín hiệu stop, interrupt waiter từ thread khác, join hữu hạn rồi mới close runtime.
Wait timeout chỉ nghĩa chưa có wake trong cửa sổ đó. Signal failure hoặc monitor pressure không được block HTTP traffic hay đổi exchange terminal.
10 · Data boundary
11 · Application exporter
CoAkka HTTP Runtime snapshot/page
→ copy bounded typed values
→ finite application queue
→ batch + finite network deadline
→ Prometheus / OpenTelemetry / logs / local dashboard
queue full / backend down → count exporter drop; never block HTTP workApplication sở hữu metric names, labels/cardinality, backend TLS/auth, batching, retry/backoff, total budget và shutdown. Runtime không retry exporter, không giữ credential và không biến exporter failure thành request failure.
12 · Failure law
| Observed fact | Next safe action |
|---|---|
| Health/liveness observation unresolved | Giữ output cũ là unknown, recover exact control operation; không tự tuyên bố current/ready. |
| Policy generation conflict | Đọc effective config mới, merge/reconsider intent rồi apply bằng generation hiện tại. |
| Unsupported/reservation refusal | Giữ policy cũ; chọn supported subset hoặc replacement service với reservation mới. |
| Stale/partial snapshot | Gắn quality flag, không dùng như complete fresh interval; đọc lại ở bounded cadence. |
| Overwritten/dropped event | Record gap, resync aggregate snapshot và sửa reader/exporter capacity; không tuyên bố event completeness. |
| Wait interrupted/timeout | Phân biệt lifecycle interrupt với empty wait; không xem như request/runtime terminal. |
| Exporter queue/backend failure | Drop/buffer theo finite policy, surface riêng và bảo vệ HTTP path. |
13 · Evidence record
Gửi một yêu cầu trên máy và xem bộ đếm thay đổi thế nào khi dịch vụ drain.
14 · Integration checklist