Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(coderd/prometheusmetrics)!: filter deleted wsbuilds to reduce db load#19197

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mafredri merged 3 commits intomainfrommafredri/fix-prommetrics-db-load
Aug 11, 2025

Conversation

mafredri
Copy link
Member

@mafredrimafredri commentedAug 6, 2025
edited
Loading

This change removes theGetLatestWorkspaceBuilds query which includes
all workspaces for all time (including deleted). This allows us to also
stop usingGetProvisionerJobsByIDs for said builds as the job status
is included inGetWorkspaces called separately.

BREAKING CHANGE: Thecoderd_api_workspace_latest_build Prometheus
metric no longer includes builds belonging to deleted workspaces, as
such, this metric will show fewer statuses.

Fixescoder/internal#717

require.NoError(t,err)
forrange1+n {
insertDeleted(t,db,u,org)
}
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Review: This fails in the old implementation, but I thought it best to formalize the assumption. Considering the old implementation did not test for this, it seems like validation for the new approach.

johnstcn reacted with thumbs up emoji
@mafredrimafredri changed the titlefix(coderd/prometheusmetrics): no deleted wsbuilds to reduce db loadfix(coderd/prometheusmetrics): filter deleted wsbuilds to reduce db loadAug 6, 2025
This change removes the `GetLatestWorkspaceBuilds` query which includesall workspaces for all time (including deleted). This allows us to alsostop using `GetProvisionerJobsByIDs` for said builds as the job statusis included in `GetWorkspaces` called separately.Fixescoder/internal#717
@mafredrimafredriforce-pushed themafredri/fix-prommetrics-db-load branch from068dbd6 to7b1fc44CompareAugust 6, 2025 10:31
@spikecurtis
Copy link
Contributor

Soft deleted workspaces have been around forever, as has this metric. I wonder if@kylecarbs can reach back that far in his memory and recall whether it was a deliberate decision to incluce builds from deleted workspaces in thecoderd_api_workspace_latest_build_total metric, or just an oversight.

The description of the metric talks about "current" number of workspace builds by status, which makes me think it was just an oversight. Since we track the latest build per workspace, not just all builds, the metric isn't useful for tracking an overall rate of succeeding / failing builds. My take is that the most obvious interpretation is that it's for non-deleted workspaces and this change is fine.

mafredri reacted with thumbs up emoji

@mafredrimafredri marked this pull request as ready for reviewAugust 6, 2025 11:23
@mafredri
Copy link
MemberAuthor

That is the conclusion I also came to when I read the descriptions, which is why I went with this approach.

If need be, we can include deleted builds with a specialized query that selects the least amount of data needed. Previously we selected all data only to use a single column which is why optimizations were not possible.

Copy link
Member

@johnstcnjohnstcn left a comment

Choose a reason for hiding this comment

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

This change makes sense to me.

Copy link
Contributor

@dannykoppingdannykopping left a comment
edited
Loading

Choose a reason for hiding this comment

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

Seems reasonable 👍

Please ensure the semantics of this change are documented in the release notes for the next release.
We could clarify the definition of this metric too, which may help operators:

https://coder.com/docs/admin/integrations/prometheus#available-metrics

Currently it's quite brief: "The latest workspace builds with a status."

@mafredrimafredri changed the titlefix(coderd/prometheusmetrics): filter deleted wsbuilds to reduce db loadfix(coderd/prometheusmetrics)!: filter deleted wsbuilds to reduce db loadAug 8, 2025
@github-actionsgithub-actionsbot added the release/breakingThis label is applied to PRs to detect breaking changes as part of the release process labelAug 8, 2025
@mafredri
Copy link
MemberAuthor

I've updated the PR to be a "breaking" change as well as describe the changed behavior. I've also updated the helps for the metrics to mention that it's for non-deleted workspaces.

@mafredrimafredri merged commit1b66495 intomainAug 11, 2025
26 checks passed
@mafredrimafredri deleted the mafredri/fix-prommetrics-db-load branchAugust 11, 2025 11:48
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsAug 11, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@EmyrkEmyrkEmyrk left review comments

@dannykoppingdannykoppingdannykopping approved these changes

@johnstcnjohnstcnjohnstcn approved these changes

@spikecurtisspikecurtisAwaiting requested review from spikecurtis

Assignees

@mafredrimafredri

Labels
release/breakingThis label is applied to PRs to detect breaking changes as part of the release process
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

bug: GetLatestWorkspaceBuilds creates lots of DB load
5 participants
@mafredri@spikecurtis@dannykopping@johnstcn@Emyrk

[8]ページ先頭

©2009-2025 Movatter.jp