Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Create a dashboard for background jobs#44901

Merged
vdavid merged 93 commits intomainfrom
dv/dashboard-for-workers
Jan 17, 2023
Merged

Create a dashboard for background jobs#44901
vdavid merged 93 commits intomainfrom
dv/dashboard-for-workers

Conversation

@vdavid
Copy link
Contributor

@vdavid vdavid commented Nov 29, 2022

We have 50+ goroutines running in the background in our app, and their observability is rather poor.

This PR adds an admin page that lists our known background routines and provides stats and noteworthy events around them.

It looks like this:

screenshot

2-min Loom where I demo this.

Features

  • As part of this PR, most of the routines we're running in worker (complete list here) now log their start, stop, and run events in Redis. This means 70% of all routines, or 87% if we don't consider resetters.
  • Then there is the above UI that polls a new GraphQL endpoint every 5 seconds and fetches the latest job/routine data.
  • The main use cases for admins that I expect to see from this feature:
    • Seeing what routines we have an using it as a reference (as their description is included)
    • Noticing errors early and investigating them easier
    • Noticing routines that take a long time to run, either in absolute terms or relative to their interval. (If a routine takes a similar time to run to its interval, that usually indicates danger.)
  • The UI supports pausing the 5-sec polling to make it easier to investigate transient issues
  • The UI also supports filtering for problematic routines to save on some scrolling from the admins
  • Records in Redis are retained for 7 days. Detailed logs are kept for the last 100 recent runs.

Changes in this PR that affect other parts of the code base

  • Front end: Moved formatDurationLong from client/web/src/components/ExecutionLogEntry.tsx to a new web/src/util/time.ts to reuse is functionality. Also created a unit test for it, then safely restructured it to suit my purposes.
  • Front end: In ValueLegendList, formatted large numbers nicer in the tooltip. Was like 106123, now it is 106,123.
  • Back end: Got rid of the dependency on workerutil in the internal/types package that caused a circular dependency with my code added. I think it's neater this way, it was quite a weird direction of dependencies.

Test plan

  • Test if the page is refreshed as intended
  • Test it on small screens
  • Make sure tests pass
  • Add automated tests as baseline QA
  • Test with connection off/on
  • Ask for a front-end peer review—this 5-min Loom should help do it efficiently
  • Ask for a back-end peer review—this 10-min Loom should help do it efficiently

@cla-bot cla-bot bot added the cla-signed label Nov 29, 2022
@sg-e2e-regression-test-bob
Copy link

sg-e2e-regression-test-bob commented Nov 29, 2022

Bundle size report 📦

Initial size Total size Async size Modules
0.06% (+1.76 kb) 0.17% (+23.66 kb) 🔺 0.19% (+21.90 kb) 🔺 0.14% (+1) 🔺

Look at the Statoscope report for a full comparison between the commits 0846982 and a93117a or learn more.

Open explanation
  • Initial size is the size of the initial bundle (the one that is loaded when you open the page)
  • Total size is the size of the initial bundle + all the async loaded chunks
  • Async size is the size of all the async loaded chunks
  • Modules is the number of modules in the initial bundle

@vdavid vdavid force-pushed the dv/dashboard-for-workers branch from 1de7b96 to 7bdf118 Compare December 6, 2022 12:47
@vdavid vdavid force-pushed the dv/dashboard-for-workers branch 4 times, most recently from fa0d646 to 645faff Compare December 20, 2022 14:08
@vdavid vdavid force-pushed the dv/dashboard-for-workers branch 2 times, most recently from 98edeaf to 9ee9239 Compare January 10, 2023 10:48
@vdavid vdavid changed the title Create a dashboard for workers Create a dashboard for workers and background jobs Jan 10, 2023
@vdavid vdavid requested a review from mrnugget January 10, 2023 14:49
@vdavid vdavid force-pushed the dv/dashboard-for-workers branch from 87b305a to fd70e86 Compare January 12, 2023 11:00
@vdavid vdavid force-pushed the dv/dashboard-for-workers branch from 2ba1a38 to d3395df Compare January 12, 2023 15:31
@vdavid vdavid force-pushed the dv/dashboard-for-workers branch 3 times, most recently from e0590e5 to 3b21c64 Compare January 16, 2023 13:03
@vdavid vdavid requested review from a team and efritz January 16, 2023 14:15
@vdavid vdavid marked this pull request as ready for review January 16, 2023 14:15
@sourcegraph-bot
Copy link
Contributor

sourcegraph-bot commented Jan 16, 2023

Codenotify: Notifying subscribers in CODENOTIFY files for diff a93117a...0846982.

Notify File(s)
@efritz cmd/worker/shared/main.go
internal/goroutine/periodic.go
internal/goroutine/recorder/common.go
internal/goroutine/recorder/common_test.go
internal/goroutine/recorder/reader.go
internal/goroutine/recorder/recorder.go
internal/workerutil/worker.go
@eseliger enterprise/internal/batches/scheduler/scheduler.go
@unknwon enterprise/cmd/frontend/internal/authz/resolvers/resolver_test.go

@vdavid vdavid requested a review from a team January 16, 2023 14:27
@sourcegraph sourcegraph deleted a comment from github-actions bot Jan 16, 2023
@sourcegraph sourcegraph deleted a comment from github-actions bot Jan 16, 2023
@vdavid vdavid changed the title Create a dashboard for workers and background jobs Create a dashboard for background jobs Jan 16, 2023
@sourcegraph sourcegraph deleted a comment from github-actions bot Jan 16, 2023
vdavid and others added 17 commits January 17, 2023 11:04
Co-authored-by: Kelli Rockwell <kelli@sourcegraph.com>
Co-authored-by: Kelli Rockwell <kelli@sourcegraph.com>
Co-authored-by: Kelli Rockwell <kelli@sourcegraph.com>
Co-authored-by: Kelli Rockwell <kelli@sourcegraph.com>
Co-authored-by: Kelli Rockwell <kelli@sourcegraph.com>
@vdavid vdavid force-pushed the dv/dashboard-for-workers branch from b7b26f4 to c88804b Compare January 17, 2023 10:04
@vdavid vdavid enabled auto-merge (squash) January 17, 2023 12:43
@vdavid vdavid disabled auto-merge January 17, 2023 12:44
@vdavid vdavid enabled auto-merge (squash) January 17, 2023 13:14
@vdavid vdavid merged commit bd7f2d3 into main Jan 17, 2023
@vdavid vdavid deleted the dv/dashboard-for-workers branch January 17, 2023 13:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants