use of org.apache.skywalking.apm.collector.core.UnexpectedException in project incubator-skywalking by apache.
the class SegmentParse method preBuild.
@GraphComputingMetric(name = "/segment/parse/preBuild")
private boolean preBuild(List<UniqueId> traceIds, SegmentDecorator segmentDecorator) {
StringBuilder segmentIdBuilder = new StringBuilder();
for (int i = 0; i < segmentDecorator.getTraceSegmentId().getIdPartsList().size(); i++) {
if (i == 0) {
segmentIdBuilder.append(segmentDecorator.getTraceSegmentId().getIdPartsList().get(i));
} else {
segmentIdBuilder.append(".").append(segmentDecorator.getTraceSegmentId().getIdPartsList().get(i));
}
}
segmentId = segmentIdBuilder.toString();
for (UniqueId uniqueId : traceIds) {
notifyGlobalsListener(uniqueId);
}
int applicationId = segmentDecorator.getApplicationId();
int applicationInstanceId = segmentDecorator.getApplicationInstanceId();
int entrySpanCount = 0;
for (int i = 0; i < segmentDecorator.getSpansCount(); i++) {
SpanDecorator spanDecorator = segmentDecorator.getSpans(i);
if (!SpanIdExchanger.getInstance(moduleManager).exchange(spanDecorator, applicationId)) {
return false;
} else {
for (int j = 0; j < spanDecorator.getRefsCount(); j++) {
ReferenceDecorator referenceDecorator = spanDecorator.getRefs(j);
if (!ReferenceIdExchanger.getInstance(moduleManager).exchange(referenceDecorator, applicationId)) {
return false;
}
}
}
if (SpanType.Entry.equals(spanDecorator.getSpanType())) {
entrySpanCount++;
}
if (entrySpanCount > 1) {
throw new UnexpectedException("This segment contains multiple entry span.");
}
}
for (int i = 0; i < segmentDecorator.getSpansCount(); i++) {
SpanDecorator spanDecorator = segmentDecorator.getSpans(i);
if (spanDecorator.getSpanId() == 0) {
notifyFirstListener(spanDecorator, applicationId, applicationInstanceId, segmentId);
timeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(spanDecorator.getStartTime());
}
if (SpanType.Exit.equals(spanDecorator.getSpanType())) {
notifyExitListener(spanDecorator, applicationId, applicationInstanceId, segmentId);
} else if (SpanType.Entry.equals(spanDecorator.getSpanType())) {
notifyEntryListener(spanDecorator, applicationId, applicationInstanceId, segmentId);
} else if (SpanType.Local.equals(spanDecorator.getSpanType())) {
notifyLocalListener(spanDecorator, applicationId, applicationInstanceId, segmentId);
} else {
logger.error("span type value was unexpected, span type name: {}", spanDecorator.getSpanType().name());
}
}
return true;
}
use of org.apache.skywalking.apm.collector.core.UnexpectedException in project incubator-skywalking by apache.
the class TraceQuery method queryBasicTraces.
public TraceBrief queryBasicTraces(TraceQueryCondition condition) throws ParseException {
long startSecondTimeBucket = 0;
long endSecondTimeBucket = 0;
String traceId = Const.EMPTY_STRING;
if (StringUtils.isNotEmpty(condition.getTraceId())) {
traceId = condition.getTraceId();
} else if (ObjectUtils.isNotEmpty(condition.getQueryDuration())) {
startSecondTimeBucket = DurationUtils.INSTANCE.startTimeDurationToSecondTimeBucket(condition.getQueryDuration().getStep(), condition.getQueryDuration().getStart());
endSecondTimeBucket = DurationUtils.INSTANCE.endTimeDurationToSecondTimeBucket(condition.getQueryDuration().getStep(), condition.getQueryDuration().getEnd());
} else {
throw new UnexpectedException("The condition must contains either queryDuration or traceId.");
}
long minDuration = condition.getMinTraceDuration();
long maxDuration = condition.getMaxTraceDuration();
String operationName = condition.getOperationName();
int applicationId = condition.getApplicationId();
PaginationUtils.Page page = PaginationUtils.INSTANCE.exchange(condition.getPaging());
return getSegmentTopService().loadTop(startSecondTimeBucket, endSecondTimeBucket, minDuration, maxDuration, operationName, traceId, applicationId, page.getLimit(), page.getFrom());
}
Aggregations