Harvest the latest metrics when /metrics is requested

Now that we track active projects, if nothing happens to the store
during the activity timeout we would still serve some old metrics
that may not account for the staleness of a project.

This commit changes it so that we grab a mutable reference to the store
before serving the metrics, which has the side effect of updating
all the metrics.
This commit is contained in:
Antonio Scandurra 2022-06-15 10:54:51 +02:00
parent e373e05d27
commit a85f9e74b1
2 changed files with 6 additions and 4 deletions

View file

@ -348,7 +348,6 @@ impl Store {
.get_mut(&project_id)
.ok_or_else(|| anyhow!("no such project"))?;
if project.host_connection_id == connection_id {
project.last_activity = Some(Instant::now());
let mut old_worktrees = mem::take(&mut project.worktrees);
for worktree in worktrees {
if let Some(old_worktree) = old_worktrees.remove(&worktree.id) {