Return diagnostics snapshot on first Stats and refactor diagnostics collection#253
Closed
mateeullahmalik wants to merge 1 commit intomasterfrom
Closed
Return diagnostics snapshot on first Stats and refactor diagnostics collection#253mateeullahmalik wants to merge 1 commit intomasterfrom
mateeullahmalik wants to merge 1 commit intomasterfrom
Conversation
Review complete. No issues found. The changes correctly address the motivation of ensuring the first Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
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.
Motivation
Statscalls could return an empty/zeroed diagnostics snapshot because the expensive diagnostics refresh was only scheduled async, causing metrics to be missing on first call.Statsinvocation can synchronously obtain and return a populated diagnostics snapshot so status consumers get meaningful data immediately.Description
Statsnow callsrefreshDiagnosticsSyncand uses the returned*StatsSnapshotwhen the cache is empty instead of relying on cache propagation.collectDiagnostics(ctx,p,prev)(replacesrefreshDiagnostics) which returns(*StatsSnapshot, error)and performs the heavy snapshot collection without mutating global state directly.refreshDiagnosticsSyncandmaybeRefreshDiagnosticsnow both callcollectDiagnosticsand, when a snapshot is returned, callm.setSnapshot(next)andm.markFresh(); both paths remain deduped byrefreshInFlight.p2pStatsSlowRefreshThresholdto aid debugging.Testing
p2p/p2p_stats.goand committed.Codex Task