Product knowledge · Advanced · Monitoring

Quan sát runtime mà không biến request path thành logging callback.

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

Bốn câu hỏi dùng bốn surface khác nhau

Câu hỏiSurface đúngKhông được suy
Service đang ở lifecycle nào và còn nhận request không?Direct health snapshotReady 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 probeProbe pass không chứng minh dependency hay business handler healthy.
Core đã accept configuration/capability nào?Runtime information + effective configurationBuilder input không phải observed fact.
Traffic/exchange/control/latency đang diễn biến thế nào?Optional bounded MonitorMonitor tắt không làm direct health biến mất; wait không tự bật collection.

02 · Ownership model

Core phát hành facts; application quyết định nơi export

CoAkka HTTP Runtime

Sở hữu health/progress, effective monitor policy, aggregates, bounded event ring, cursor/loss accounting và wait/interrupt lifecycle.

Connector

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.

Application

Chọn signal/cadence, map metrics/alerts, sở hữu exporter queue, batching, network I/O, credentials, retry và shutdown order.

Deployment

Sở hữu health endpoint exposure, scrape/service discovery, alert routing, retention, access control và replica-level interpretation.

03 · Direct health

Health là coherent local snapshot, không phải một boolean

Lifecycle
CREATED, RUNNING, DRAINING hoặc STOPPED; đọc cùng readiness/admission thay vì tự suy từ process/socket.
Snapshot sequence + observed monotonic time
Identity và thời điểm của observation; monotonic time không phải wall-clock timestamp.
Progress sequence + monotonic time
Core-issued progress evidence. Giá trị cũ không tự là fresh-liveness proof.
Acknowledged probe sequence + time
Probe nào đã được runtime acknowledge; bounded probe mới yêu cầu progress mới trong deadline.
Route/metadata generation + binding-change sequence
Effective control-plane identity đang quan sát; không tự tăng hoặc thay bằng source version.
Ready + admission open
Hai facts riêng: service có thể operational nhưng admission đã đóng khi drain.
Activity
Active/pending requests, connections, WebSocket sessions và outbound pending tại snapshot; đây là gauges, không phải ownership transfer.

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.

Chạy bài drain với một request đang xử lý

04 · Fresh liveness

“Process còn tồn tại” chưa đủ

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=true

Dù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

Reserve maximum shape trước start; live policy chỉ thu hẹp hoặc dùng phần đã reserve

FieldÝ nghĩa trong SDK 2.3.0
CollectionDISABLED, AGGREGATES hoặc AGGREGATES_AND_EVENTS. Mặc định disabled.
NotificationPOLL hoặc SIGNAL; signal chỉ dùng được khi startup đã reserve.
LatencyNONE hoặc fixed pre-reserved buckets; không tạo histogram tùy ý giữa runtime.
Active event capacityPhần đang dùng trong reserved ring; live apply không vượt reserved event capacity.
Aggregate/event categoriesSDK 2.3.0 nhận bitmask LIFECYCLE, EXCHANGE, CONTROL, LATENCY. Supported mask từ Core là authoritative.
Max events per readStartup 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

Policy generation và collection epoch không phải cùng một con số

Configuration generation

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ó.

Collection epoch

Context/interval để hiểu counters và reset. Epoch change chia time series; nó không thay expected generation khi apply.

Change sequence

Monotonic observation identity cho policy/collection changes trong instance; không phải wall clock.

Event sequence

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

Một snapshot giữ counters, quality flags và config đã accept

NhómFields cần hiểu
Qualitycollecting, stale, partial, snapshot/change sequence và observed monotonic time. Stale/partial không được export như complete fresh sample.
Traffic/exchangeAdmitted requests/bytes; completed, failed, timed out, disconnected, cancelled; response status-family counters.
Event channelRetained, overwritten, dropped events; signal notifications, coalesced signals và signal failures.
Failure/latencyBounded stable failure rows và fixed latency buckets đã reserve; unknown reason vẫn giữ numeric identity.
Effective contextComplete 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

Notification là doorbell; bounded page mới là data

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
FactLuật đọc
EventGiữ kind, sequence/change sequence, config generation, collection epoch, monotonic time, category, stable failure reason và exchange identity.
Oldest/latestXác định retained window; không suy continuity chỉ vì latest tăng.
OverwrittenBá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.
RemainingCho biết còn page trong retained ring; tiếp tục bounded reads thay vì tăng page vô hạn.
Queue-shaped fieldsChỉ 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 runtime chỉ có một blocking monitor waiter

1

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.

2

Wake, then read

Notifications có thể coalesce. Sau wake luôn đọc snapshot/page; đừng đếm wakeup như event count.

3

Stop admission and observe drain

Giữ monitoring sống khi cần quan sát accepted work trong finite drain interval.

4

Interrupt, join, close

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

Monitor là operational evidence, không phải traffic capture

11 · Application exporter

Copy facts ra khỏi runtime rồi export bằng một pipeline hữu hạn

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 work

Application 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

Mỗi failure cần đúng owner và recovery

Observed factNext safe action
Health/liveness observation unresolvedGiữ 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 refusalGiữ policy cũ; chọn supported subset hoặc replacement service với reservation mới.
Stale/partial snapshotGắn quality flag, không dùng như complete fresh interval; đọc lại ở bounded cadence.
Overwritten/dropped eventRecord gap, resync aggregate snapshot và sửa reader/exporter capacity; không tuyên bố event completeness.
Wait interrupted/timeoutPhân biệt lifecycle interrupt với empty wait; không xem như request/runtime terminal.
Exporter queue/backend failureDrop/buffer theo finite policy, surface riêng và bảo vệ HTTP path.

13 · Evidence record

Một dashboard đẹp chưa chứng minh runtime contract

Thực hành đọc Monitor và drain

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

Trước khi chọn API ngôn ngữ