Skip to content

Commit 2717d44

Browse files
authored
chore: add contact info to sync health logs (#2336)
Add more data to validate whether hubs are connecting to the correct IP addresses and ports. ## Merge Checklist _Choose all relevant options below by adding an `x` now or at any time before submitting for review_ - [x] PR title adheres to the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) standard - [x] PR has a [changeset](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#35-adding-changesets) - [x] PR has been tagged with a change label(s) (i.e. documentation, feature, bugfix, or chore) - [ ] PR includes [documentation](https://github.com/farcasterxyz/hub-monorepo/blob/main/CONTRIBUTING.md#32-writing-docs) if necessary. <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on enhancing the logging of sync health jobs by adding contact information related to peers in the logs, which aids in troubleshooting. ### Detailed summary - Added `contactInfoForLogs` method in `syncHealthJob.ts` to retrieve contact information for peers. - Updated the logging in `doJobs` method to include contact info when an error occurs during sync health computation. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent fff8d7b commit 2717d44

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

.changeset/seven-cats-beg.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@farcaster/hubble": patch
3+
---
4+
5+
chore: add contact info to sync health logs

apps/hubble/src/network/sync/syncHealthJob.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,20 @@ export class MeasureSyncHealthJobScheduler {
175175
}
176176
}
177177

178+
contactInfoForLogs(peer: PeerIdentifier) {
179+
if (peer.kind === PeerIdentifierKind.PeerId) {
180+
const contactInfo = this._metadataRetriever._syncEngine.getContactInfoForPeerId(peer.identifier);
181+
182+
if (!contactInfo) {
183+
return undefined;
184+
}
185+
186+
return contactInfo;
187+
} else {
188+
return undefined;
189+
}
190+
}
191+
178192
async doJobs() {
179193
if (!this._hub.performedFirstSync) {
180194
log.info("Skipping SyncHealth job because we haven't performed our first sync yet");
@@ -204,9 +218,13 @@ export class MeasureSyncHealthJobScheduler {
204218
);
205219

206220
if (syncHealthMessageStats.isErr()) {
221+
const contactInfo = this.contactInfoForLogs(peer);
207222
log.info(
208-
{ peerId: peer.identifier, err: syncHealthMessageStats.error },
209-
`Error computing SyncHealth: ${syncHealthMessageStats.error}`,
223+
{
224+
peerId: peer.identifier,
225+
err: syncHealthMessageStats.error,
226+
},
227+
`Error computing SyncHealth: ${syncHealthMessageStats.error}. Contact info: ${contactInfo}`,
210228
);
211229
continue;
212230
}

0 commit comments

Comments
 (0)