-
Notifications
You must be signed in to change notification settings - Fork 0
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: add parsing of health check event #4
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great, just a few questions
oh, and CI is red. i merged main
into this branch to get the CI checks working and it complained about a few linting things
src/index.ts
Outdated
console.info(`[HealthCheck]: Block ${parsedEvent.block}`); | ||
break; | ||
default: | ||
console.warn("Unknown event type:", parsedEvent.event); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could even throw
here instead of just warn. if it's just a warning it might drown in the other logs and we may never know about it.
throwing would alert us much earlier if somebody were to try to DDoS this function, wdyt?
src/parse-transaction-receipts.ts
Outdated
} | ||
if (isProposalCreatedEvent(event)) { | ||
result.push({ | ||
block: Number(receipt.blockNumber), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need the block number? if we have the tx hash we could look up the block number easily, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to log it on every health check event to know which block is the event coming from, which is good to know in case quicknode acts weird in any way (for example sending events multiple times, they fall behind from the tip of the chain, etc).
We don't really need it for the proposal events though so I can remove it from those
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha, i'd say let's keep it only on the healthcheck then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
Co-authored-by: chapati <philip.paetz@me.com>
This adds the parsing of a second event, MedianUpdated (from SortedOracles), which acts as a health check/heartbeat for the cloud function, as it's a frequently emitted event that can serve as an indicator of quicknode working properly.
The parsing of the event results in a single console.log of the action, which will then be used for creating a metric on Google Cloud Monitoring around how many heartcheck logs are present in a given timespan.