I have a spring boot 3 and webflux application, i want to use Micrometer, using on controller it is working like
@Override
public Mono<ResponseEntity<NetworkTokenInformationResponse>> getToken(String gatewayToken, ServerWebExchange exchange) {
return getTokenizationInformationByGatewayToken.execute(gatewayToken)
.map(token -> {
token.add(linkTo(methodOn(TokenController.class).getToken(token.getGatewayToken(), exchange)).withSelfRel());
registry.counter("getToken.controller", "gatewayToken", gatewayToken).increment();
return ResponseEntity.ok()
.contentType(MediaType.APPLICATION_JSON)
.body(token);
}
);
}
but when i try to executre it in a service because it is more simple to be processed nothing happen, this is the code in service
@Slf4j
@AllArgsConstructor
public class GetTokenizationInformationByGatewayToken {
private final TokenRepositoryAdapter repository;
private MeterRegistry registry;
public Mono<NetworkTokenInformationResponse> execute(@NonNull String gatewayToken) {
log.info(STR."get token from database token {gatewayToken}");
return repository.findByGatewayToken(gatewayToken)
.switchIfEmpty(Mono.error(new TokenizationNotFoundException(STR."No network token found in database for gateway token {gatewayToken}")))
.flatMap(token -> Mono.just(token.networkTokenInformationResponseExtracted()))
.doOnSuccess(_ ->
registry.counter("getToken.controller", "gatewayToken", gatewayToken).increment());
}
}
We go in the code but nothing available when then i parse the url /actuator/prometeus
application.properties
management.metrics.tags.application=${spring.application.name}
management.endpoints.web.exposure.include=prometheus
Is there soemthing with Flux and Mono blocking it ?