use of com.google.gerrit.metrics.Description in project gerrit by GerritCodeReview.
the class ProcMetricModuleTest method invalidName2.
@Test
public void invalidName2() {
exception.expect(IllegalArgumentException.class);
metrics.newCounter("invalid/ name", new Description("fail"));
}
use of com.google.gerrit.metrics.Description in project gerrit by GerritCodeReview.
the class ProcMetricModuleTest method invalidName1.
@Test
public void invalidName1() {
exception.expect(IllegalArgumentException.class);
metrics.newCounter("invalid name", new Description("fail"));
}
use of com.google.gerrit.metrics.Description in project gerrit by GerritCodeReview.
the class ProcMetricModule method procJvmThread.
private void procJvmThread(MetricMaker metrics) {
ThreadMXBean thread = ManagementFactory.getThreadMXBean();
metrics.newCallbackMetric("proc/jvm/thread/num_live", 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);
if (thread.isSynchronizerUsageSupported()) {
metrics.newCallbackMetric("proc/jvm/thread/num_deadlocked_threads", Integer.class, new Description("number of threads that are deadlocked waiting for object monitors or ownable synchronizers").setGauge().setUnit("threads"), () -> {
long[] deadlocked = thread.findDeadlockedThreads();
if (deadlocked == null) {
return 0;
}
return deadlocked.length;
});
} else {
metrics.newCallbackMetric("proc/jvm/thread/num_deadlocked_threads", Integer.class, new Description("number of threads that are deadlocked waiting to acquire object monitors").setGauge().setUnit("threads"), () -> {
long[] deadlocked = thread.findMonitorDeadlockedThreads();
if (deadlocked == null) {
return 0;
}
return deadlocked.length;
});
}
}
use of com.google.gerrit.metrics.Description in project gerrit by GerritCodeReview.
the class PerformanceLogContextTest method timerMetricsInsidePerformanceLogContextCreatePerformanceLogNullValuesAllowed.
@Test
public void timerMetricsInsidePerformanceLogContextCreatePerformanceLogNullValuesAllowed() {
assertThat(LoggingContext.getInstance().isPerformanceLogging()).isFalse();
assertThat(LoggingContext.getInstance().getPerformanceLogRecords()).isEmpty();
try (PerformanceLogContext traceContext = new PerformanceLogContext(config, performanceLoggers)) {
assertThat(LoggingContext.getInstance().isPerformanceLogging()).isTrue();
Timer1<String> timer1 = metricMaker.newTimer("test1/latency", new Description("Latency metric for testing"), Field.ofString("project", Metadata.Builder::projectName).build());
timer1.start(null).close();
Timer2<String, String> timer2 = metricMaker.newTimer("test2/latency", new Description("Latency metric for testing"), Field.ofString("project", Metadata.Builder::projectName).build(), Field.ofString("branch", Metadata.Builder::branchName).build());
timer2.start(null, null).close();
Timer3<String, String, String> timer3 = metricMaker.newTimer("test3/latency", new Description("Latency metric for testing"), Field.ofString("project", Metadata.Builder::projectName).build(), Field.ofString("branch", Metadata.Builder::branchName).build(), Field.ofString("revision", Metadata.Builder::revision).build());
timer3.start(null, null, null).close();
assertThat(LoggingContext.getInstance().getPerformanceLogRecords()).hasSize(3);
}
assertThat(testPerformanceLogger.logEntries()).containsExactly(PerformanceLogEntry.create("test1/latency", Metadata.empty()), PerformanceLogEntry.create("test2/latency", Metadata.empty()), PerformanceLogEntry.create("test3/latency", Metadata.empty())).inOrder();
assertThat(LoggingContext.getInstance().isPerformanceLogging()).isFalse();
assertThat(LoggingContext.getInstance().getPerformanceLogRecords()).isEmpty();
}
use of com.google.gerrit.metrics.Description in project gerrit by GerritCodeReview.
the class ProcMetricModuleTest method counterPrefixFields.
@Test
public void counterPrefixFields() {
Counter1<String> cntr = metrics.newCounter("test/count", new Description("simple test").setCumulative().setFieldOrdering(FieldOrdering.PREFIX_FIELDS_BASENAME), Field.ofString("action", Field.ignoreMetadata()).build());
Counter total = get("test/count_total", Counter.class);
assertThat(total.getCount()).isEqualTo(0);
cntr.increment("passed");
Counter passed = get("test/passed/count", Counter.class);
assertThat(total.getCount()).isEqualTo(1);
assertThat(passed.getCount()).isEqualTo(1);
cntr.incrementBy("failed", 5);
Counter failed = get("test/failed/count", Counter.class);
assertThat(total.getCount()).isEqualTo(6);
assertThat(passed.getCount()).isEqualTo(1);
assertThat(failed.getCount()).isEqualTo(5);
}
Aggregations