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: api metrics #88

Merged
merged 2 commits into from
May 20, 2022
Merged

feat: api metrics #88

merged 2 commits into from
May 20, 2022

Conversation

vasco-santos
Copy link
Contributor

@vasco-santos vasco-santos commented May 13, 2022

This PR adds metrics endpoint to the API by:

  • new table for metrics
  • cron job to compute them async
  • use cron job released

From previous knowledge doing the queries in the API itself would work in the beginning. But let's not wait for fires, and go straight for cron job

Blocked on #86

Closes #56

@vasco-santos vasco-santos marked this pull request as draft May 13, 2022 15:41
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented May 17, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 81103d0
Status: ✅  Deploy successful!
Preview URL: https://010346e1.nftstorage-link.pages.dev

View logs

@vasco-santos vasco-santos marked this pull request as ready for review May 17, 2022 12:13
@vasco-santos vasco-santos force-pushed the feat/api-metrics branch 2 times, most recently from 7572044 to af2b015 Compare May 17, 2022 12:57
Copy link

@alanshaw alanshaw left a comment

Choose a reason for hiding this comment

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

LGTM, added some non-blocking suggestions.

`nftlinkapi_permacache_size_total ${sizeTotal}`,
`# HELP nftlinkapi_permacache_events_total Total perma cache events.`,
`# TYPE nftlinkapi_permacache_events_total counter`,
`nftlinkapi_permacache_events_total ${eventsTotal}`,

Choose a reason for hiding this comment

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

Split by type?

Suggested change
`nftlinkapi_permacache_events_total ${eventsTotal}`,
`nftlinkapi_permacache_events_total{type="Put"} ${putEventsTotal}`,
`nftlinkapi_permacache_events_total{type="Delete"} ${deleteEventsTotal}`,

`# HELP nftlinkapi_permacache_events_total Total perma cache events.`,
`# TYPE nftlinkapi_permacache_events_total counter`,
`nftlinkapi_permacache_events_total ${eventsTotal}`,
].join('\n')

Choose a reason for hiding this comment

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

I used this prom-client library in checkup https://github.com/nftstorage/checkup/blob/main/prom.js - it might make things a bit less error prone here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will do this as follow up.

Comment on lines 12 to 16
const COUNT_USERS = `
SELECT COUNT(*) AS total
FROM nftstorage.user u JOIN nftstorage.user_tag ut
ON u.id = ut.user_id
WHERE ut.tag = 'HasSuperHotAccess'::user_tag_type AND ut.value = 'true'
`

Choose a reason for hiding this comment

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

Isn't this just a count of HasSuperHotAccess tags?

Suggested change
const COUNT_USERS = `
SELECT COUNT(*) AS total
FROM nftstorage.user u JOIN nftstorage.user_tag ut
ON u.id = ut.user_id
WHERE ut.tag = 'HasSuperHotAccess'::user_tag_type AND ut.value = 'true'
`
const COUNT_USERS = `
SELECT COUNT(*) AS total
FROM nftstorage.user_tag
WHERE tag = 'HasSuperHotAccess'::user_tag_type AND value = 'true'
`

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.

SuperHot HTTP API metrics
2 participants