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

[DPLT-1044] Write latest near.org post block height to Grafana #112

Merged

Conversation

morgsmccauley
Copy link
Collaborator

@morgsmccauley morgsmccauley commented Jun 28, 2023

This PR adds creates a scheduled (every 1min) lambda which fetches the lastest post block height from api.near.social and writes it to CloudWatch metrics, which eventually ends up in Grafana. This will allow us to calculate the delta from the QueryAPI powered feed indexer.

api.near.social is currently used by near.org to fetch all posts which populate the main feed. I'd prefer to use the social.near contract directly but it doesn't seem feasible to do so. The contract stores more than just posts, and we'd essentially need to store a replica locally to parse out the pieces of information (posts) we are concerned about - exactly what the API does.

@morgsmccauley morgsmccauley changed the title [DPLT-1044] Write latest post block height to Grafana [DPLT-1044] Write latest near.org post block height to Grafana Jun 28, 2023
@morgsmccauley morgsmccauley marked this pull request as ready for review June 28, 2023 02:44
@morgsmccauley
Copy link
Collaborator Author

Still need to deploy/test this, but my AWS perms which allowed me to do so were revoked.

@morgsmccauley morgsmccauley force-pushed the DPLT-1044-expose-lag-behind-latest-post-metric-in-grafana branch from adbf15f to 37a4a26 Compare June 28, 2023 02:57
Copy link
Contributor

@roshaans roshaans left a comment

Choose a reason for hiding this comment

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

Lgtm. Minor comment about error logging.

export const handler = async () => {
const metrics = new Metrics("QueryAPI");

const response = await fetch("https://api.near.social/index", {
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably helpful to handle the error and log messages accordingly. Unless if the request fails, it bubbles up just fine in the lambda function execution logs.

Copy link
Collaborator Author

@morgsmccauley morgsmccauley Jun 28, 2023

Choose a reason for hiding this comment

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

I've intentionally left these uncaught so that they all bubble up to the execution environment, and are therefore logged. The errors which are thrown from these calls should provide enough detail to debug :)

@morgsmccauley morgsmccauley merged commit 621c082 into main Jun 28, 2023
1 check passed
@morgsmccauley morgsmccauley deleted the DPLT-1044-expose-lag-behind-latest-post-metric-in-grafana branch June 28, 2023 21:04
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