@Test void testPrometheus() { when(meterRegistry.scrape()).thenReturn("scraped"); String actual = metricsController.prometheus(); assertEquals("scraped", actual); }
@GetMapping(path = "prometheus", produces = CONTENT_TYPE_004) @ResponseStatus(HttpStatus.OK) @PreAuthorize("hasAnyRole('METRICS')") @ApiResponses({ @ApiResponse( code = 200, message = "Tab separated metrics values in a format fit for prometheus to consume"), @ApiResponse(code = 403, message = "Current user does not have ROLE_METRICS"), @ApiResponse( code = 401, message = "User is not authenticated and anonymous user does not have ROLE_METRICS") }) @ApiOperation( value = "Get recorded metrics for prometheus.", response = String.class, produces = CONTENT_TYPE_004) public String prometheus() { return meterRegistry.scrape(); }
MetricsController { @GetMapping(path = "prometheus", produces = CONTENT_TYPE_004) @ResponseStatus(HttpStatus.OK) @PreAuthorize("hasAnyRole('METRICS')") @ApiResponses({ @ApiResponse( code = 200, message = "Tab separated metrics values in a format fit for prometheus to consume"), @ApiResponse(code = 403, message = "Current user does not have ROLE_METRICS"), @ApiResponse( code = 401, message = "User is not authenticated and anonymous user does not have ROLE_METRICS") }) @ApiOperation( value = "Get recorded metrics for prometheus.", response = String.class, produces = CONTENT_TYPE_004) public String prometheus() { return meterRegistry.scrape(); } }
MetricsController { @GetMapping(path = "prometheus", produces = CONTENT_TYPE_004) @ResponseStatus(HttpStatus.OK) @PreAuthorize("hasAnyRole('METRICS')") @ApiResponses({ @ApiResponse( code = 200, message = "Tab separated metrics values in a format fit for prometheus to consume"), @ApiResponse(code = 403, message = "Current user does not have ROLE_METRICS"), @ApiResponse( code = 401, message = "User is not authenticated and anonymous user does not have ROLE_METRICS") }) @ApiOperation( value = "Get recorded metrics for prometheus.", response = String.class, produces = CONTENT_TYPE_004) public String prometheus() { return meterRegistry.scrape(); } MetricsController(PrometheusMeterRegistry meterRegistry); }
MetricsController { @GetMapping(path = "prometheus", produces = CONTENT_TYPE_004) @ResponseStatus(HttpStatus.OK) @PreAuthorize("hasAnyRole('METRICS')") @ApiResponses({ @ApiResponse( code = 200, message = "Tab separated metrics values in a format fit for prometheus to consume"), @ApiResponse(code = 403, message = "Current user does not have ROLE_METRICS"), @ApiResponse( code = 401, message = "User is not authenticated and anonymous user does not have ROLE_METRICS") }) @ApiOperation( value = "Get recorded metrics for prometheus.", response = String.class, produces = CONTENT_TYPE_004) public String prometheus() { return meterRegistry.scrape(); } MetricsController(PrometheusMeterRegistry meterRegistry); @GetMapping(path = "prometheus", produces = CONTENT_TYPE_004) @ResponseStatus(HttpStatus.OK) @PreAuthorize("hasAnyRole('METRICS')") @ApiResponses({ @ApiResponse( code = 200, message = "Tab separated metrics values in a format fit for prometheus to consume"), @ApiResponse(code = 403, message = "Current user does not have ROLE_METRICS"), @ApiResponse( code = 401, message = "User is not authenticated and anonymous user does not have ROLE_METRICS") }) @ApiOperation( value = "Get recorded metrics for prometheus.", response = String.class, produces = CONTENT_TYPE_004) String prometheus(); }
MetricsController { @GetMapping(path = "prometheus", produces = CONTENT_TYPE_004) @ResponseStatus(HttpStatus.OK) @PreAuthorize("hasAnyRole('METRICS')") @ApiResponses({ @ApiResponse( code = 200, message = "Tab separated metrics values in a format fit for prometheus to consume"), @ApiResponse(code = 403, message = "Current user does not have ROLE_METRICS"), @ApiResponse( code = 401, message = "User is not authenticated and anonymous user does not have ROLE_METRICS") }) @ApiOperation( value = "Get recorded metrics for prometheus.", response = String.class, produces = CONTENT_TYPE_004) public String prometheus() { return meterRegistry.scrape(); } MetricsController(PrometheusMeterRegistry meterRegistry); @GetMapping(path = "prometheus", produces = CONTENT_TYPE_004) @ResponseStatus(HttpStatus.OK) @PreAuthorize("hasAnyRole('METRICS')") @ApiResponses({ @ApiResponse( code = 200, message = "Tab separated metrics values in a format fit for prometheus to consume"), @ApiResponse(code = 403, message = "Current user does not have ROLE_METRICS"), @ApiResponse( code = 401, message = "User is not authenticated and anonymous user does not have ROLE_METRICS") }) @ApiOperation( value = "Get recorded metrics for prometheus.", response = String.class, produces = CONTENT_TYPE_004) String prometheus();  }