Skip to content

Conversation

@grahamalama
Copy link
Contributor

@grahamalama grahamalama commented Dec 6, 2023

This PR adjusts the heartbeat so that we make fewer requests in it.

Before, this PR we'd make (n * 3) + 1 API calls, where n equals the number of configured projects:

  • "all_projects_are_visible": - 1 API call
  • "all_projects_have_permissions": n API calls (in a threadpool)
  • "all_projects_components_exist": n API calls (not in a threadpool)
  • "all_projects_issue_types_exist": n API calls (not in a threadpool)

With 22 configured prod projects, that's 67 API calls (😱).

Now, we make n + 3 API calls:

  • "all_projects_are_visible": - 1 API call
  • "all_projects_have_permissions": 1 API call
  • "all_project_custom_components_exist" (renamed): up to n API calls (in a threadpool)
    • only makes calls for actions that specify custom components
  • "all_projects_issue_types_exist": 1 API call

For a grand total of 25 6 API calls in prod.

(edit: we only make component requests for projects that specify custom components, and only 3 projects do that)

This was done by using different API endpoints (or params on those endpoints) to fetch more results at once. It's annoying that Jira doesn't provide an API endpoint to fetch components by project, but we were luckily able to make an improvement

This PR also adds a little more exception handling to functions we call in the heartbeat

@grahamalama grahamalama requested a review from a team as a code owner December 6, 2023 15:54
@grahamalama grahamalama added the enhancement New feature or request label Dec 6, 2023
@grahamalama grahamalama force-pushed the handle-exceptions-in-heartbeat branch from c60bd73 to b998a0f Compare December 6, 2023 15:56
@grahamalama grahamalama force-pushed the handle-exceptions-in-heartbeat branch from b998a0f to 9ae4a0e Compare December 6, 2023 15:57
@grahamalama grahamalama requested review from a team and removed request for a team December 6, 2023 16:26
Copy link
Contributor

@alexcottner alexcottner left a comment

Choose a reason for hiding this comment

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

Two small questions, but definitely good to approve.

@grahamalama grahamalama force-pushed the handle-exceptions-in-heartbeat branch from c7fce62 to 6b6098a Compare December 6, 2023 20:09
@grahamalama grahamalama merged commit 070b535 into main Dec 6, 2023
@grahamalama grahamalama deleted the handle-exceptions-in-heartbeat branch December 6, 2023 20:23
@sentry
Copy link

sentry bot commented Dec 6, 2023

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

Did you find this useful? React with a 👍 or 👎

@leplatrem
Copy link
Contributor

Thanks 🙏

Although, honestly, for a product that is used by so many companies in the world, 67 requests on an API should not even be considered an issue

@grahamalama grahamalama added the breaking-change Pull requests that introduce a breaking change label Dec 8, 2023
@grahamalama
Copy link
Contributor Author

Tagged this issue as a "breaking change" since we renamed a field of the heartbeat payload

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change Pull requests that introduce a breaking change enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants