/** * {@inheritDoc} */ @NonNull @Override public MetricSet getMetricSet() { Jenkins jenkins = Jenkins.getInstance(); if (jenkins == null) { throw new AssertionError("Jenkins is missing"); } HealthChecker c = jenkins.getExtensionList(PeriodicWork.class).get(HealthChecker.class); if (c == null) { throw new AssertionError("HealthChecker is missing"); } return metrics( metric(name("jenkins", "health-check", "duration"), c.getHealthCheckDuration()), metric(name("jenkins", "health-check", "count"), c.getHealthCheckCount()), metric(name("jenkins", "health-check", "score"), c.getHealthCheckScore()), metric(name("jenkins", "health-check", "inverse-score"), new DerivativeGauge<Double, Double>(c.getHealthCheckScore()) { @Override protected Double transform(Double value) { return value == null ? null : 1.0 - value; } }) ); }