You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Introduce `metrics` and `prometheus` feature flags to allow users to
opt out of telemetry dependencies. Update the `Registry` and
`CacheManager` to conditionally compile metrics logic, and adjust
documentation and tests to reflect these changes.
Copy file name to clipboardExpand all lines: README.md
+8-5Lines changed: 8 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,7 +60,7 @@ The crate is fully async and designed for the Tokio multi-threaded runtime.
60
60
#[tokio::main]
61
61
asyncfnmain() ->anyhow::Result<()> {
62
62
tracing_subscriber::fmt::init();
63
-
// Optional Prometheus exporter (metrics are always sent via the `metrics` facade).
63
+
// Optional Prometheus exporter (requires the `prometheus` feature).
64
64
jwks_cache::install_default_exporter()?;
65
65
66
66
letregistry=jwks_cache::Registry::builder()
@@ -144,7 +144,7 @@ The optional third argument to `Registry::resolve` lets you pass the `kid` up fr
144
144
-`register` / `unregister` keep provider state scoped to each tenant.
145
145
-`resolve` serves cached JWKS payloads with per-tenant metrics tagging.
146
146
-`refresh` triggers an immediate background refresh without waiting for TTL expiry.
147
-
-`provider_status` and `all_statuses` expose lifecycle state, expiry, error counters, hit rates, and the metrics that power `jwks-cache.openapi.yaml`.
147
+
-`provider_status` and `all_statuses` expose lifecycle state, expiry, and error counters, plus hit rates and status metrics when the `metrics` feature is enabled.
148
148
149
149
### Security controls
150
150
@@ -154,12 +154,15 @@ The optional third argument to `Registry::resolve` lets you pass the `kid` up fr
154
154
155
155
### Feature flags
156
156
157
-
-`redis`: enable Redis-backed snapshots for `persist_all` and `restore_from_persistence`. When disabled, these methods are cheap no-ops so lifecycle code can stay shared.
157
+
- The `redis` feature enables Redis-backed snapshots for `persist_all` and `restore_from_persistence`. When disabled, these methods are cheap no-ops so lifecycle code can stay shared.
158
+
- The `metrics` feature enables metrics emission through the `metrics` facade.
159
+
- The `prometheus` feature enables `install_default_exporter` to install the bundled Prometheus recorder (implies `metrics`).
160
+
- The default features include `prometheus` and `metrics`; disable them with `default-features = false`.
158
161
159
162
## Observability
160
163
161
-
- Metrics emitted via the `metrics` facade include `jwks_cache_requests_total`, `jwks_cache_hits_total`, `jwks_cache_misses_total`, `jwks_cache_stale_total`, `jwks_cache_refresh_total`, `jwks_cache_refresh_errors_total`, and the `jwks_cache_refresh_duration_seconds` histogram.
162
-
-`install_default_exporter` installs the bundled Prometheus recorder (`metrics-exporter-prometheus`) and exposes a `PrometheusHandle` for HTTP servers to serve `/metrics`.
164
+
- Metrics emitted via the `metrics` facade (requires the `metrics` feature) include `jwks_cache_requests_total`, `jwks_cache_hits_total`, `jwks_cache_misses_total`, `jwks_cache_stale_total`, `jwks_cache_refresh_total`, `jwks_cache_refresh_errors_total`, and the `jwks_cache_refresh_duration_seconds` histogram.
165
+
-The `install_default_exporter`function installs the bundled Prometheus recorder (`metrics-exporter-prometheus`) and exposes a `PrometheusHandle` for HTTP servers to serve `/metrics` (requires the `prometheus` feature).
163
166
- Every cache operation is instrumented with `tracing` spans keyed by tenant and provider identifiers, making it easy to correlate logs, traces, and metrics.
0 commit comments