Skip to content

feat: add filecache prometheus metrics #18089

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

Merged
merged 8 commits into from
May 30, 2025
Merged

Conversation

Emyrk
Copy link
Member

@Emyrk Emyrk commented May 28, 2025

Dynamic parameters has an in memory file cache. This adds prometheus metrics to monitor said cache.

Closes coder/internal#554

@Emyrk Emyrk requested a review from aslilac May 28, 2025 20:57
Comment on lines +201 to +204
ev, err := entry.value.Load()
if err == nil {
c.currentCacheSize.Add(-1 * float64(ev.size))
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This feels really unfortunate, but it is all cached so it's not an expensive call.

}

content := bytes.NewBuffer(file.Data)
return archivefs.FromTarReader(content), nil
return archivefs.FromTarReader(content), int64(content.Len()), nil
Copy link
Member

Choose a reason for hiding this comment

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

hmm. I really dislike trusting honest reporting of size here. is there not some way we could inspect the size of this entire object from inside the cache at runtime? there might not be but it'd be super slick

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think there is without doing some recursive Stat() call on all the files in the filesystem.

Right here is the cheapest place to do it. If we ever add a compression layer, then this won't be 100% accurate, but at present it does indicate the total number of bytes held in memory by the cache entry.

@Emyrk Emyrk requested a review from aslilac May 30, 2025 15:07
@Emyrk Emyrk merged commit 9db114d into main May 30, 2025
34 checks passed
@Emyrk Emyrk deleted the stevenmasley/file_cache_metrics branch May 30, 2025 16:54
@github-actions github-actions bot locked and limited conversation to collaborators May 30, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Prometheus metrics for the Parameters file cache
2 participants