Skip to content

Add OTLP metrics for workers, gRPC, the scheduler, store tiers and health - #2687

Merged
amankrx merged 1 commit into
TraceMachina:mainfrom
amankrx:feat/worker-fleet-otlp-metrics
Aug 14, 2026
Merged

Add OTLP metrics for workers, gRPC, the scheduler, store tiers and health#2687
amankrx merged 1 commit into
TraceMachina:mainfrom
amankrx:feat/worker-fleet-otlp-metrics

Conversation

@amankrx

@amankrx amankrx commented Aug 13, 2026

Copy link
Copy Markdown
Member

What and why

Fixes #2614. NativeLink had OTLP metrics for cache and execution only. Everything else lived in the older #[metric] system or nowhere.

Adds the missing categories: workers (connected, connects, disconnects, keepalives, paused/draining), gRPC (one duration histogram by service, method and status, giving rate, errors and latency together), scheduler matching duration, fast/slow store tier hits and bytes, and health check results.

Also the two execution metrics dropped in #2599 for want of a data source. Memory comes from ActionResourceUsage.peak_memory_kb, which the worker already reported. CPU time is new: the worker samples /proc/<pid>/stat for the process group every 250ms already, so it now reads utime/stime from the same line and reports it as cpu_time_ms.

Connection pools are covered too: free slots at acquisition, whether a caller had to queue, and Redis reconnects. A pool that keeps reporting zero free slots is the bottleneck whatever the latency elsewhere says.

Nothing is labelled by worker id or action digest; both grow without bound.

How this was verified

Unit tests for the metric helpers, the gRPC path splitter, the health status labels, and the /proc/<pid>/stat CPU parser.

Risk

Moderate, mostly in accounting rather than behaviour.

CPU time is cumulative per process and a process that exits disappears from /proc, so the sampler keeps the last value per pid and totals them at the end rather than summing the live group. cutime/cstime are excluded, since they only cover reaped children and would double count.

Worker counts are per scheduler instance; with several schedulers the fleet total is the sum. They are exact by construction: unbounded LRU so nothing is silently evicted, one removal path, and re-adding an id does not double count.

gRPC status comes from response headers. Tonic puts it in trailers when a call fails mid-stream, and trailers are not reachable from that layer without consuming the body, so error rate undercounts mid-stream failures. Rate and latency are exact.

The proto gains cpu_time_ms at tag 5, a new optional field, so an old worker reports zero.

Nothing from #2614 is left out.


This change is Reviewable

@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nativelink Ready Ready Preview Aug 14, 2026 4:02am
nativelink-aidm Ready Ready Preview Aug 14, 2026 4:02am

Request Review

@amankrx
amankrx marked this pull request as draft August 13, 2026 05:10
@amankrx
amankrx force-pushed the feat/worker-fleet-otlp-metrics branch from 8b9e28b to e56d976 Compare August 13, 2026 05:38
@amankrx amankrx changed the title Add OTLP metrics for the worker fleet Add OTLP metrics for workers, gRPC, the scheduler, store tiers and health Aug 13, 2026
@amankrx
amankrx marked this pull request as ready for review August 13, 2026 07:24
@amankrx
amankrx force-pushed the feat/worker-fleet-otlp-metrics branch from e56d976 to b9a6242 Compare August 13, 2026 07:24
@amankrx
amankrx force-pushed the feat/worker-fleet-otlp-metrics branch from b9a6242 to 83f23b1 Compare August 13, 2026 12:26
@amankrx
amankrx requested a review from palfrey August 13, 2026 13:08
@amankrx
amankrx force-pushed the feat/worker-fleet-otlp-metrics branch from 83f23b1 to a5eebe9 Compare August 14, 2026 02:27
@amankrx
amankrx force-pushed the feat/worker-fleet-otlp-metrics branch from a5eebe9 to c4e170a Compare August 14, 2026 03:11
@amankrx
amankrx force-pushed the feat/worker-fleet-otlp-metrics branch from c4e170a to 3c4bd22 Compare August 14, 2026 03:39

@MarcusSorealheis MarcusSorealheis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@amankrx
amankrx merged commit 9172cec into TraceMachina:main Aug 14, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Complete the OTLP metrics coverage: instrument declared-but-missing metrics and add missing operational metrics

2 participants