Library to expose Prometheus metrics
...
repositories {
maven {
url "https://mvn.universal-development.com/public"
}
}
...
dependencies {
implementation('com.unidev:unidev-prometheus:0.0.1')
}
Usage:
MetricService metricService = new MetricService(ConfigService.appName(), prometheusPort);
...
metricService.inc("failed-operation", Map.of("type", "read-db"));
metricService.counter("template-evaluation", Map.of("template", templateName)).inc();
try {
...
} catch(Throwable t) {
metricService.countException(t, Map.of("method", "dbQuery()"));
}
https://github.com/prometheus/client_java#instrumenting
https://sysdig.com/blog/prometheus-metrics/
This code is released under the MIT License. See LICENSE.