mirror of
https://github.com/wahyd4/pinpoint.git
synced 2026-08-14 15:26:31 +10:00
[유치수] [NOBTS] write terminal statistics
git-svn-id: http://svn.bds.nhncorp.com/pe/hippo-server/trunk@981 84d0f5b1-2673-498c-a247-62c4ff18d310
This commit is contained in:
@@ -1,73 +1,80 @@
|
||||
package com.profiler.server.handler;
|
||||
|
||||
import com.profiler.common.ServiceType;
|
||||
import com.profiler.common.dto.thrift.Span;
|
||||
import com.profiler.common.dto.thrift.SubSpan;
|
||||
import com.profiler.server.dao.*;
|
||||
import java.net.DatagramPacket;
|
||||
|
||||
import org.apache.thrift.TBase;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.net.DatagramPacket;
|
||||
import com.profiler.common.ServiceType;
|
||||
import com.profiler.common.dto.thrift.SubSpan;
|
||||
import com.profiler.server.dao.AgentIdApplicationIndexDao;
|
||||
import com.profiler.server.dao.ApplicationTraceIndexDao;
|
||||
import com.profiler.server.dao.RootTraceIndexDaoDao;
|
||||
import com.profiler.server.dao.TerminalStatisticsDao;
|
||||
import com.profiler.server.dao.TraceIndexDao;
|
||||
import com.profiler.server.dao.TracesDao;
|
||||
|
||||
/**
|
||||
*
|
||||
* subspan represent terminal spans.
|
||||
*/
|
||||
public class SubSpanHandler implements Handler {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(SubSpanHandler.class.getName());
|
||||
private final Logger logger = LoggerFactory.getLogger(SubSpanHandler.class.getName());
|
||||
|
||||
@Autowired
|
||||
private TraceIndexDao traceIndexDao;
|
||||
@Autowired
|
||||
private TraceIndexDao traceIndexDao;
|
||||
|
||||
@Autowired
|
||||
private TracesDao traceDao;
|
||||
@Autowired
|
||||
private TracesDao traceDao;
|
||||
|
||||
@Autowired
|
||||
private RootTraceIndexDaoDao rootTraceIndexDao;
|
||||
@Autowired
|
||||
private RootTraceIndexDaoDao rootTraceIndexDao;
|
||||
|
||||
@Autowired
|
||||
private ApplicationTraceIndexDao applicationTraceIndexDao;
|
||||
@Autowired
|
||||
private ApplicationTraceIndexDao applicationTraceIndexDao;
|
||||
|
||||
@Autowired
|
||||
private AgentIdApplicationIndexDao agentIdApplicationIndexDao;
|
||||
@Autowired
|
||||
private AgentIdApplicationIndexDao agentIdApplicationIndexDao;
|
||||
|
||||
@Autowired
|
||||
private TerminalStatisticsDao terminalStatistics;
|
||||
@Autowired
|
||||
private TerminalStatisticsDao terminalStatistics;
|
||||
|
||||
@Override
|
||||
public void handler(TBase<?, ?> tbase, DatagramPacket datagramPacket) {
|
||||
try {
|
||||
SubSpan subSpan = (SubSpan) tbase;
|
||||
@Override
|
||||
public void handler(TBase<?, ?> tbase, DatagramPacket datagramPacket) {
|
||||
try {
|
||||
SubSpan subSpan = (SubSpan) tbase;
|
||||
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Received SubSPAN=" + subSpan);
|
||||
}
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Received SubSPAN=" + subSpan);
|
||||
}
|
||||
|
||||
String applicationName = agentIdApplicationIndexDao.selectApplicationName(subSpan.getAgentId());
|
||||
String applicationName = agentIdApplicationIndexDao.selectApplicationName(subSpan.getAgentId());
|
||||
|
||||
if (applicationName == null) {
|
||||
logger.warn("Applicationname '{}' not found. Drop the log.", applicationName);
|
||||
return;
|
||||
} else {
|
||||
logger.info("Applicationname '{}' found. Write the log.", applicationName);
|
||||
}
|
||||
if (applicationName == null) {
|
||||
logger.warn("Applicationname '{}' not found. Drop the log.", applicationName);
|
||||
return;
|
||||
} else {
|
||||
logger.info("Applicationname '{}' found. Write the log.", applicationName);
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Found Applicationname={}", applicationName);
|
||||
}
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Found Applicationname={}", applicationName);
|
||||
}
|
||||
|
||||
ServiceType serviceType = ServiceType.parse(subSpan.getServiceType());
|
||||
ServiceType serviceType = ServiceType.parse(subSpan.getServiceType());
|
||||
|
||||
traceDao.insertTerminalSpan(applicationName, subSpan);
|
||||
traceDao.insertTerminalSpan(applicationName, subSpan);
|
||||
|
||||
// if terminal update statistics
|
||||
// terminalStatistics.update(applicationName, subSpan.getServiceName(), serviceType.getCode(), subSpan.getAgentId());
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.warn("Span handle error " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
// if terminal update statistics
|
||||
if (serviceType.isRpcClient()) {
|
||||
terminalStatistics.update(applicationName, subSpan.getEndPoint(), serviceType.getCode());
|
||||
} else {
|
||||
terminalStatistics.update(applicationName, subSpan.getServiceName(), serviceType.getCode());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.warn("Span handle error " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user