未验证 提交 de81e211 编写于 作者: wu-sheng's avatar wu-sheng 提交者: GitHub

Merge pull request #881 from ascrutae/fix/entry-span-issue

[Agent] fix create entry span failure
...@@ -248,35 +248,33 @@ public class TracingContext implements AbstractTracerContext { ...@@ -248,35 +248,33 @@ public class TracingContext implements AbstractTracerContext {
AbstractSpan entrySpan; AbstractSpan entrySpan;
final AbstractSpan parentSpan = peek(); final AbstractSpan parentSpan = peek();
final int parentSpanId = parentSpan == null ? -1 : parentSpan.getSpanId(); final int parentSpanId = parentSpan == null ? -1 : parentSpan.getSpanId();
if (parentSpan == null) { if (parentSpan != null && parentSpan.isEntry()) {
entrySpan = (AbstractTracingSpan)DictionaryManager.findOperationNameCodeSection() entrySpan = (AbstractTracingSpan)DictionaryManager.findOperationNameCodeSection()
.findOnly(segment.getApplicationId(), operationName) .findOnly(segment.getApplicationId(), operationName)
.doInCondition(new PossibleFound.FoundAndObtain() { .doInCondition(new PossibleFound.FoundAndObtain() {
@Override public Object doProcess(int operationId) { @Override public Object doProcess(int operationId) {
return new EntrySpan(spanIdGenerator++, parentSpanId, operationId); return parentSpan.setOperationId(operationId);
} }
}, new PossibleFound.NotFoundAndObtain() { }, new PossibleFound.NotFoundAndObtain() {
@Override public Object doProcess() { @Override public Object doProcess() {
return new EntrySpan(spanIdGenerator++, parentSpanId, operationName); return parentSpan.setOperationName(operationName);
} }
}); });
entrySpan.start(); return entrySpan.start();
return push(entrySpan); } else {
} else if (parentSpan.isEntry()) {
entrySpan = (AbstractTracingSpan)DictionaryManager.findOperationNameCodeSection() entrySpan = (AbstractTracingSpan)DictionaryManager.findOperationNameCodeSection()
.findOnly(segment.getApplicationId(), operationName) .findOnly(segment.getApplicationId(), operationName)
.doInCondition(new PossibleFound.FoundAndObtain() { .doInCondition(new PossibleFound.FoundAndObtain() {
@Override public Object doProcess(int operationId) { @Override public Object doProcess(int operationId) {
return parentSpan.setOperationId(operationId); return new EntrySpan(spanIdGenerator++, parentSpanId, operationId);
} }
}, new PossibleFound.NotFoundAndObtain() { }, new PossibleFound.NotFoundAndObtain() {
@Override public Object doProcess() { @Override public Object doProcess() {
return parentSpan.setOperationName(operationName); return new EntrySpan(spanIdGenerator++, parentSpanId, operationName);
} }
}); });
return entrySpan.start(); entrySpan.start();
} else { return push(entrySpan);
throw new IllegalStateException("The Entry Span can't be the child of Non-Entry Span");
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册