Skip to content

Instantly share code, notes, and snippets.

@dalexandrov
Created February 23, 2021 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dalexandrov/3087db15f00a8da35e4917d0c3439e53 to your computer and use it in GitHub Desktop.
Save dalexandrov/3087db15f00a8da35e4917d0c3439e53 to your computer and use it in GitHub Desktop.
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