Created
February 23, 2021 14:41
-
-
Save dalexandrov/f854ab2c780363eaa5a81e933eb6391e 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 registerCounter(MetricRegistry metricRegistry, | |
ConnectionPoolMetrics cpm, | |
String poolPrefix, | |
String name, | |
Function<ConnectionPoolMetrics, Long> fn) { | |
String counterName = poolPrefix + name; | |
if (metricRegistry.getCounters().get(new MetricID(counterName)) == null) { | |
Metadata metadata = Metadata.builder() | |
.withName(counterName) | |
.withType(MetricType.COUNTER) | |
.notReusable() | |
.build(); | |
Neo4JCounterWrapper wrapper = new Neo4JCounterWrapper(() -> fn.apply(cpm)); | |
metricRegistry.register(metadata, wrapper); | |
} | |
} | |
private void registerGauge(MetricRegistry metricRegistry, | |
ConnectionPoolMetrics cpm, | |
String poolPrefix, | |
String name, | |
Function<ConnectionPoolMetrics, Integer> fn) { | |
String gaugeName = poolPrefix + name; | |
if (metricRegistry.getGauges().get(new MetricID(gaugeName)) == null) { | |
Metadata metadata = Metadata.builder() | |
.withName(poolPrefix + name) | |
.withType(MetricType.GAUGE) | |
.notReusable() | |
.build(); | |
Neo4JGaugeWrapper<Integer> wrapper = | |
new Neo4JGaugeWrapper<>(() -> fn.apply(cpm)); | |
metricRegistry.register(metadata, wrapper); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment