Skip to content

Commit 962bdca

Browse files
TheSentinel454codex
andcommitted
relay readiness: keep completion epoch as gauge with republisher
Signed-off-by: tornquist <[email protected]> Co-authored-by: Codex <[email protected]>
1 parent 20baaee commit 962bdca

6 files changed

Lines changed: 317 additions & 68 deletions

File tree

‎crates/buzz-relay/src/main.rs‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ async fn run_relay_main(boot: BootTracker) -> anyhow::Result<()> {
227227

228228
let usage_interval_secs = usage_metrics_interval_secs();
229229
let usage_idle_timeout_secs = usage_metrics_idle_timeout_secs(usage_interval_secs);
230+
let dependency_sample_completion_republish_interval =
231+
buzz_relay::readiness::dependency_sample_completion_republish_interval(
232+
usage_idle_timeout_secs,
233+
);
230234
let (boot, ()) = boot.run_required(
231235
StartupPhase::MetricsBind,
232236
|| relay_metrics::try_install(config.metrics_port, usage_idle_timeout_secs),
@@ -244,6 +248,7 @@ async fn run_relay_main(boot: BootTracker) -> anyhow::Result<()> {
244248
info!(
245249
port = config.metrics_port,
246250
idle_timeout_secs = usage_idle_timeout_secs,
251+
completion_republish_secs = dependency_sample_completion_republish_interval.as_secs(),
247252
"Prometheus metrics exporter started"
248253
);
249254

@@ -1062,6 +1067,22 @@ async fn run_relay_main(boot: BootTracker) -> anyhow::Result<()> {
10621067
));
10631068
}
10641069

1070+
// Completion-epoch publisher: independent from sampling so the completion
1071+
// gauge survives recorder idle-eviction even when sampling stalls.
1072+
{
1073+
let publisher_state = Arc::clone(&state);
1074+
let cancel = publisher_state
1075+
.dependency_completion_publisher_cancel
1076+
.clone();
1077+
tokio::spawn(
1078+
buzz_relay::readiness::run_dependency_sample_completion_publisher(
1079+
publisher_state,
1080+
dependency_sample_completion_republish_interval,
1081+
cancel,
1082+
),
1083+
);
1084+
}
1085+
10651086
// Cross-pod connection-control consumer: receive disconnect commands from
10661087
// Redis pub/sub (published by the pod that recorded a ban) and close any
10671088
// matching local sockets. A member's live connections may land on any pod,
@@ -1236,6 +1257,7 @@ async fn run_relay_main(boot: BootTracker) -> anyhow::Result<()> {
12361257
serve(router, health_router, Arc::clone(&state)).await?;
12371258
state.community_revalidator_cancel.cancel();
12381259
state.dependency_sampler_cancel.cancel();
1260+
state.dependency_completion_publisher_cancel.cancel();
12391261

12401262
// Signal the audit worker to stop accepting, flush buffered entries, and
12411263
// exit. Uses a CancellationToken so it works regardless of how many

‎crates/buzz-relay/src/metrics.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,9 @@ pub(crate) fn describe_readiness_metrics() {
332332
"buzz_readiness_state",
333333
"Latest private readiness-probe observation, where 1 is ready and 0 is shutting down"
334334
);
335-
metrics::describe_counter!(
335+
metrics::describe_gauge!(
336336
"buzz_readiness_dependency_sample_completed_timestamp_seconds",
337-
"Unix time the cached /_status dependency report completed, absent until the first sample completes"
337+
"Unix time the cached /_status dependency report completed, absent until the first sample completes; sampler completion advances it and the publisher re-emits it"
338338
);
339339
}
340340

0 commit comments

Comments
 (0)