Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(store-indexer): add metric for distance from block tag to follow #2763

Merged
merged 5 commits into from
Apr 29, 2024

Conversation

alvrs
Copy link
Member

@alvrs alvrs commented Apr 29, 2024

No description provided.

@alvrs alvrs requested review from holic and yonadaaa as code owners April 29, 2024 15:04
Copy link

changeset-bot bot commented Apr 29, 2024

🦋 Changeset detected

Latest commit: 6ad0bbe

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
@latticexyz/store-indexer Patch
@latticexyz/abi-ts Patch
@latticexyz/block-logs-stream Patch
@latticexyz/cli Patch
@latticexyz/common Patch
@latticexyz/config Patch
create-mud Patch
@latticexyz/dev-tools Patch
@latticexyz/faucet Patch
@latticexyz/gas-report Patch
@latticexyz/protocol-parser Patch
@latticexyz/query Patch
@latticexyz/react Patch
@latticexyz/recs Patch
@latticexyz/schema-type Patch
@latticexyz/services Patch
solhint-config-mud Patch
solhint-plugin-mud Patch
@latticexyz/store-sync Patch
@latticexyz/store Patch
@latticexyz/utils Patch
@latticexyz/world-modules Patch
@latticexyz/world Patch
mock-game-contracts Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -73,6 +73,12 @@ async function getLatestStoredBlockNumber(): Promise<bigint | undefined> {
return currentChainState?.lastUpdatedBlockNumber ?? undefined;
}

async function getDistanceFromFollowBlock(): Promise<bigint | undefined> {
const latestStoredBlockNumber = (await getLatestStoredBlockNumber()) ?? -1n;
const latestFollowBlockNumber = (await publicClient.getBlock({ blockTag: env.FOLLOW_BLOCK_TAG })).number;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we parallelize these to maybe have a better chance of these aligning?

@@ -73,6 +73,12 @@ async function getLatestStoredBlockNumber(): Promise<bigint | undefined> {
return currentChainState?.lastUpdatedBlockNumber ?? undefined;
}

async function getDistanceFromFollowBlock(): Promise<bigint | undefined> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like we're always returning a bigint now - do we need undefined here?

name: "distance_from_follow_block",
help: "Block distance from the block tag this the indexer is following",
async collect(): Promise<void> {
this.set(Number(await getDistanceFromFollowBlock()));
Copy link
Member

@holic holic Apr 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this.set on a gauge only support number? vs a numeric string like BigInt.toString()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think number is better here so we can do things like > for the alerts (and very unlikely the numbers ever get into a range where they don't fit into a number anymore)

Copy link
Member

@holic holic Apr 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yes, I just assumed that what "gauge" metric type is for, not the value we pass into the gauge

just wondering about the unlikely edge case/assumption where the bigint value > JS number max

@alvrs alvrs merged commit 93690fd into main Apr 29, 2024
12 checks passed
@alvrs alvrs deleted the alvrs/indexer-metrics branch April 29, 2024 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants