changed application type and replaced counters with gauges
This commit is contained in:
parent
85f3d1c9dc
commit
6024e0c5b5
|
@ -23,8 +23,8 @@ import java.io.File;
|
|||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/actuator/prometheus")
|
||||
public class PrometheusController { // TODO: remove this with migration to Spring Boot 2
|
||||
@RequestMapping(value = "/actuator/prometheus", produces = "application/openmetrics-text; version=1.0.0; charset=utf-8")
|
||||
public class PrometheusController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(PrometheusController.class);
|
||||
|
||||
private final PiWikService piWikService;
|
||||
|
@ -36,12 +36,12 @@ public class PrometheusController { // TODO: remove this with migration to Sprin
|
|||
this.repositoryService = repositoryService;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, path = "", produces = MediaType.TEXT_PLAIN_VALUE)
|
||||
@RequestMapping(method = RequestMethod.GET)
|
||||
public String getPiwikMetrics() {
|
||||
PrometheusMeterRegistry registry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);
|
||||
registry.counter("provide_repositories_registered").increment(repositoryService.getTotalRegisteredRepositories());
|
||||
registry.counter("provide_usagecounts_repositories_registered").increment(piWikService.getTotal());
|
||||
registry.counter("provide_usagecounts_repositories_validated").increment(piWikService.getValidated(true));
|
||||
registry.gauge("provide_repositories_registered", repositoryService.getTotalRegisteredRepositories());
|
||||
registry.gauge("provide_usagecounts_repositories_registered", piWikService.getTotal());
|
||||
registry.gauge("provide_usagecounts_repositories_validated", piWikService.getValidated(true));
|
||||
|
||||
return registry.scrape(TextFormat.CONTENT_TYPE_OPENMETRICS_100);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue