Skip to content

Commit

Permalink
Add jvm metrics (#1735)
Browse files Browse the repository at this point in the history
* Add jvm prometheus metrics

* Add jvm prometheus metrics

* Cr fixes

* Cr fixes
  • Loading branch information
faderskd authored Oct 9, 2023
1 parent 9c8ad5b commit a476171
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package pl.allegro.tech.hermes.common.di.factories;

import io.micrometer.core.instrument.Meter;
import io.micrometer.core.instrument.MeterRegistry;
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.config.MeterFilter;
import io.micrometer.core.instrument.distribution.DistributionStatisticConfig;
import io.micrometer.prometheus.PrometheusConfig;
Expand Down Expand Up @@ -31,6 +35,7 @@ public PrometheusMeterRegistry provide() {
if (parameters.zookeeperReporterEnabled()) {
registerZookeeperReporter(meterRegistry);
}
registerJvmMetrics(meterRegistry);
return meterRegistry;
}

Expand All @@ -55,4 +60,10 @@ private void registerZookeeperReporter(PrometheusMeterRegistry meterRegistry) {
new ZookeeperCounterReporter(meterRegistry, counterStorage, prefix)
.start(parameters.zookeeperReportPeriod().toSeconds(), TimeUnit.SECONDS);
}

private void registerJvmMetrics(MeterRegistry meterRegistry) {
new JvmMemoryMetrics().bindTo(meterRegistry);
new JvmGcMetrics().bindTo(meterRegistry);
new JvmThreadMetrics().bindTo(meterRegistry);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package pl.allegro.tech.hermes.common.metric.executor;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import pl.allegro.tech.hermes.common.metric.HermesMetrics;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ScheduledExecutorService;
Expand All @@ -14,8 +11,6 @@
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import static java.util.concurrent.Executors.newScheduledThreadPool;

public class InstrumentedExecutorServiceFactory {

private final ThreadPoolMetrics threadPoolMetrics;
Expand Down

0 comments on commit a476171

Please sign in to comment.