Search in sources :

Example 11 with VisibleForTesting

use of com.navercorp.pinpoint.common.annotations.VisibleForTesting in project pinpoint by naver.

the class SpanFactory method fullScanLocalAsyncIdBo.

@VisibleForTesting
LocalAsyncIdBo fullScanLocalAsyncIdBo(TSpanChunk tSpanChunk) {
    int asyncId = -1;
    int asyncSequence = -1;
    boolean first = true;
    boolean asyncIdNotSame = false;
    for (TSpanEvent tSpanEvent : tSpanChunk.getSpanEventList()) {
        if (first) {
            first = false;
            if (isSetAsyncId(tSpanEvent)) {
                asyncId = tSpanEvent.getAsyncId();
                asyncSequence = tSpanEvent.getAsyncSequence();
            }
        } else {
            if (isSetAsyncId(tSpanEvent)) {
                if (asyncId != tSpanEvent.getAsyncId()) {
                    asyncIdNotSame = true;
                    break;
                }
                if (asyncSequence != tSpanEvent.getAsyncSequence()) {
                    asyncIdNotSame = true;
                    break;
                }
            }
        }
    }
    if (asyncIdNotSame) {
        logger.warn("AsyncId consistency is broken. tSpanChunk:{}", tSpanChunk);
        return null;
    }
    if (asyncId != -1 && asyncSequence != -1) {
        return new LocalAsyncIdBo(asyncId, asyncSequence);
    }
    // non async
    return null;
}
Also used : LocalAsyncIdBo(com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) VisibleForTesting(com.navercorp.pinpoint.common.annotations.VisibleForTesting)

Example 12 with VisibleForTesting

use of com.navercorp.pinpoint.common.annotations.VisibleForTesting in project pinpoint by naver.

the class UNIXProcessPidProvider method getPidField.

@VisibleForTesting
static Field getPidField(Class<?> unixProcess) throws NoSuchFieldException {
    Field pid = unixProcess.getDeclaredField(PID_FIELD_NAME);
    pid.setAccessible(true);
    return pid;
}
Also used : Field(java.lang.reflect.Field) VisibleForTesting(com.navercorp.pinpoint.common.annotations.VisibleForTesting)

Example 13 with VisibleForTesting

use of com.navercorp.pinpoint.common.annotations.VisibleForTesting in project pinpoint by naver.

the class DataSourceChart method newDataSourceChartGroup.

@VisibleForTesting
static DataSourceChartGroup newDataSourceChartGroup(TimeWindow timeWindow, List<SampledDataSource> sampledDataSources, ServiceTypeRegistryService serviceTypeRegistryService) {
    Objects.requireNonNull(timeWindow, "timeWindow");
    Map<StatChartGroup.ChartType, Chart<? extends Point>> chartTypeChartMap = newDatasourceChart(timeWindow, sampledDataSources);
    if (CollectionUtils.isEmpty(sampledDataSources)) {
        final Integer uncollectedValue = SampledDataSource.UNCOLLECTED_VALUE;
        // TODO avoid null
        final String uncollectedString = SampledDataSource.UNCOLLECTED_STRING;
        return new DataSourceChartGroup(timeWindow, chartTypeChartMap, uncollectedValue, uncollectedString, uncollectedString, uncollectedString);
    } else {
        SampledDataSource latestSampledDataSource = CollectionUtils.lastElement(sampledDataSources);
        int id = latestSampledDataSource.getId();
        String serviceTypeName = serviceTypeRegistryService.findServiceType(latestSampledDataSource.getServiceTypeCode()).getName();
        String databaseName = latestSampledDataSource.getDatabaseName();
        String jdbcUrl = latestSampledDataSource.getJdbcUrl();
        return new DataSourceChartGroup(timeWindow, chartTypeChartMap, id, serviceTypeName, databaseName, jdbcUrl);
    }
}
Also used : SampledDataSource(com.navercorp.pinpoint.web.vo.stat.SampledDataSource) Point(com.navercorp.pinpoint.web.vo.chart.Point) StatChart(com.navercorp.pinpoint.web.vo.stat.chart.StatChart) Chart(com.navercorp.pinpoint.web.vo.chart.Chart) Point(com.navercorp.pinpoint.web.vo.chart.Point) VisibleForTesting(com.navercorp.pinpoint.common.annotations.VisibleForTesting)

Example 14 with VisibleForTesting

use of com.navercorp.pinpoint.common.annotations.VisibleForTesting in project pinpoint by naver.

the class SpanThriftMessageConverter method buildTSpan.

@VisibleForTesting
TSpan buildTSpan(Span span) {
    final TSpan tSpan = new TSpan();
    // tSpan.setVersion(span.getVersion());
    tSpan.setApplicationName(applicationName);
    tSpan.setAgentId(agentId);
    tSpan.setAgentStartTime(agentStartTime);
    tSpan.setApplicationServiceType(applicationServiceType);
    final TraceRoot traceRoot = span.getTraceRoot();
    final TraceId traceId = traceRoot.getTraceId();
    final ByteBuffer transactionId = transactionIdEncoder.encodeTransactionId(traceId);
    tSpan.setTransactionId(transactionId);
    tSpan.setSpanId(traceId.getSpanId());
    tSpan.setParentSpanId(traceId.getParentSpanId());
    tSpan.setStartTime(span.getStartTime());
    tSpan.setElapsed(span.getElapsedTime());
    tSpan.setServiceType(span.getServiceType());
    tSpan.setRemoteAddr(span.getRemoteAddr());
    final Shared shared = traceRoot.getShared();
    tSpan.setRpc(shared.getRpcName());
    tSpan.setEndPoint(shared.getEndPoint());
    tSpan.setFlag(traceId.getFlags());
    tSpan.setErr(shared.getErrorCode());
    tSpan.setParentApplicationName(span.getParentApplicationName());
    tSpan.setParentApplicationType(span.getParentApplicationType());
    tSpan.setAcceptorHost(span.getAcceptorHost());
    tSpan.setApiId(span.getApiId());
    final IntStringValue exceptionInfo = span.getExceptionInfo();
    if (exceptionInfo != null) {
        TIntStringValue tIntStringValue = buildTIntStringValue(exceptionInfo);
        tSpan.setExceptionInfo(tIntStringValue);
    }
    tSpan.setLoggingTransactionInfo(shared.getLoggingInfo());
    final List<Annotation<?>> annotations = span.getAnnotations();
    if (CollectionUtils.hasLength(annotations)) {
        final List<TAnnotation> tAnnotations = buildTAnnotation(annotations);
        tSpan.setAnnotations(tAnnotations);
    }
    spanPostProcessor.preProcess(span, tSpan);
    final List<SpanEvent> spanEventList = span.getSpanEventList();
    if (CollectionUtils.hasLength(spanEventList)) {
        final List<TSpanEvent> tSpanEvents = buildTSpanEventList(spanEventList);
        tSpan.setSpanEventList(tSpanEvents);
    }
    spanPostProcessor.postProcess(span, tSpan);
    return tSpan;
}
Also used : TIntStringValue(com.navercorp.pinpoint.thrift.dto.TIntStringValue) Shared(com.navercorp.pinpoint.profiler.context.id.Shared) ByteBuffer(java.nio.ByteBuffer) TAnnotation(com.navercorp.pinpoint.thrift.dto.TAnnotation) Annotation(com.navercorp.pinpoint.profiler.context.Annotation) TAnnotation(com.navercorp.pinpoint.thrift.dto.TAnnotation) IntStringValue(com.navercorp.pinpoint.common.util.IntStringValue) TIntStringValue(com.navercorp.pinpoint.thrift.dto.TIntStringValue) SpanEvent(com.navercorp.pinpoint.profiler.context.SpanEvent) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) TSpan(com.navercorp.pinpoint.thrift.dto.TSpan) TraceId(com.navercorp.pinpoint.bootstrap.context.TraceId) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) VisibleForTesting(com.navercorp.pinpoint.common.annotations.VisibleForTesting)

Example 15 with VisibleForTesting

use of com.navercorp.pinpoint.common.annotations.VisibleForTesting in project pinpoint by naver.

the class PinpointServerAcceptor method setMessageHandler.

@VisibleForTesting
public void setMessageHandler(final ChannelHandler messageHandler) {
    Objects.requireNonNull(messageHandler, "messageHandler");
    bootstrap.setPipelineFactory(new ChannelPipelineFactory() {

        @Override
        public ChannelPipeline getPipeline() throws Exception {
            ChannelPipeline pipeline = pipelineFactory.newPipeline();
            pipeline.addLast("handler", messageHandler);
            return pipeline;
        }
    });
}
Also used : ChannelPipelineFactory(org.jboss.netty.channel.ChannelPipelineFactory) PinpointSocketException(com.navercorp.pinpoint.rpc.PinpointSocketException) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline) VisibleForTesting(com.navercorp.pinpoint.common.annotations.VisibleForTesting)

Aggregations

VisibleForTesting (com.navercorp.pinpoint.common.annotations.VisibleForTesting)15 TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)6 SpanEvent (com.navercorp.pinpoint.profiler.context.SpanEvent)5 TraceId (com.navercorp.pinpoint.bootstrap.context.TraceId)4 IntStringValue (com.navercorp.pinpoint.common.util.IntStringValue)4 Annotation (com.navercorp.pinpoint.profiler.context.Annotation)4 LocalAsyncId (com.navercorp.pinpoint.profiler.context.LocalAsyncId)4 Shared (com.navercorp.pinpoint.profiler.context.id.Shared)4 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)4 PAnnotation (com.navercorp.pinpoint.grpc.trace.PAnnotation)3 PSpanEvent (com.navercorp.pinpoint.grpc.trace.PSpanEvent)3 TAnnotation (com.navercorp.pinpoint.thrift.dto.TAnnotation)3 LocalAsyncIdBo (com.navercorp.pinpoint.common.server.bo.LocalAsyncIdBo)2 PIntStringValue (com.navercorp.pinpoint.grpc.trace.PIntStringValue)2 PLocalAsyncId (com.navercorp.pinpoint.grpc.trace.PLocalAsyncId)2 PTransactionId (com.navercorp.pinpoint.grpc.trace.PTransactionId)2 AsyncId (com.navercorp.pinpoint.profiler.context.AsyncId)2 AsyncSpanChunk (com.navercorp.pinpoint.profiler.context.AsyncSpanChunk)2 TIntStringValue (com.navercorp.pinpoint.thrift.dto.TIntStringValue)2 TLocalAsyncId (com.navercorp.pinpoint.thrift.dto.TLocalAsyncId)2