Merge branch 'stable-3.1'

* stable-3.1:
  Move addition of refs/users/self symlink out of filtering logic
  Separate account tests that assert push behavior into own class
  Update recommended version of buildifier to 2.0.0
  Proc metrics: add average system load for the last minute
  Proc metrics: add available number of cores
  Add more metrics about Java threads

Change-Id: I2403648c358bf21f5ed3ffbb3429d8b483641e81
This commit is contained in:
David Pursehouse 2020-03-09 17:30:16 +09:00
commit 00ac073816
3 changed files with 46 additions and 1 deletions

View File

@ -116,7 +116,7 @@ To format Java source code, Gerrit uses the
link:https://github.com/google/google-java-format[`google-java-format`,role=external,window=_blank]
tool (version 1.7), and to format Bazel BUILD, WORKSPACE and .bzl files the
link:https://github.com/bazelbuild/buildtools/tree/master/buildifier[`buildifier`,role=external,window=_blank]
tool (version 1.0.0). Unused dependencies are found and removed using the
tool (version 2.0.0). Unused dependencies are found and removed using the
link:https://github.com/bazelbuild/buildtools/tree/master/unused_deps[`unused_deps`,role=external,window=_blank]
build tool, a sibling of `buildifier`.

View File

@ -37,7 +37,9 @@ split up by update type (create+replace, autoclose, normal)
* `proc/birth_timestamp`: Time at which the Gerrit process started.
* `proc/uptime`: Uptime of the Gerrit process.
* `proc/cpu/num_cores`: Number of processors available to the Java virtual machine.
* `proc/cpu/usage`: CPU time used by the Gerrit process.
* `proc/cpu/system_load`: System load average for the last minute.
* `proc/num_open_fds`: Number of open file descriptors.
* `proc/jvm/memory/heap_committed`: Amount of memory guaranteed for user objects.
* `proc/jvm/memory/heap_used`: Amount of memory holding user objects.
@ -49,6 +51,9 @@ objects needing finalization.
* `proc/jvm/gc/count`: Number of GCs.
* `proc/jvm/gc/time`: Approximate accumulated GC elapsed time.
* `proc/jvm/thread/num_live`: Current live thread count.
* `proc/jvm/thread/num_daemon_live`: Current live daemon threads count.
* `proc/jvm/thread/num_peak_live`: Peak live thread count since the Java virtual machine started or peak was reset.
* `proc/jvm/thread/num_total_started`: Total number of threads created and also started since the Java virtual machine started.
=== Caches

View File

@ -28,6 +28,7 @@ import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryUsage;
import java.lang.management.OperatingSystemMXBean;
import java.lang.management.ThreadMXBean;
import java.util.concurrent.TimeUnit;
@ -37,6 +38,7 @@ public class ProcMetricModule extends MetricModule {
buildLabel(metrics);
procUptime(metrics);
procCpuUsage(metrics);
procCpuLoad(metrics);
procJvmGc(metrics);
procJvmMemory(metrics);
procJvmThread(metrics);
@ -84,6 +86,23 @@ public class ProcMetricModule extends MetricModule {
new Description("Number of open file descriptors").setGauge().setUnit("fds"),
provider::getOpenFileDescriptorCount);
}
metrics.newCallbackMetric(
"proc/cpu/num_cores",
Integer.class,
new Description("Number of processors available to the Java virtual machine").setGauge(),
Runtime.getRuntime()::availableProcessors);
}
private void procCpuLoad(MetricMaker metrics) {
OperatingSystemMXBean provider =
ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class);
if (provider.getSystemLoadAverage() != -1) {
metrics.newCallbackMetric(
"proc/cpu/system_load",
Double.class,
new Description("System load average for the last minute").setGauge(),
provider::getSystemLoadAverage);
}
}
private void procJvmMemory(MetricMaker metrics) {
@ -194,5 +213,26 @@ public class ProcMetricModule extends MetricModule {
Integer.class,
new Description("Current live thread count").setGauge().setUnit("threads"),
thread::getThreadCount);
metrics.newCallbackMetric(
"proc/jvm/thread/num_daemon_live",
Integer.class,
new Description("Current live daemon threads count").setGauge().setUnit("threads"),
thread::getDaemonThreadCount);
metrics.newCallbackMetric(
"proc/jvm/thread/num_peak_live",
Integer.class,
new Description(
"Peak live thread count since the Java virtual machine started or peak was reset")
.setGauge()
.setUnit("threads"),
thread::getPeakThreadCount);
metrics.newCallbackMetric(
"proc/jvm/thread/num_total_started",
Long.class,
new Description(
"Total number of threads created and also started since the Java virtual machine started")
.setGauge()
.setUnit("threads"),
thread::getTotalStartedThreadCount);
}
}