Trace MCP runtime refresh coordination (#39667)

## What changed

Add named tracing spans for MCP dirty-state refreshes and time spent waiting
to acquire the refresh semaphore.

GitOrigin-RevId: 1dbb3572d2061581beb83b3de098d6ec91791104
This commit is contained in:
Ben Romano
2026-08-20 06:34:50 +00:00
committed by copyberry
parent 2584e88cad
commit 312b62ac95
2 changed files with 2 additions and 0 deletions

View File

@@ -154,6 +154,7 @@ impl Session {
}
/// Publishes changed MCP state, waiting for any refresh already in progress.
#[tracing::instrument(name = "mcp.runtime.refresh_if_dirty", skip_all)]
pub(crate) async fn refresh_mcp_if_dirty(self: &Arc<Self>) {
let Ok(_refresh) = self.mcp_refresh.acquire().await else {
error!("MCP runtime refresh semaphore closed");

View File

@@ -30,6 +30,7 @@ impl McpRefresh {
self.pending.swap(false, Ordering::AcqRel)
}
#[tracing::instrument(name = "mcp.runtime.refresh_wait", skip_all)]
pub(super) async fn acquire(&self) -> Result<SemaphorePermit<'_>, AcquireError> {
self.gate.acquire().await
}