mirror of
https://github.com/farcasterxyz/hub-monorepo.git
synced 2026-04-18 03:00:22 -04:00
feat: add a gossip message delay stat (#1615)
This commit is contained in:
5
.changeset/grumpy-kings-thank.md
Normal file
5
.changeset/grumpy-kings-thank.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@farcaster/hubble": patch
|
||||
---
|
||||
|
||||
feat: add a gossip message delay stat
|
||||
@@ -81,6 +81,7 @@ import { SingleBar } from "cli-progress";
|
||||
import { exportToProtobuf } from "@libp2p/peer-id-factory";
|
||||
import OnChainEventStore from "./storage/stores/onChainEventStore.js";
|
||||
import { ensureMessageData } from "./storage/db/message.js";
|
||||
import { getFarcasterTime } from "@farcaster/core";
|
||||
|
||||
export type HubSubmitSource = "gossip" | "rpc" | "eth-provider" | "l2-provider" | "sync" | "fname-registry";
|
||||
|
||||
@@ -1024,6 +1025,13 @@ export class Hub implements HubInterface {
|
||||
const result = await this.submitMessage(message, "gossip");
|
||||
if (result.isOk()) {
|
||||
this.gossipNode.reportValid(msgId, peerIdFromString(source.toString()).toBytes(), true);
|
||||
const currentTime = getFarcasterTime().unwrapOr(0);
|
||||
const messageCreatedTime = message.data?.timestamp ?? 0;
|
||||
// The message time is user provided, so, while not ideal, it's still good enough to use most of the time
|
||||
if (currentTime > 0 && messageCreatedTime > 0 && currentTime > messageCreatedTime) {
|
||||
const diff = currentTime - messageCreatedTime;
|
||||
statsd().timing("gossip.message_delay", diff);
|
||||
}
|
||||
} else {
|
||||
log.info(
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user