From 11b517e2cc3bc9c37ae6508ce4ae5d25f09946b0 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Thu, 5 Mar 2020 17:43:12 +0100 Subject: [PATCH] JGit metrics: expose total load time for block cache entries This allows to calculate current average load time within a time interval by dividing increase of total_load_time by increase of load_success_count within a given time interval. The already exposed metric avg_load_time gives the average since the gerrit process was started. Change-Id: I40eb61cc716b7d545aeae4eb522a439cc48bd74d --- Documentation/metrics.txt | 7 ++++--- .../google/gerrit/metrics/proc/JGitMetricModule.java | 11 +++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Documentation/metrics.txt b/Documentation/metrics.txt index 9fe2df9395..e6654c3de4 100644 --- a/Documentation/metrics.txt +++ b/Documentation/metrics.txt @@ -139,9 +139,10 @@ topic submissions that concluded successfully. === JGit -* `jgit/block_cache/cache_used`: Bytes of memory retained in JGit block cache. -* `jgit/block_cache/open_files`: File handles held open by JGit block cache. -* `avg_load_time` Average time to load a cache entry for JGit block cache. +* `jgit/block_cache/cache_used` : Bytes of memory retained in JGit block cache. +* `jgit/block_cache/open_files` : File handles held open by JGit block cache. +* `avg_load_time` : Average time to load a cache entry for JGit block cache. +* `total_load_time` : Total time to load cache entries for JGit block cache. * `eviction_count` : Cache evictions for JGit block cache. * `eviction_ratio` : Cache eviction ratio for JGit block cache. * `hit_count` : Cache hits for JGit block cache. diff --git a/java/com/google/gerrit/metrics/proc/JGitMetricModule.java b/java/com/google/gerrit/metrics/proc/JGitMetricModule.java index b9d86504fe..a44f907cc7 100644 --- a/java/com/google/gerrit/metrics/proc/JGitMetricModule.java +++ b/java/com/google/gerrit/metrics/proc/JGitMetricModule.java @@ -65,6 +65,17 @@ public class JGitMetricModule extends MetricModule { } }); + metrics.newCallbackMetric( + "jgit/block_cache/total_load_time", + Long.class, + new Description("Total time to load cache entries for JGit block cache.").setGauge(), + new Supplier() { + @Override + public Long get() { + return WindowCacheStats.getStats().getTotalLoadTime(); + } + }); + metrics.newCallbackMetric( "jgit/block_cache/eviction_count", Long.class,