Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
[#107] Logging response time of every REST call as well, easier to tr…
Browse files Browse the repository at this point in the history
…ack individual requests by correlation ID
  • Loading branch information
nurkiewicz committed Dec 16, 2014
1 parent 3958b41 commit fd80e8e
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ofg.infrastructure.web.resttemplate

import com.codahale.metrics.MetricRegistry
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import org.aspectj.lang.ProceedingJoinPoint
import org.aspectj.lang.annotation.Around
import org.aspectj.lang.annotation.Aspect
Expand All @@ -12,6 +13,7 @@ import static org.springframework.util.StringUtils.trimTrailingCharacter

@Aspect
@CompileStatic
@Slf4j
class MetricsAspect {

private static final String PREFIX = RestOperations.class.simpleName
Expand All @@ -26,7 +28,11 @@ class MetricsAspect {
final Object url = pjp.args[0]
final String name = metricName(url)
return metricRegistry.timer(name).time {
return pjp.proceed()
final long startTime = System.currentTimeMillis()
Object result = pjp.proceed()
final long done = System.currentTimeMillis() - startTime
log.debug("Calling '$url' took ${done}ms")
return result
}
}

Expand Down

0 comments on commit fd80e8e

Please sign in to comment.