chore(sync): bound INFO log collection fields

Production journal review returned a 465 KiB truncated window because several INFO records rendered complete relay and event-id collections. Repository announcements can supply those relay sets, while sync state can grow the event sets, so a single diagnostic record had no useful size bound.

Retain the authoritative collection counts but render at most five representative members in INFO-level fields. This covers batch confirmation, relay discovery, and aggregate disconnect/reconnect decisions; full DEBUG filter diagnostics remain available when explicitly enabled.

This changes observability only. It does not cap sync state, relay discovery, event processing, or scheduling, and it deliberately does not introduce configuration for a diagnostic sample size.

Validated with cargo test --lib (650 passed), cargo test --test sync (89 passed, 1 ignored), git diff --check, and nix build .#ngit-grasp.
This commit is contained in:
DanConwayDev
2026-08-07 17:02:40 +00:00
parent c3bcd132bc
commit 3c014c7cf4
2 changed files with 14 additions and 7 deletions
+8 -5
View File
@@ -744,6 +744,10 @@ const CONSOLIDATION_THRESHOLD: usize = 70;
/// exhaust network resources while keeping the sync actor responsive.
const MAX_CONCURRENT_CONNECT_ATTEMPTS: usize = 8;
/// Maximum number of collection members rendered in an INFO-level log field.
/// Counts remain authoritative; samples keep remotely influenced logs bounded.
const LOG_COLLECTION_SAMPLE_SIZE: usize = 5;
/// Adaptive per-relay threshold for historic REQ+EOSE pagination.
///
/// NIP-01 guarantees none of this; the model is empirical. A source audit of
@@ -2399,7 +2403,6 @@ impl SyncManager {
);
}
// DEBUG TRACING: Log the root events being confirmed
tracing::info!(
relay = %relay_url,
batch_id = batch_id,
@@ -2407,11 +2410,11 @@ impl SyncManager {
full_repos_confirmed = full_repos_count,
state_only_repos_confirmed = state_only_repos_count,
root_events_confirmed = events_count,
root_events_ids = ?batch.items.root_events.iter().map(|id| id.to_hex()).collect::<Vec<_>>(),
root_events_sample = ?batch.items.root_events.iter().take(LOG_COLLECTION_SAMPLE_SIZE).map(|id| id.to_hex()).collect::<Vec<_>>(),
total_full_repos = state.repos.len(),
total_state_only_repos = state.state_only_repos.len(),
total_root_events = state.root_events.len(),
all_root_events = ?state.root_events.iter().map(|id| id.to_hex()).collect::<Vec<_>>(),
all_root_events_sample = ?state.root_events.iter().take(LOG_COLLECTION_SAMPLE_SIZE).map(|id| id.to_hex()).collect::<Vec<_>>(),
is_generic_filter = is_generic_filter,
announcements_synced = state.announcements_synced,
had_failures = state.historic_sync_had_failures,
@@ -5148,7 +5151,7 @@ impl SyncManager {
tracing::info!(
count = to_disconnect.len(),
relays = ?to_disconnect,
relay_sample = ?to_disconnect.iter().take(LOG_COLLECTION_SAMPLE_SIZE).collect::<Vec<_>>(),
"Found empty non-bootstrap relays to disconnect"
);
@@ -5254,7 +5257,7 @@ impl SyncManager {
tracing::info!(
count = to_reconnect.len(),
relays = ?to_reconnect,
relay_sample = ?to_reconnect.iter().take(LOG_COLLECTION_SAMPLE_SIZE).collect::<Vec<_>>(),
"Attempting reconnection for disconnected relays"
);
+6 -2
View File
@@ -20,6 +20,9 @@ use crate::nostr::SharedDatabase;
use super::{AddFilters, RepoSyncIndex, RepoSyncNeeds, SyncLevel};
/// Counts remain complete while remotely influenced log samples stay bounded.
const LOG_COLLECTION_SAMPLE_SIZE: usize = 5;
// =============================================================================
// LoopControl - Result of notification processing
// =============================================================================
@@ -275,7 +278,7 @@ impl SelfSubscriber {
event_id = %event.id,
repo_id = %repo_id,
relay_count = relays.len(),
relays = ?relays,
relay_sample = ?relays.iter().take(LOG_COLLECTION_SAMPLE_SIZE).collect::<Vec<_>>(),
"[DIAG] Queued 30617 announcement for batch processing"
);
}
@@ -574,7 +577,8 @@ impl SelfSubscriber {
for (repo_id, needs) in &updates {
tracing::info!(
repo_id = %repo_id,
relay_urls = ?needs.relays,
relay_count = needs.relays.len(),
relay_sample = ?needs.relays.iter().take(LOG_COLLECTION_SAMPLE_SIZE).collect::<Vec<_>>(),
"Discovered repo with relay URLs"
);
}