|
2 | 2 |
|
3 | 3 | ## Features |
4 | 4 |
|
5 | | -### Database Metrics Wiring (Step 1) |
| 5 | +### Database Metrics Wiring — `kms.database.operations.total`, `kms.database.operation.duration` (Step 1) |
6 | 6 |
|
7 | 7 | - Wire `kms.database.operations.total` (counter) and `kms.database.operation.duration` |
8 | 8 | (histogram) at the `Database` facade layer with `operation`, `backend`, and `outcome` |
|
15 | 15 | - `MainDbKind::as_str()` provides canonical backend labels |
16 | 16 | (`"sqlite"`, `"postgresql"`, `"mysql"`, `"redis"`). |
17 | 17 |
|
18 | | -### HTTP Metrics Wiring (Step 2) |
| 18 | +### HTTP Metrics Wiring — `kms.http.requests.total`, `kms.http.request.duration`, `kms.active.connections` (Step 2) |
19 | 19 |
|
20 | 20 | - Add `OtelHttpMetrics` Actix-web middleware (`crate/server/src/middlewares/otel_http_middleware.rs`) |
21 | 21 | that records `kms.http.requests.total` (counter with `method`, `path`, `status` |
|
54 | 54 | - Add `Database::count_all_non_destroyed_objects()` facade that sums counts across all |
55 | 55 | registered stores with `saturating_add`, tolerating partial failures. |
56 | 56 |
|
57 | | -### Object Count Metric — Redis-findex backend (Step 3, continued) |
| 57 | +### Object Count Metric — `kms.objects.total`, Redis-findex backend (Step 3, continued) |
58 | 58 |
|
59 | 59 | - Implement `count_all_non_destroyed` for the `RedisWithFindex` backend using an |
60 | 60 | O(1) counter key (`kms::metrics::live_object_count`) instead of a full key scan. |
@@ -122,6 +122,36 @@ state is not `Destroyed` or `Destroyed_Compromised`. |
122 | 122 | Runs without any hardware. Added `tokio` as a dev-dependency to |
123 | 123 | `cosmian_kms_interfaces`. |
124 | 124 |
|
| 125 | + |
| 126 | +### Cache and HSM Operation Metrics — `kms.cache.operations.total`, `kms.hsm.operations.total` (Step 4) |
| 127 | + |
| 128 | + |
| 129 | +- Add `hsm_model_from_prefix(hsm_instances, prefix) -> &str` to |
| 130 | + `crate/server/src/core/uid_utils.rs`. Looks up the human-readable HSM model |
| 131 | + label (e.g. `"softhsm2"`, `"utimaco"`) from the configured `hsm_instances` |
| 132 | + slice and falls back to the prefix string itself when no matching instance is |
| 133 | + found, ensuring the metric label is always non-empty. |
| 134 | +- Export `HsmInstanceParams` from `crate/server/src/config/mod.rs` (re-exported |
| 135 | + through `params/mod.rs`) so that `uid_utils` and future callers can reference |
| 136 | + it without reaching into private sub-modules. |
| 137 | +- Wire `kms.cache.operations.total` in `get_unwrapped()` |
| 138 | + (`crate/server/src/core/kms/other_kms_methods.rs`): emit `record_cache_operation("get", "hit")` |
| 139 | + on a cache hit, `record_cache_operation("get", "miss")` on a miss, and |
| 140 | + `record_cache_operation("insert", "ok")` after a successful cache population. |
| 141 | +- Wire `kms.hsm.operations.total` at three dispatch points: |
| 142 | + - `perform_crypto_operation()` in `key_ops/crypto_op.rs` — covers all six |
| 143 | + oracle-routed operations (Encrypt, Decrypt, Sign, SignatureVerify, MAC, |
| 144 | + MACVerify) via the `ResolvedKey::Oracle` arm. Uses `Op::OP_NAME` as the |
| 145 | + operation label and `hsm_model_from_prefix` for the model label. |
| 146 | + - `wrap_using_crypto_oracle()` in `core/wrapping/wrap.rs` — emits |
| 147 | + `record_hsm_operation("Wrap", model)` after the oracle `encrypt` call. |
| 148 | + - `unwrap_using_crypto_oracle()` in `core/wrapping/unwrap.rs` — emits |
| 149 | + `record_hsm_operation("Unwrap", model)` after the oracle `decrypt` call. |
| 150 | +- Add 4 unit tests in `core::uid_utils::tests` covering legacy `"hsm"` prefix, |
| 151 | + new `"hsm::softhsm2"` format, multi-instance selection, and unknown-prefix |
| 152 | + fallback. All tests are sync, require no async runtime, and pass without |
| 153 | + hardware. |
| 154 | + |
125 | 155 | ## Testing |
126 | 156 |
|
127 | 157 | ### Mockall test infrastructure |
|
0 commit comments