Created
February 23, 2021 14:45
-
-
Save dalexandrov/3087db15f00a8da35e4917d0c3439e53 to your computer and use it in GitHub Desktop.
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
private void reinit() { | |
Map<String, Function<ConnectionPoolMetrics, Long>> counters = Map.ofEntries( | |
entry("acquired", ConnectionPoolMetrics::acquired), | |
entry("closed", ConnectionPoolMetrics::closed), | |
entry("created", ConnectionPoolMetrics::created), | |
entry("failedToCreate", ConnectionPoolMetrics::failedToCreate), | |
entry("timedOutToAcquire", ConnectionPoolMetrics::timedOutToAcquire), | |
entry("totalAcquisitionTime", ConnectionPoolMetrics::totalAcquisitionTime), | |
entry("totalConnectionTime", ConnectionPoolMetrics::totalConnectionTime), | |
entry("totalInUseCount", ConnectionPoolMetrics::totalInUseCount), | |
entry("totalInUseTime", ConnectionPoolMetrics::totalInUseTime)); | |
Map<String, Function<ConnectionPoolMetrics, Integer>> gauges = Map.ofEntries( | |
entry("acquiring", ConnectionPoolMetrics::acquiring), | |
entry("creating", ConnectionPoolMetrics::creating), | |
entry("idle", ConnectionPoolMetrics::idle), | |
entry("inUse", ConnectionPoolMetrics::inUse) | |
); | |
for (ConnectionPoolMetrics it : lastPoolMetrics.get()) { | |
//String poolPrefix = NEO4J_METRIC_NAME_PREFIX + "-" + it.id() + "-"; | |
String poolPrefix = NEO4J_METRIC_NAME_PREFIX + "-"; | |
counters.forEach((name, supplier) -> registerCounter(metricRegistry.get(), it, poolPrefix, name, supplier)); | |
gauges.forEach((name, supplier) -> registerGauge(metricRegistry.get(), it, poolPrefix, name, supplier)); | |
// we only care about the first one | |
metricsInitialized.set(true); | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment