use of org.springframework.util.StopWatch in project pinpoint by naver.
the class LegacyAgentStatController method getAgentStatV1.
@Deprecated
@PreAuthorize("hasPermission(new com.navercorp.pinpoint.web.vo.AgentParam(#agentId, #to), 'agentParam', 'inspector')")
@RequestMapping(value = "/getAgentStat/v1", method = RequestMethod.GET)
@ResponseBody
public LegacyAgentStatChartGroup getAgentStatV1(@RequestParam("agentId") String agentId, @RequestParam("from") long from, @RequestParam("to") long to, @RequestParam(value = "sampleRate", required = false) Integer sampleRate) throws Exception {
StopWatch watch = new StopWatch();
watch.start("agentStatService.selectAgentStatList");
TimeWindow timeWindow = new TimeWindow(new Range(from, to), new TimeWindowSlotCentricSampler());
LegacyAgentStatChartGroup chartGroup = this.v1Service.selectAgentStatList(agentId, timeWindow);
watch.stop();
if (logger.isInfoEnabled()) {
logger.info("getAgentStatV1(agentId={}, from={}, to={}) : {}ms", agentId, from, to, watch.getLastTaskTimeMillis());
}
return chartGroup;
}
use of org.springframework.util.StopWatch in project pinpoint by naver.
the class LegacyAgentStatController method getAgentStat.
@Deprecated
@PreAuthorize("hasPermission(new com.navercorp.pinpoint.web.vo.AgentParam(#agentId, #to), 'agentParam', 'inspector')")
@RequestMapping(value = "/getAgentStat", method = RequestMethod.GET)
@ResponseBody
public LegacyAgentStatChartGroup getAgentStat(@RequestParam("agentId") String agentId, @RequestParam("from") long from, @RequestParam("to") long to, @RequestParam(value = "sampleRate", required = false) Integer sampleRate) throws Exception {
StopWatch watch = new StopWatch();
watch.start("agentStatService.selectAgentStatList");
TimeWindow timeWindow = new TimeWindow(new Range(from, to), new TimeWindowSlotCentricSampler());
LegacyAgentStatChartGroup chartGroup = this.agentStatService.selectAgentStatList(agentId, timeWindow);
watch.stop();
if (logger.isInfoEnabled()) {
logger.info("getAgentStat(agentId={}, from={}, to={}) : {}ms", agentId, from, to, watch.getLastTaskTimeMillis());
}
return chartGroup;
}
use of org.springframework.util.StopWatch in project pinpoint by naver.
the class FilteredMapServiceImpl method linkStatistics.
@Override
@Deprecated
public LoadFactor linkStatistics(Range range, List<TransactionId> traceIdSet, Application sourceApplication, Application destinationApplication, Filter filter) {
if (sourceApplication == null) {
throw new NullPointerException("sourceApplication must not be null");
}
if (destinationApplication == null) {
throw new NullPointerException("destApplicationName must not be null");
}
if (filter == null) {
throw new NullPointerException("filter must not be null");
}
StopWatch watch = new StopWatch();
watch.start();
List<List<SpanBo>> originalList = this.traceDao.selectAllSpans(traceIdSet);
List<SpanBo> filteredTransactionList = filterList(originalList, filter);
LoadFactor statistics = new LoadFactor(range);
// scan transaction list
for (SpanBo span : filteredTransactionList) {
if (sourceApplication.equals(span.getApplicationId(), registry.findServiceType(span.getApplicationServiceType()))) {
List<SpanEventBo> spanEventBoList = span.getSpanEventBoList();
if (spanEventBoList == null) {
continue;
}
// find dest elapsed time
for (SpanEventBo spanEventBo : spanEventBoList) {
if (destinationApplication.equals(spanEventBo.getDestinationId(), registry.findServiceType(spanEventBo.getServiceType()))) {
// find exception
boolean hasException = spanEventBo.hasException();
// add sample
// TODO : need timeslot value instead of the actual value
statistics.addSample(span.getStartTime() + spanEventBo.getStartElapsed(), spanEventBo.getEndElapsed(), 1, hasException);
break;
}
}
}
}
watch.stop();
logger.info("Fetch link statistics elapsed. {}ms", watch.getLastTaskTimeMillis());
return statistics;
}
use of org.springframework.util.StopWatch in project pinpoint by naver.
the class FilteredMapServiceImpl method selectApplicationMapWithScatterData.
@Override
public ApplicationMap selectApplicationMapWithScatterData(List<TransactionId> transactionIdList, Range originalRange, Range scanRange, int xGroupUnit, int yGroupUnit, Filter filter) {
if (transactionIdList == null) {
throw new NullPointerException("transactionIdList must not be null");
}
if (filter == null) {
throw new NullPointerException("filter must not be null");
}
StopWatch watch = new StopWatch();
watch.start();
final List<List<SpanBo>> filterList = selectFilteredSpan(transactionIdList, filter);
DotExtractor dotExtractor = createDotExtractor(scanRange, filterList);
ApplicationMap map = createMap(originalRange, scanRange, filterList);
ApplicationMapWithScatterData applicationMapWithScatterData = new ApplicationMapWithScatterData(map, dotExtractor.getApplicationScatterData(originalRange.getFrom(), originalRange.getTo(), xGroupUnit, yGroupUnit));
watch.stop();
logger.debug("Select filtered application map elapsed. {}ms", watch.getTotalTimeMillis());
return applicationMapWithScatterData;
}
use of org.springframework.util.StopWatch in project spring-boot by spring-projects.
the class MetricsFilter method doFilterInternal.
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws ServletException, IOException {
StopWatch stopWatch = createStopWatchIfNecessary(request);
String path = new UrlPathHelper().getPathWithinApplication(request);
int status = HttpStatus.INTERNAL_SERVER_ERROR.value();
try {
chain.doFilter(request, response);
status = getStatus(response);
} finally {
if (!request.isAsyncStarted()) {
if (response.isCommitted()) {
status = getStatus(response);
}
stopWatch.stop();
request.removeAttribute(ATTRIBUTE_STOP_WATCH);
recordMetrics(request, path, status, stopWatch.getTotalTimeMillis());
}
}
}
Aggregations