use of com.navercorp.pinpoint.common.trace.ServiceType in project pinpoint by naver.
the class SpanHandler method insertSpanStat.
private void insertSpanStat(SpanBo span) {
final ServiceType applicationServiceType = getApplicationServiceType(span);
final ServiceType spanServiceType = registry.findServiceType(span.getServiceType());
final boolean isError = span.getErrCode() != 0;
int bugCheck = 0;
if (span.getParentSpanId() == -1) {
if (spanServiceType.isQueue()) {
// create virtual queue node
statisticsHandler.updateCaller(span.getAcceptorHost(), spanServiceType, span.getRemoteAddr(), span.getApplicationId(), applicationServiceType, span.getEndPoint(), span.getElapsed(), isError);
statisticsHandler.updateCallee(span.getApplicationId(), applicationServiceType, span.getAcceptorHost(), spanServiceType, span.getAgentId(), span.getElapsed(), isError);
} else {
// create virtual user
statisticsHandler.updateCaller(span.getApplicationId(), ServiceType.USER, span.getAgentId(), span.getApplicationId(), applicationServiceType, span.getAgentId(), span.getElapsed(), isError);
// update the span information of the current node (self)
statisticsHandler.updateCallee(span.getApplicationId(), applicationServiceType, span.getApplicationId(), ServiceType.USER, span.getAgentId(), span.getElapsed(), isError);
}
bugCheck++;
}
// when drawing server map based on statistics info, you must know the application name of the previous node.
if (span.getParentApplicationId() != null) {
String parentApplicationName = span.getParentApplicationId();
logger.debug("Received parent application name. {}", parentApplicationName);
ServiceType parentApplicationType = registry.findServiceType(span.getParentApplicationServiceType());
// 2. current node's application service type is not a queue (current node may be a queue that is traced)
if (spanServiceType.isQueue()) {
if (!applicationServiceType.isQueue() && !parentApplicationType.isQueue()) {
// emulate virtual queue node's accept Span and record it's acceptor host
hostApplicationMapDao.insert(span.getRemoteAddr(), span.getAcceptorHost(), spanServiceType.getCode(), parentApplicationName, parentApplicationType.getCode());
// emulate virtual queue node's send SpanEvent
statisticsHandler.updateCaller(span.getAcceptorHost(), spanServiceType, span.getRemoteAddr(), span.getApplicationId(), applicationServiceType, span.getEndPoint(), span.getElapsed(), isError);
parentApplicationName = span.getAcceptorHost();
parentApplicationType = spanServiceType;
}
}
statisticsHandler.updateCallee(span.getApplicationId(), applicationServiceType, parentApplicationName, parentApplicationType, span.getAgentId(), span.getElapsed(), isError);
bugCheck++;
}
// record the response time of the current node (self).
// blow code may be conflict of idea above callee key.
// it is odd to record reversely, because of already recording the caller data at previous node.
// the data may be different due to timeout or network error.
statisticsHandler.updateResponseTime(span.getApplicationId(), applicationServiceType, span.getAgentId(), span.getElapsed(), isError);
if (bugCheck != 1) {
logger.warn("ambiguous span found(bug). span:{}", span);
}
}
use of com.navercorp.pinpoint.common.trace.ServiceType in project pinpoint by naver.
the class DefaultServiceTypeRegistryService method buildServiceTypeRegistry.
private ServiceTypeRegistry buildServiceTypeRegistry() {
ServiceTypeRegistry.Builder builder = new ServiceTypeRegistry.Builder();
StaticFieldLookUp<ServiceType> staticFieldLookUp = new StaticFieldLookUp<ServiceType>(ServiceType.class, ServiceType.class);
List<ServiceType> lookup = staticFieldLookUp.lookup();
for (ServiceType serviceType : lookup) {
if (logger.isInfoEnabled()) {
logger.info("add Default ServiceType:" + serviceType);
}
builder.addServiceType(serviceType);
}
final List<ServiceTypeInfo> types = loadType();
for (ServiceTypeInfo type : types) {
if (logger.isInfoEnabled()) {
logger.info("add Plugin ServiceType:" + type.getServiceType());
}
builder.addServiceType(type.getServiceType());
}
return builder.build();
}
use of com.navercorp.pinpoint.common.trace.ServiceType in project pinpoint by naver.
the class ServiceTypeTest method findDesc.
@Test
public void findDesc() {
DefaultServiceTypeRegistryService serviceTypeRegistryService = new DefaultServiceTypeRegistryService();
String desc = "UNKNOWN_DB";
List<ServiceType> serviceTypeList = serviceTypeRegistryService.findDesc(desc);
boolean find = false;
for (ServiceType serviceType : serviceTypeList) {
if (serviceType.getDesc().equals(desc)) {
find = true;
}
}
Assert.assertTrue(find);
try {
serviceTypeList.add(ServiceType.INTERNAL_METHOD);
Assert.fail();
} catch (Exception ignored) {
}
}
use of com.navercorp.pinpoint.common.trace.ServiceType in project pinpoint by naver.
the class IBatisPlugin method addInterceptorsForSqlMapExecutors.
// SqlMapClient / SqlMapSession
private void addInterceptorsForSqlMapExecutors() {
final ServiceType serviceType = IBATIS;
final String[] sqlMapExecutorImplClasses = { "com.ibatis.sqlmap.engine.impl.SqlMapClientImpl", "com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl" };
addInterceptorsForClasses(serviceType, sqlMapExecutorImplClasses);
}
use of com.navercorp.pinpoint.common.trace.ServiceType in project pinpoint by naver.
the class IBatisPlugin method addInterceptorsForSqlMapClientTemplate.
// SqlMapClientTemplate
private void addInterceptorsForSqlMapClientTemplate() {
final ServiceType serviceType = IBATIS_SPRING;
final String[] sqlMapClientTemplateClasses = { "org.springframework.orm.ibatis.SqlMapClientTemplate" };
addInterceptorsForClasses(serviceType, sqlMapClientTemplateClasses);
}
Aggregations