Commit 0bf1d54
authored
feat: Add counter metrics for consumed cycles (#9922)
Add counter versions of metrics for consumed cycles that are stored in
`ReplicatedState`. The existing ones behave like gauges (so their values
can go down when prepayments are made and up when refunds are issued)
which makes it more challenging for consumers to build automated
monitoring tools to perform aggregations over them. By having them
monotonically increase, it's easier to calculate rates of change, show
aggregates over time etc.
The key idea is to introduce a second map of `<CyclesUseCase,
NominalCycles>` in the `ReplicatedState` that will only be updated once
per use case: either at the payment stage if we know the precise amount
or only at refund stage if a prepayment is made with an expected refund
later. The second map is quite similar to the existing in all other
aspects (how they are stored in checkpoints or how they are exposed as
prometheus metrics) besides how the values are updated.
A new map is introduced to ease the transition as migrating from the old
map to new is non-trivial given that a proper cutoff point needs to be
introduced to handle outstanding callbacks that might have been created
before the metric introduction. This is left for a follow-up if and when
people decide to do it. The new map will be used in a follow up that
will implement the [new management canister
endpoint](dfinity/portal#6217) to retrieve
canister level metrics.
Additionally, the new metrics include the use case `HttpsOutcalls` in
the canister level metrics as it's useful to determine how much each
canister uses this feature. I've opted to not change existing metrics to
do the same as it would make things less clean imo than the current
approach -- a single specific API is used to perform this update in
exactly one place where it's needed.
The changes in the PR are mostly driven by the addition of the new map
of metrics, updates in protobuf files to store the new metrics, the
changes to support having the `HttpsOutcalls` use case additionally
included as well as some changes in tests to support the new metrics.1 parent 2f5d582 commit 0bf1d54
18 files changed
Lines changed: 479 additions & 102 deletions
File tree
- rs
- execution_environment/src
- execution_environment
- execution/response
- scheduler/tests
- monitoring/metrics/src
- protobuf
- def/state
- canister_state_bits/v1
- metadata/v1
- src/gen/state
- replicated_state/src
- canister_state
- metadata_state
- state_layout/src
- state_layout
- state_manager/src
Lines changed: 39 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
101 | 106 | | |
102 | | - | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
103 | 113 | | |
104 | 114 | | |
105 | 115 | | |
106 | 116 | | |
107 | 117 | | |
108 | 118 | | |
109 | 119 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
118 | 123 | | |
119 | | - | |
| 124 | + | |
120 | 125 | | |
121 | 126 | | |
122 | 127 | | |
| |||
125 | 130 | | |
126 | 131 | | |
127 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
128 | 140 | | |
129 | | - | |
| 141 | + | |
| 142 | + | |
130 | 143 | | |
131 | 144 | | |
132 | 145 | | |
| |||
137 | 150 | | |
138 | 151 | | |
139 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
140 | 160 | | |
141 | 161 | | |
142 | 162 | | |
| |||
146 | 166 | | |
147 | 167 | | |
148 | 168 | | |
149 | | - | |
| 169 | + | |
150 | 170 | | |
151 | 171 | | |
152 | 172 | | |
| |||
177 | 197 | | |
178 | 198 | | |
179 | 199 | | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
180 | 207 | | |
181 | 208 | | |
182 | 209 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2178 | 2178 | | |
2179 | 2179 | | |
2180 | 2180 | | |
2181 | | - | |
2182 | | - | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
2183 | 2186 | | |
2184 | 2187 | | |
2185 | 2188 | | |
| |||
0 commit comments