feat: hot-path-safe node metrics + gateway /metrics + Grafana starter kit (match#33)#61
Merged
Merged
Conversation
… kit (match#33) Engine/cluster side (NO Micrometer, nothing new allocating or locking on the matching thread): - NodeMetrics: plain-long counters + preallocated log2 latency histogram (1us..1s buckets) written only on the cluster agent thread; order latency sampled 1-in-16 around sbeDemuxer.dispatch so nanoTime stays off most orders; cross-thread visibility via a volatile piggyback bumped from the existing flush timer. Role tracked from onRoleChange (cluster.memberId() is -1 during onStart — nodeId comes from CLUSTER_NODE like the bootstrap). - NodeMetricsServer: JDK com.sun.net.httpserver on its own daemon thread, hand-rendered Prometheus text; port METRICS_PORT (default 9500+nodeId); started in onStart, stopped in onTerminate; failure to start never takes a node down. Exposes submitted/terminal/overflow/trades/drops/queues/ sessions/aeron-errors + role, memberId, snapshot age (stamped in onTakeSnapshot), egress age, and the latency histogram. Market gateway: - /metrics on the existing Netty HTTP surface (GatewayHttpHandler): WS clients/dropped-frames/resyncs/slow-disconnects, stale deltas, cluster session up, egress messages/age, aeron errors. New volatile-read getters on AeronGateway/GatewayStateManager. Observability kit (grafana/): prometheus.yml scrape config (nodes 9500-9502, gateway 8081, OMS 8080), alerts.yml (no leader, snapshot age >2x interval, reliable-egress drops, OMS egress gaps, risk-reject spike, OMS disconnected), starter dashboard JSON (10 panels), README. Tests: NodeMetricsServerTest (render, bucket cumulation/saturation, sampling cadence), GatewayHttpHandlerTest /metrics route. Full suite green (786). Live-verified after rolling update: 3 nodes + gateway serving; a 15s load run showed identical counters on all 3 nodes (3,907,420 orders / 3,079,530 trades / exactly 244,215 sampled latencies each — determinism visible in metrics), mean engine processing ~0.76us. No-regression: box is in quiet/dev-driver mode (user drop-in) — sustained 160k/s vs the documented ~148k dev-rung ceiling with equal client latencies (p50 0.22us); prod-profile 800k rerun offered as follow-up. Closes #33. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Engine/cluster side (NO Micrometer, nothing new allocating or locking on the
matching thread):
(1us..1s buckets) written only on the cluster agent thread; order latency
sampled 1-in-16 around sbeDemuxer.dispatch so nanoTime stays off most
orders; cross-thread visibility via a volatile piggyback bumped from the
existing flush timer. Role tracked from onRoleChange (cluster.memberId() is
-1 during onStart — nodeId comes from CLUSTER_NODE like the bootstrap).
hand-rendered Prometheus text; port METRICS_PORT (default 9500+nodeId);
started in onStart, stopped in onTerminate; failure to start never takes
a node down. Exposes submitted/terminal/overflow/trades/drops/queues/
sessions/aeron-errors + role, memberId, snapshot age (stamped in
onTakeSnapshot), egress age, and the latency histogram.
Market gateway:
clients/dropped-frames/resyncs/slow-disconnects, stale deltas, cluster
session up, egress messages/age, aeron errors. New volatile-read getters
on AeronGateway/GatewayStateManager.
Observability kit (grafana/): prometheus.yml scrape config (nodes 9500-9502,
gateway 8081, OMS 8080), alerts.yml (no leader, snapshot age >2x interval,
reliable-egress drops, OMS egress gaps, risk-reject spike, OMS disconnected),
starter dashboard JSON (10 panels), README.
Tests: NodeMetricsServerTest (render, bucket cumulation/saturation, sampling
cadence), GatewayHttpHandlerTest /metrics route. Full suite green (786).
Live-verified after rolling update: 3 nodes + gateway serving; a 15s load run
showed identical counters on all 3 nodes (3,907,420 orders / 3,079,530 trades
/ exactly 244,215 sampled latencies each — determinism visible in metrics),
mean engine processing ~0.76us. No-regression: box is in quiet/dev-driver
mode (user drop-in) — sustained 160k/s vs the documented ~148k dev-rung
ceiling with equal client latencies (p50 0.22us); prod-profile 800k rerun
offered as follow-up.
Closes #33.
Co-Authored-By: Claude Fable 5 noreply@anthropic.com