Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Upload-handler cancellation can misclassify retained bundles and lose acceptance and size metrics, while post-claim refusals are omitted from slot-duration metrics and slot-holder totals.
2 open issues
What changed in this PR
Adds process-wide Prometheus metrics for deploy tools and bundle uploads, exposing outcomes and resource usage that HTTP status metrics cannot distinguish.
Changes:
- Registers zero-initialized counters, gauges, and duration/size histograms through the existing
MetricsAPI. - Connects deploy observers and upload reporting, with gauges updated by
Metrics::refresh. - Adds router-level integration coverage and documents the new series.
| File | Description |
|---|---|
src/metrics/deploy.rs |
Defines deploy and upload collectors, labels, and reporting methods. |
src/metrics.rs |
Registers deploy collectors and refreshes their gauges. |
src/deploy.rs |
Connects outcome reporting and adds metrics integration tests. |
README.md |
Documents deploy metrics and embedder integration. |
Review effort: Max
Comment on lines
+542
to
+543
| if let Some(metrics) = self.0.take().as_ref().and_then(|m| m.0.get()) { | ||
| metrics.upload(Upload::BodyError); |
Comment on lines
+255
to
+257
| fn ended(&self, how: Ended, lasted: Duration) { | ||
| self.deploys.with_label_values(&[how.as_str()]).inc(); | ||
| self.duration.observe(lasted.as_secs_f64()); |
This was referenced Nov 19, 2026
raymondk
marked this pull request as draft
November 19, 2026 03:12
raymondk
force-pushed
the
deploy-core-6-metrics
branch
from
November 19, 2026 04:06
59ff894 to
7a07457
Compare
raymondk
force-pushed
the
deploy-core-6-metrics
branch
from
November 19, 2026 15:59
7a07457 to
0873cc8
Compare
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.
The `Metrics` handle an embedder already builds over its servers also
publishes, where a server serves the deploy tools, as totals for the
process:
- `imcp2_deploys_running` against `imcp2_deploy_slots`: how full it is.
- `imcp2_deploy_refusals_total{reason}`: busy, session_busy, stopping,
no_room. A sustained rate of `busy` is a cap that is too low.
- `imcp2_deploys_total{outcome}`: succeeded, failed, rejected,
setup_failed (the server's own failure, not the request's),
interrupted; and `imcp2_deploy_duration_seconds`.
- `imcp2_deploy_uploads_total{outcome}`: accepted, bad_ticket, too_large,
extracts_too_large, not_a_bundle, plugin_not_allowed, store_full,
session_busy, body_error, storage_error.
- `imcp2_deploy_upload_bytes` and `imcp2_deploy_bundle_extracted_bytes`,
which is where the two size limits should sit is read off.
- `imcp2_deploy_upload_store_bytes` against its capacity, and the uploads
held and arriving: what the deploy tools keep under the state directory.
The counters are fed as things happen, a deploy dropped mid-run and an
upload abandoned mid-body included; the gauges by `Metrics::refresh`.
Every label value is a variant named in code: nothing a client sends
becomes a label. Every series starts at zero.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV
raymondk
force-pushed
the
deploy-core-6-metrics
branch
from
November 19, 2026 16:21
0873cc8 to
f8ae6aa
Compare
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.

Sixth of six. Stacked on the remote server PR.
Why
The request metrics cannot see deploys. A deploy is one
tools/callinside aPOST, 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.What this PR adds
Where a server serves the deploy tools, the
Metricshandle an embedder already builds also publishes these, as process totals:imcp2_deploys_running,imcp2_deploy_slotsimcp2_deploy_refusals_total{reason}busy,session_busy,stopping,no_room. A sustainedbusyrate means the cap is too lowimcp2_deploys_total{outcome}succeeded,failed,rejected,setup_failed(the server's own failure),interruptedimcp2_deploy_duration_secondsimcp2_deploy_uploads_total{outcome}accepted,bad_ticket,too_large,extracts_too_large,not_a_bundle,plugin_not_allowed,store_full,session_busy,body_error,storage_errorimcp2_deploy_upload_bytes,imcp2_deploy_bundle_extracted_bytesimcp2_deploy_upload_store_bytes,..._capacity_bytesimcp2_deploy_uploads_held,imcp2_deploy_uploads_arrivingMetrics::newand the gauges update inMetrics::refresh.Limitations
rejectedincludes a deploy refused because the session's identity could not be derived, whether the grant lapsed or Internet Identity was unreachable. The code cannot tell those apart today.Metricshandle built over it.Testing
One test drives uploads and deploy calls through the router and checks each series, including zero-fill and the gauges after a refresh. The
succeeded,failedandinterruptedoutcomes need a deploy against a network and are covered only by the classification unit test.🤖 Generated with Claude Code
https://claude.ai/code/session_01XSXgo38kH12wagL3rstXfV