Repository navigation
feat(cli): the public gateway serves its metrics on a loopback listener - #2611
Merged
Merged
Conversation
thiras
added a commit
that referenced
this pull request
Oct 24, 2026
Co-Authored-By: Claude Fable 5.1 <[email protected]>
thiras
force-pushed
the
feat/gateway-range
branch
2 times, most recently
from
October 24, 2026 18:11
83d17a1 to
0332fe4
Compare
`--metrics-listen <addr>` serves Prometheus text at `GET /metrics` on a loopback address: content bytes served, answers by outcome (ok, not found, refused, allowance exhausted, pool cannot pay, upstream failed) as one unlabeled sibling counter each, and pulls in flight as a gauge. Every series exports from the start. The exposition is for the operator's scraper; the listener takes a loopback address only, and nothing is served without the flag. `adr/appendix-gateway.md` is the gateway's appendix: the hosts it serves, the allowance, ranges, and the metric names; the observability appendix points to it. Part of #2593. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
thiras
force-pushed
the
feat/gateway-metrics
branch
from
October 24, 2026 18:13
2028cd5 to
6580cda
Compare
thiras
marked this pull request as ready for review
October 24, 2026 18:13
1 task done
thiras
added a commit
that referenced
this pull request
Oct 24, 2026
…2613) The metrics entry and the `Range` entry (#2612) stand once each. Co-authored-by: Claude Fable 5.1 <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Served-byte and active-pull accounting misreport activity, and the changelog contains unresolved merge-conflict markers.
3 open issues
What changed in this PR
Adds an operator-only Prometheus endpoint to the public HTTP gateway, separate from its public content listener.
Changes:
- Adds
--metrics-listen, requiring public mode and a loopback address. - Instruments request outcomes, served bytes, pull failures, and active pulls, with unit and end-to-end coverage.
- Documents gateway behavior, metric names, and container usage.
| File | Description |
|---|---|
docker/README.decdn.md |
Adds metrics configuration to the container example. |
crates/e2e/tests/gateway_public.rs |
Scrapes the live gateway and checks metrics. |
crates/common/src/cli/gateway/tests.rs |
Tests metrics flag parsing and public-mode requirement. |
crates/common/src/cli/gateway.rs |
Defines --metrics-listen. |
crates/cli/src/commands/gateway/tests.rs |
Tests outcome counters and the metrics endpoint. |
crates/cli/src/commands/gateway/metrics/tests.rs |
Tests initial exposition and counter updates. |
crates/cli/src/commands/gateway/metrics.rs |
Implements eight Prometheus series. |
crates/cli/src/commands/gateway.rs |
Wires the loopback listener and activity accounting. |
CHANGELOG.md |
Adds the metrics release note. |
adr/Makefile |
Includes the gateway appendix in the ADR book. |
adr/architecture.md |
Links the gateway appendix. |
adr/appendix-observability.md |
Points to the gateway metric definitions. |
adr/appendix-gateway.md |
Documents gateway behavior and metrics. |
Review effort: Balanced
Comment on lines
+1936
to
+1938
| if let Some(public) = &gateway.public { | ||
| public.metrics.bytes(chunk.len()); | ||
| } |
Comment on lines
+2015
to
+2016
| if let Some(public) = &self.gateway.public { | ||
| public.metrics.pull_ended(); |
Comment on lines
+4092
to
+4104
| <<<<<<< HEAD | ||
| - **CLI: the gateway answers `Range` on a sized bundle entry (#2612).** An | ||
| ======= | ||
| - **CLI: the public gateway serves its metrics on a loopback listener | ||
| (#2611).** `decdn gateway --public-url … --metrics-listen <addr>` serves | ||
| Prometheus text at `GET /metrics`: content bytes served, answers by outcome | ||
| (ok, not found, refused, allowance exhausted, pool cannot pay, upstream | ||
| failed) as one unlabeled sibling counter each, and pulls in flight as a | ||
| gauge. The listener takes a loopback address only. The series are listed in | ||
| `adr/appendix-gateway.md`, the gateway's new appendix. Part of #2593. | ||
|
|
||
| - **CLI: the gateway answers `Range` on a sized bundle entry (#2610).** An | ||
| >>>>>>> 2028cd53 (docs(changelog): note the gateway's metrics listener (#2611)) |
Open
7 of 11 tasks
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.


What
The public gateway exposes metrics (#2593, PR 4 of the plan):
--metrics-listen <loopback addr>serves Prometheus text atGET /metricson a second listener, for the operator's scraper only.gateway/metrics.rs: hand-rolled text exposition, assponsord's is (a registry crate would add its own shape for eight series). One unlabeled sibling counter per outcome, per appendix-observability § Reason splits; every series exports from the start at zero.decdn_gateway_bytes_served_total,decdn_gateway_requests_{ok,not_found,refused,allowance_exhausted}_total,decdn_gateway_pull_failures_{funding,other}_total,decdn_gateway_pulls_active(gauge). Counted at the final status inhandle, per frame innext_frame, and by the pull guard for pulls in flight.adr/appendix-gateway.mdis new: the gateway's hosts, allowance, ranges and metric names, in STE. Registered in the ADR book list and the architecture appendix list; the observability appendix points to it outside its registry tables (the node'sadr_registry_names_are_exportedtest still passes).Stacked on #2610 (
feat/gateway-range); the diff shown is against that branch. Part of #2593; the pointer PR follows.Reviewer notes
metrics.rsis the whole module; the wiring ingateway.rsishandle(now a counting wrapper aroundanswer), one line innext_frame,PullGuard::new/Drop, andserve_metrics. The flag requires--public-urland refuses a non-loopback address at startup.Verification
Always:
pre-commit runon commit (all hooks passed;cargo denyfindings are the known warn-only advisories)CARGO_BUILD_WARNINGS=deny cargo clippy -p decdn-cli -p decdn-common -p decdn-e2e --all-targets --all-features: cleancargo nextest run -p decdn-cli -p decdn-common -p decdn-e2e: 1520 passedOnly if touched:
adr/:make -C adr check-refs check-book-listpasses,adr/architecture.mdappendix list updatedadr/appendix-gateway.md § Metrics; no dashboard indecdn/devopsyet (the gateway has no deployment there; a follow-up once it does)cargo nextest run -p decdn-e2e --features anvil-e2e -E 'binary(gateway_public)'passes, now scraping the live listener (bytes served, one 402, refusals, zero pulls in flight)CHANGELOG.mdentry added by hand🤖 Generated with Claude Code