Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Cancellations during bundle preparation are misclassified as rejections, and uploads dropped while receiving are omitted from outcome counters.
2 open issues
What changed in this PR
Adds deployment observability to hosted servers through the existing Metrics API, while keeping imcp2-deploy independent of Prometheus.
Changes:
- Tracks deploy outcomes, refusals, durations, upload outcomes, and resource usage.
- Automatically registers collectors and refreshes gauges through existing metrics integration.
- Adds router-level metrics coverage and documents the new series.
| File | Description |
|---|---|
src/metrics/deploy.rs |
Defines deploy and upload Prometheus collectors. |
src/metrics.rs |
Registers deploy collectors and refreshes their gauges. |
src/deploy.rs |
Connects shared state and upload handling to metrics; adds integration coverage. |
README.md |
Documents metrics and embedder integration. |
crates/imcp2-deploy/src/uploads.rs |
Exposes upload-store usage snapshots. |
crates/imcp2-deploy/src/observe.rs |
Defines observer callbacks and fixed outcome values. |
crates/imcp2-deploy/src/lib.rs |
Reports deploy outcomes and exposes slot usage. |
Review effort: Max
raymondk
force-pushed
the
deploy-5c-embedders
branch
from
November 19, 2026 01:11
580ca47 to
d5ab142
Compare
raymondk
force-pushed
the
deploy-5d-metrics
branch
from
November 19, 2026 01:14
870fa3c to
91f5e1c
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Deployment metrics can overcount active work during draining, misleadingly label server-side setup failures, and omit interruption counts and durations when deployment tasks are cancelled.
3 open issues
2 resolved since last review
Review effort: Max
raymondk
force-pushed
the
deploy-5c-embedders
branch
from
November 19, 2026 02:02
d5ab142 to
536e120
Compare
…as refused, and how full the server is A deploy is one `tools/call` inside a `POST`, answered 200 whether it succeeded, failed or was refused for want of a slot, so the request metrics say nothing about deploys; and the upload route's status codes fold several reasons into one. - imcp2-deploy tells an observer (`DeployObserver`) how each deploy call went: refused (busy, session_busy, stopping), or how it ended (succeeded, failed, rejected, interrupted) and how long it held its slot. It gains no metrics dependency; `DeploySlots` and `Uploads` say what they hold. - imcp2 publishes them through the `Metrics` handle an embedder already builds over its servers: `imcp2_deploys_total`, `imcp2_deploy_refusals_total`, `imcp2_deploy_duration_seconds`, `imcp2_deploy_uploads_total`, `imcp2_deploy_upload_bytes`, and the gauges `imcp2_deploys_running`, `imcp2_deploy_slots`, `imcp2_deploy_upload_store_bytes` (and its capacity), `imcp2_deploy_uploads_held`, `imcp2_deploy_uploads_arriving`, which `Metrics::refresh` republishes. Every series starts at zero. - Every label value is a variant named in code; nothing a client sends becomes a label. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV
…and an abandoned upload is counted - A deploy stopped while its bundle was still being read and checked is refused with a `RequestError` like a bad bundle is, and was counted as `rejected`. The refusal now says it was a stop (`RequestError::was_interrupted`), and is counted as `interrupted`. - An upload whose request is dropped mid-body never returns from the receive, so it reached no counter. A guard counts it as `body_error` unless the receive answers. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV
…oy dropped mid-run is counted, and the server's own failures are not `rejected` - Deploys holding a slot are counted on their own, not read off the free permits: the wait for them to end held the free permits while it waited, so a draining server read as full. The wait now listens for a deploy ending and holds nothing. - What became of a deploy that holds a slot is told by a guard, so a call whose future is dropped mid-run is counted, as interrupted, instead of vanishing from the count and the duration histogram. - A deploy the server could not prepare (its directory not made, a step of its own failing) is `setup_failed`, not `rejected`, and its answer says to try again later. `rejected` is documented as what it is, an identity that could not be derived included. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV
raymondk
force-pushed
the
deploy-5d-metrics
branch
from
November 19, 2026 02:05
91f5e1c to
b2ebcb7
Compare
| }) | ||
| .await | ||
| .map_err(|e| RequestError(format!("bundle extraction panicked: {e}")))?; | ||
| .map_err(|e| RequestError::server_fault(format!("bundle extraction panicked: {e}")))?; |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Stacked on #250. Second of four follow-ups preparing the hosted deploy tools for the gateway.
Why
The request metrics cannot see deploys. A deploy is one
tools/callinside aPOSTto the MCP endpoint, answered200whether it succeeded, failed, or was refused because every slot was taken. The upload route is visible by status code, but one code covers several reasons. There is no way today to tell whether the concurrency cap is set right or how much the upload store holds.What changes
imcp2-deployreports how each deploy call went through a small observer trait (DeployObserver), and takes no metrics dependency.imcp2implements it with Prometheus collectors, registered by the sameMetrics::newan embedder already calls and refreshed by the sameMetrics::refresh. An embedder needs no new code.imcp2_deploys_running,imcp2_deploy_slotsimcp2_deploy_refusals_total{reason}busy,session_busy,stopping. A sustainedbusyrate means the cap is too lowimcp2_deploys_total{outcome}succeeded,failed,rejected,interruptedimcp2_deploy_duration_secondsimcp2_deploy_uploads_total{outcome}accepted,bad_ticket,too_large,store_full,session_busy,body_error,storage_errorimcp2_deploy_upload_bytesimcp2_deploy_upload_store_bytes,..._capacity_bytesimcp2_deploy_uploads_held,imcp2_deploy_uploads_arrivingEvery label value is a variant named in code; nothing a client sends becomes a label. All series start at zero. They are process totals with no instance label, since the endpoints of a process share one set of slots and one store.
Notes for review
deploy_in_slot, which returns the answer together with what to tell the observer, so each exit reports exactly once. Its behaviour is unchanged.Metricsbuilt over it; a second handle over the same state gets gauges but no counter events.Testing
deploys_and_uploads_are_counteddrives uploads and deploy calls through the router and checks each series, including zero-fill and the gauges after a refresh.deploy-feature tests pass; clippy is clean with and without the feature.succeeded,failedandinterruptedoutcomes andsession_busy, which need a deploy that runs against a network. They share the code path of the testedrejectedoutcome.🤖 Generated with Claude Code
https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV