Search in sources :

Example 26 with ServiceType

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);
    }
}
Also used : ServiceType(com.navercorp.pinpoint.common.trace.ServiceType)

Example 27 with ServiceType

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();
}
Also used : ServiceTypeRegistry(com.navercorp.pinpoint.common.trace.ServiceTypeRegistry) StaticFieldLookUp(com.navercorp.pinpoint.common.util.StaticFieldLookUp) ServiceTypeInfo(com.navercorp.pinpoint.common.trace.ServiceTypeInfo) ServiceType(com.navercorp.pinpoint.common.trace.ServiceType)

Example 28 with ServiceType

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) {
    }
}
Also used : DefaultServiceTypeRegistryService(com.navercorp.pinpoint.common.service.DefaultServiceTypeRegistryService) ServiceType(com.navercorp.pinpoint.common.trace.ServiceType) Test(org.junit.Test)

Example 29 with ServiceType

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);
}
Also used : ServiceType(com.navercorp.pinpoint.common.trace.ServiceType)

Example 30 with ServiceType

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);
}
Also used : ServiceType(com.navercorp.pinpoint.common.trace.ServiceType)

Aggregations

ServiceType (com.navercorp.pinpoint.common.trace.ServiceType)34 Test (org.junit.Test)5 SpanBo (com.navercorp.pinpoint.common.server.bo.SpanBo)4 SpanEventBo (com.navercorp.pinpoint.common.server.bo.SpanEventBo)4 Application (com.navercorp.pinpoint.web.vo.Application)3 HistogramSchema (com.navercorp.pinpoint.common.trace.HistogramSchema)2 NodeHistogram (com.navercorp.pinpoint.web.applicationmap.histogram.NodeHistogram)2 ResponseTimeViewModel (com.navercorp.pinpoint.web.view.ResponseTimeViewModel)2 ApplicationTypeDetector (com.navercorp.pinpoint.bootstrap.plugin.ApplicationTypeDetector)1 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)1 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)1 AgentInfoBo (com.navercorp.pinpoint.common.server.bo.AgentInfoBo)1 AnnotationBo (com.navercorp.pinpoint.common.server.bo.AnnotationBo)1 SpanChunkBo (com.navercorp.pinpoint.common.server.bo.SpanChunkBo)1 DefaultServiceTypeRegistryService (com.navercorp.pinpoint.common.service.DefaultServiceTypeRegistryService)1 ServiceTypeRegistryService (com.navercorp.pinpoint.common.service.ServiceTypeRegistryService)1 ServiceTypeInfo (com.navercorp.pinpoint.common.trace.ServiceTypeInfo)1 ServiceTypeRegistry (com.navercorp.pinpoint.common.trace.ServiceTypeRegistry)1 TraceMetadataLoader (com.navercorp.pinpoint.common.trace.TraceMetadataLoader)1 TraceMetadataProvider (com.navercorp.pinpoint.common.trace.TraceMetadataProvider)1