Skip to content

Commit

Permalink
Add JVM metrics to auto-publish to prometheus registry (#354)
Browse files Browse the repository at this point in the history
* Add JVM metrics to auto-publish to prometheus registry

* formatting fix

---------

Co-authored-by: Michael Collado <[email protected]>
Co-authored-by: Eric Maynard <[email protected]>
  • Loading branch information
3 people authored Oct 8, 2024
1 parent 6c02252 commit baf2b8c
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
import io.micrometer.core.instrument.Counter;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Timer;
import io.micrometer.core.instrument.binder.jvm.ClassLoaderMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmGcMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmMemoryMetrics;
import io.micrometer.core.instrument.binder.jvm.JvmThreadMetrics;
import io.micrometer.core.instrument.binder.system.ProcessorMetrics;
import java.lang.reflect.Method;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
Expand All @@ -45,6 +50,11 @@ public class PolarisMetricRegistry {

public PolarisMetricRegistry(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
new ClassLoaderMetrics().bindTo(meterRegistry);
new JvmMemoryMetrics().bindTo(meterRegistry);
new JvmGcMetrics().bindTo(meterRegistry);
new ProcessorMetrics().bindTo(meterRegistry);
new JvmThreadMetrics().bindTo(meterRegistry);
}

public MeterRegistry getMeterRegistry() {
Expand Down

0 comments on commit baf2b8c

Please sign in to comment.