Commit 0aba830
test: DEFI-2810: E2e coverage for labeled metrics and doc cleanups (#310)
## Summary
Final canister-side PR for
[DEFI-2810](https://dfinity.atlassian.net/browse/DEFI-2810). Builds on
#308 (labeled-metrics foundation + per-forex) and #309 (per-exchange +
per-stablecoin) by adding end-to-end test coverage for every labeled
series introduced across the earlier two PRs, plus small doc cleanups.
The corresponding Prometheus alert rules ship separately in
[dfinity-ops/k8s#2459](dfinity-ops/k8s#2459).
- **E2e integration test** (`xrc-tests/metrics_endpoint`) — boots the
canister against the docker mock, drives a `get_exchange_rate` request
with one exchange configured to fail, scrapes `/metrics` via the
`http_request` candid endpoint, and asserts every labeled metric family
from PRs 1 & 2 is present, including a non-success outcome on the
per-exchange counter. Includes a regression guard: each labeled metric
name emits exactly one `# HELP` line.
- **Group B `# HELP` annotations** — `xrc_stablecoin_errors`,
`xrc_crypto_asset_errors`, and `xrc_forex_asset_errors` now point
dashboard authors at the per-source replacements from PRs 1 & 2. Pure
docstring change.
- **DEFI-2828 TODO** on the new test's `#[ignore]` attribute, describing
the follow-up to replace the implicit "requires Docker mock harness"
convention with an explicit gate (reason string / feature flag).
### Note on the dropped collector-sources gauge
An earlier draft of this PR added `xrc_forex_collector_sources{slot}`
exposing per-deque-slot source counts. It was dropped during review
(commit `9c1497d`) — the collector deque is only mutated on successful
source fetches and has no wall-clock expiry, so a sustained outage
leaves the gauge reporting stale counts for arbitrarily old days while
`== 0` only fires on a cold-start empty deque. The signals operators
actually need are already on `/metrics` from #308 / #309 and covered by
the new e2e test — and operationalised as alerts in
[dfinity-ops/k8s#2459](dfinity-ops/k8s#2459):
| Scenario | Alert |
|---|---|
| All forex data is stale (errors, empty, unreachable, _or_ timer dead)
| `time() - min(xrc_forex_last_success_seconds) > 86400` |
| Timer not firing | `time() - xrc_periodic_forex_run_last_seconds >
1800` |
| Any individual source down for an extended period | `time() -
xrc_forex_last_success_seconds > 172800` |
## Test plan
- [x] `cargo test -p xrc` — 215 unit tests pass post-revert.
- [x] `./scripts/e2e-tests` — passed at the gauge-included revision
(`84aaca7`); the post-revert change to `metrics_endpoint.rs` only
removes assertions, which cannot regress a previously passing test.
## Follow-up
[DEFI-2828](https://dfinity.atlassian.net/browse/DEFI-2828) tracks
replacing the `#[ignore]` gating in `xrc-tests` with an explicit gate
(reason string / feature flag).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
[DEFI-2810]: https://dfinity.atlassian.net/browse/DEFI-2810
[DEFI-2828]: https://dfinity.atlassian.net/browse/DEFI-2828
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 502f263 commit 0aba830
3 files changed
Lines changed: 206 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
| 2 | + | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
| 103 | + | |
| 104 | + | |
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
108 | 109 | | |
109 | | - | |
| 110 | + | |
| 111 | + | |
110 | 112 | | |
111 | 113 | | |
112 | 114 | | |
113 | 115 | | |
114 | 116 | | |
115 | | - | |
| 117 | + | |
| 118 | + | |
116 | 119 | | |
117 | 120 | | |
118 | 121 | | |
| |||
0 commit comments