-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
) * #1748 WIP * #1748 Add monitoring for Zookeeper cache executor service * #1748 Remove unnecessary method * #1748 Remove unused methods * #1748 Remove unused constants * #1748 Test for monitoring of the executors with Micrometer --------- Co-authored-by: Michal Ciszewski <michal.ciszewski@allegro.pl>
- Loading branch information
Showing
14 changed files
with
128 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 8 additions & 41 deletions
49
hermes-common/src/main/java/pl/allegro/tech/hermes/common/metric/ExecutorMetrics.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,23 @@ | ||
package pl.allegro.tech.hermes.common.metric; | ||
|
||
import io.micrometer.core.instrument.MeterRegistry; | ||
import io.micrometer.core.instrument.Tags; | ||
import io.micrometer.core.instrument.binder.jvm.ExecutorServiceMetrics; | ||
|
||
import java.util.function.ToDoubleFunction; | ||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.ScheduledExecutorService; | ||
|
||
public class ExecutorMetrics { | ||
private final HermesMetrics hermesMetrics; | ||
private final MeterRegistry meterRegistry; | ||
|
||
public ExecutorMetrics(HermesMetrics hermesMetrics, MeterRegistry meterRegistry) { | ||
this.hermesMetrics = hermesMetrics; | ||
public ExecutorMetrics(MeterRegistry meterRegistry) { | ||
this.meterRegistry = meterRegistry; | ||
} | ||
|
||
public <T> void registerThreadPoolCapacity(String executorName, T stateObj, ToDoubleFunction<T> f) { | ||
hermesMetrics.registerThreadPoolCapacity(executorName, () -> (int) f.applyAsDouble(stateObj)); | ||
registerMicrometerGauge("executors.capacity", executorName, stateObj, f); | ||
public ExecutorService monitor(ExecutorService executorService, String executorName) { | ||
return ExecutorServiceMetrics.monitor(meterRegistry, executorService, executorName); | ||
} | ||
|
||
public <T> void registerThreadPoolActiveThreads(String executorName, T stateObj, ToDoubleFunction<T> f) { | ||
hermesMetrics.registerThreadPoolActiveThreads(executorName, () -> (int) f.applyAsDouble(stateObj)); | ||
registerMicrometerGauge("executors.active-threads", executorName, stateObj, f); | ||
} | ||
|
||
public <T> void registerThreadPoolUtilization(String executorName, T stateObj, ToDoubleFunction<T> f) { | ||
hermesMetrics.registerThreadPoolUtilization(executorName, () -> f.applyAsDouble(stateObj)); | ||
registerMicrometerGauge("executors.utilization", executorName, stateObj, f); | ||
} | ||
|
||
public <T> void registerThreadPoolTaskQueueCapacity(String executorName, T stateObj, ToDoubleFunction<T> f) { | ||
hermesMetrics.registerThreadPoolTaskQueueCapacity(executorName, () -> (int) f.applyAsDouble(stateObj)); | ||
registerMicrometerGauge("executors.task-queue-capacity", executorName, stateObj, f); | ||
} | ||
|
||
public <T> void registerThreadPoolTaskQueued(String executorName, T stateObj, ToDoubleFunction<T> f) { | ||
hermesMetrics.registerThreadPoolTaskQueued(executorName, () -> (int) f.applyAsDouble(stateObj)); | ||
registerMicrometerGauge("executors.task-queue-size", executorName, stateObj, f); | ||
} | ||
|
||
public <T> void registerThreadPoolTaskQueueUtilization(String executorName, T stateObj, ToDoubleFunction<T> f) { | ||
hermesMetrics.registerThreadPoolTaskQueueUtilization(executorName, () -> f.applyAsDouble(stateObj)); | ||
registerMicrometerGauge("executors.task-queue-utilization", executorName, stateObj, f); | ||
} | ||
|
||
public void incrementRequestRejectedCounter(String executorName) { | ||
hermesMetrics.incrementThreadPoolTaskRejectedCount(executorName); | ||
meterRegistry.counter("executors.task-rejected", Tags.of("executor_name", executorName)).increment(); | ||
} | ||
|
||
|
||
private <T> void registerMicrometerGauge(String name, String executorName, T stateObj, ToDoubleFunction<T> f) { | ||
meterRegistry.gauge(name, Tags.of("executor_name", executorName), stateObj, f); | ||
public ScheduledExecutorService monitor(ScheduledExecutorService scheduledExecutorService, String executorName) { | ||
return ExecutorServiceMetrics.monitor(meterRegistry, scheduledExecutorService, executorName); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 0 additions & 43 deletions
43
...common/src/main/java/pl/allegro/tech/hermes/common/metric/executor/ThreadPoolMetrics.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.