diff --git a/prometheus-metrics-instrumentation-caffeine/src/main/java/io/prometheus/metrics/instrumentation/caffeine/CacheMetricsCollector.java b/prometheus-metrics-instrumentation-caffeine/src/main/java/io/prometheus/metrics/instrumentation/caffeine/CacheMetricsCollector.java index c195ae77c..313e2f48f 100644 --- a/prometheus-metrics-instrumentation-caffeine/src/main/java/io/prometheus/metrics/instrumentation/caffeine/CacheMetricsCollector.java +++ b/prometheus-metrics-instrumentation-caffeine/src/main/java/io/prometheus/metrics/instrumentation/caffeine/CacheMetricsCollector.java @@ -25,7 +25,8 @@ *
{@code
  * // Note that `recordStats()` is required to gather non-zero statistics
  * Cache cache = Caffeine.newBuilder().recordStats().build();
- * CacheMetricsCollector cacheMetrics = new CacheMetricsCollector().register();
+ * CacheMetricsCollector cacheMetrics = new CacheMetricsCollector();
+ * PrometheusRegistry.defaultRegistry.register(cacheMetrics);
  * cacheMetrics.addCache("mycache", cache);
  *
  * }
@@ -87,7 +88,7 @@ public void addCache(String cacheName, AsyncCache cache) { * * @param cacheName cache to be removed */ - public Cache nremoveCache(String cacheName) { + public Cache removeCache(String cacheName) { return children.remove(cacheName); } diff --git a/prometheus-metrics-instrumentation-guava/src/main/java/io/prometheus/metrics/instrumentation/guava/CacheMetricsCollector.java b/prometheus-metrics-instrumentation-guava/src/main/java/io/prometheus/metrics/instrumentation/guava/CacheMetricsCollector.java index e1da20071..2962b0bf3 100644 --- a/prometheus-metrics-instrumentation-guava/src/main/java/io/prometheus/metrics/instrumentation/guava/CacheMetricsCollector.java +++ b/prometheus-metrics-instrumentation-guava/src/main/java/io/prometheus/metrics/instrumentation/guava/CacheMetricsCollector.java @@ -23,7 +23,8 @@ *
{@code
  * // Note that `recordStats()` is required to gather non-zero statistics
  * Cache cache = CacheBuilder.newBuilder().recordStats().build();
- * CacheMetricsCollector cacheMetrics = new CacheMetricsCollector().register();
+ * CacheMetricsCollector cacheMetrics = new CacheMetricsCollector();
+ * PrometheusRegistry.defaultRegistry.register(cacheMetrics);
  * cacheMetrics.addCache("mycache", cache);
  *
  * }