net.nemerosa.ontrack.boot.metrics.SystemMetricsSource Maven / Gradle / Ivy
package net.nemerosa.ontrack.boot.metrics;
import net.nemerosa.ontrack.model.metrics.MetricsSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.endpoint.PublicMetrics;
import org.springframework.boot.actuate.metrics.Metric;
import org.springframework.stereotype.Component;
import java.util.Collection;
import java.util.stream.Stream;
/**
* Export all Spring Boot metrics which are neither counters nor gauges. This makes
* accessible the list of metrics like gc
, mem
, etc.
*/
@Component
public class SystemMetricsSource implements MetricsSource {
private final Collection publicMetrics;
@Autowired
public SystemMetricsSource(Collection publicMetrics) {
this.publicMetrics = publicMetrics;
}
@Override
public Stream> getMetrics() {
return publicMetrics.stream()
.flatMap(m -> m.metrics().stream())
.filter(m -> !m.getName().startsWith("counter"))
.filter(m -> !m.getName().startsWith("gauge"))
;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy