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;
}
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;
}
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);
}
}
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;
}
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;
}
});
}
Aggregations