Skip to content

Commit dc68b23

Browse files
committed
metrics: add InitTime measurment + grafana panel
1 parent 2e86281 commit dc68b23

6 files changed

Lines changed: 380 additions & 57 deletions

File tree

metrics/README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,17 @@ Distribution ranges: 1%, 5%, 10%, 25%, 50%, 75%, 90%, 90%+.
261261

262262
Utilization is computed as `RunningTime / Uptime`. A value of 0.50 means the process has spent 50% of its lifetime executing callbacks. The remaining time was spent waiting for messages. Processes with zero running time or zero uptime are excluded.
263263

264+
### Process Init Time Metrics
265+
266+
The metrics actor tracks how long each process spent in its `ProcessInit` callback. This identifies actors with slow initialization -- heavy setup, blocking I/O, or synchronous calls during init.
267+
268+
No build tags required. Init time metrics are always active.
269+
270+
| Metric | Type | Labels | Description |
271+
|--------|------|--------|-------------|
272+
| `ergo_process_init_time_max_seconds` | Gauge | - | Maximum ProcessInit duration across all processes on this node |
273+
| `ergo_process_init_time_top_seconds` | Gauge | pid, name, application, behavior | Top-N processes by ProcessInit duration |
274+
264275
### Process Throughput Metrics
265276

266277
Per-process message throughput top-N and node-level aggregates.
@@ -343,7 +354,7 @@ The dashboard includes a `$node` variable dropdown at the top. It allows selecti
343354
Six stat panels showing aggregated values for selected nodes:
344355

345356
- **Total Processes** -- total number of processes across selected nodes
346-
- **Running** -- number of running processes (green). A large gap between Total and Running indicates many processes are idle or waiting
357+
- **Running** -- number of processes currently executing callbacks or waiting for a Call response. The gap between Total and Running is normal -- most processes spend their time in Sleep state (idle, waiting for messages)
347358
- **Zombie** -- number of zombie processes (green when 0, red when 1 or more). Non-zero value signals that some processes have terminated abnormally and were not properly cleaned up -- requires investigation
348359
- **Memory Used** -- total OS memory used across selected nodes
349360
- **Memory Alloc** -- total runtime memory allocated across selected nodes. A significant difference between Used and Alloc may indicate memory fragmentation or that the runtime is holding memory that could be released
@@ -431,10 +442,10 @@ Two timeseries panels (message throughput overview):
431442
- **Message Throughput (Cluster Total)** -- cluster-wide message rate showing total inbound (received by processes) and outbound (sent by processes). A sudden drop may indicate stalled processes or upstream failures
432443
- **Message Throughput per Node** -- message rate per node showing inbound and outbound. Identifies nodes with the highest message flow
433444

434-
Two timeseries panels (message throughput top-N by rate):
445+
Two table panels (message throughput top-N):
435446

436-
- **Top Processes by Inbound Rate** -- top 10 processes by current inbound message rate (msg/s). Shows which actors are receiving the most messages right now. Compare with mailbox depth -- high rate with low depth means the process handles messages quickly; high rate with growing depth means it's falling behind
437-
- **Top Processes by Outbound Rate** -- top 10 processes by current outbound message rate (msg/s). Shows which actors generate the most messages right now. High outbound rate identifies the busiest senders -- event producers, dispatchers, coordinators
447+
- **Top Processes by Messages In** -- top 50 processes by total messages received (cumulative). Identifies which actors handle the most inbound traffic
448+
- **Top Processes by Messages Out** -- top 50 processes by total messages sent (cumulative). Identifies which actors generate the most outbound traffic
438449

439450
Two timeseries panels (utilization overview):
440451

@@ -448,12 +459,14 @@ Two panels (utilization detail):
448459

449460
#### Processes (collapsed row)
450461

451-
A collapsed row containing four timeseries graphs. Click to expand.
462+
A collapsed row containing six panels. Click to expand.
452463

453464
- **Processes (total)** -- total process count per node. Steady growth without a plateau may indicate a process leak (processes being spawned but never terminated)
454465
- **Processes (running)** -- running process count per node. Helps identify load distribution across the cluster -- uneven running counts may point to hotspot nodes
455466
- **Process Spawn Rate** -- rate of successfully spawned processes per node. Also shows failed spawn attempts (in red). Spawn failures indicate resource exhaustion or configuration errors. A sudden spike in spawn rate may signal a restart loop
456467
- **Process Termination Rate** -- rate of terminated processes per node. When termination rate consistently exceeds spawn rate, the node is draining. When spawn rate exceeds termination rate, process count is growing -- correlate with the Processes panel to verify
468+
- **Init Time per Node** -- bar gauge showing maximum ProcessInit duration per node. Color indicates severity: green < 100ms, yellow < 1s, red > 1s. Shows at a glance which nodes have slow initialization
469+
- **Top Processes by Init Time** -- table showing processes with the longest ProcessInit duration. Identifies which actor types take the longest to initialize
457470

458471
#### Resources (collapsed row)
459472

metrics/actor.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ type Actor struct {
8484
// Process throughput metrics
8585
throughput throughputMetrics
8686

87+
// Process init time metrics
88+
inittime initTimeMetrics
89+
8790
// Event metrics
8891
event eventMetrics
8992

@@ -328,6 +331,9 @@ func (a *Actor) initializeMetrics() error {
328331
// Initialize process throughput metrics
329332
a.throughput.init(a.registry, nodeLabels)
330333

334+
// Initialize process init time metrics
335+
a.inittime.init(a.registry, nodeLabels)
336+
331337
// Initialize event metrics
332338
a.event.init(a.registry, nodeLabels)
333339

@@ -474,6 +480,7 @@ func (a *Actor) collectBaseMetrics() error {
474480
a.depth.begin()
475481
a.utilization.begin()
476482
a.throughput.begin()
483+
a.inittime.begin()
477484

478485
var totalMessagesIn uint64
479486
var totalMessagesOut uint64
@@ -499,13 +506,17 @@ func (a *Actor) collectBaseMetrics() error {
499506
// Process throughput metrics
500507
a.throughput.observe(info, topN)
501508

509+
// Process init time metrics
510+
a.inittime.observe(info, topN)
511+
502512
return true
503513
})
504514

505515
a.depth.flush()
506516
a.utilization.flush()
507517
a.latency.flush()
508518
a.throughput.flush()
519+
a.inittime.flush()
509520

510521
// Collect event metrics
511522
a.event.begin()

0 commit comments

Comments
 (0)