I am trying to enable method execution time tracking so I can see the execution times on zipkin. I am using micrometer for that. I have set up my application in a docker container and i have also zipkin in a docker container. I know that there is a connection between my application container and the zipkin container because I can see it receives http request and so on. This is how I have modified my method that i want to track in the service layer:
@Transactional
public Page<W> getAll(
UUID distributionCenterId,
Pageable pageable,
Language language
) {
String methodName = "getAll";
log.debug("{} - Entry. Get all entities", methodName);
Span span = tracer.nextSpan().name(methodName).start();
long startTime = System.nanoTime();
try {
pageable = validatePageable(pageable, methodName);
Page<W> response;
// Try to get the entities from the cache if cacheService is available
if (cacheService != null) {
Optional<List<LR>> cachedResponse = cacheService.getAll(distributionCenterId, language.toString());
if (cachedResponse.isPresent()) {
log.debug("{} - Cache hit for all entities with distributionCenterId: '{}'", methodName, distributionCenterId);
response = new PageImpl<>(
cachedResponse.get().stream().map(this::createWrapper).collect(Collectors.toList()),
pageable,
cachedResponse.get().size()
);
log.info("{} - Exit. Found all entities from cache: '{}'", methodName, response);
long endTime = System.nanoTime();
long duration = endTime - startTime;
span.tag("duration", String.valueOf(duration));
return response;
}
log.debug("{} - Cache miss for all entities with distributionCenterId: '{}'", methodName, distributionCenterId);
}
// Fetch the entities from the repository if not found in cache
response = repo.findAll(distributionCenterId, pageable)
.map(entity -> {
populateOthers(entity);
return createResponse(entity, language);
})
.map(this::createWrapper);
// Store the response in the cache if cacheService is available
if (cacheService != null) {
List<LR> responseList = response.getContent().stream().map(W::getLogicResponse).collect(Collectors.toList());
cacheService.storeAll(responseList, distributionCenterId, language.toString(), 5, TimeUnit.MINUTES);
}
log.info("{} - Exit. Found all entities: '{}'", methodName, response);
long endTime = System.nanoTime();
long duration = endTime - startTime;
span.tag("duration", String.valueOf(duration));
return response;
} catch (Exception e) {
span.error(e);
throw e;
} finally {
span.end();
}
}
I dont know what i am doing wrong but on initial load I get a request from a different method that tracks some execution time but no detail is given on what exactly it tracked