use of org.apache.skywalking.apm.agent.core.context.trace.NoopSpan in project incubator-skywalking by apache.
the class TracingContext method createLocalSpan.
/**
* Create a local span
*
* @param operationName most likely a local method signature, or business name.
* @return the span represents a local logic block.
* Ref to {@link LocalSpan}
*/
@Override
public AbstractSpan createLocalSpan(final String operationName) {
if (isLimitMechanismWorking()) {
NoopSpan span = new NoopSpan();
return push(span);
}
AbstractSpan parentSpan = peek();
final int parentSpanId = parentSpan == null ? -1 : parentSpan.getSpanId();
AbstractTracingSpan span = (AbstractTracingSpan) DictionaryManager.findOperationNameCodeSection().findOrPrepare4Register(segment.getApplicationId(), operationName, false, false).doInCondition(new PossibleFound.FoundAndObtain() {
@Override
public Object doProcess(int operationId) {
return new LocalSpan(spanIdGenerator++, parentSpanId, operationId);
}
}, new PossibleFound.NotFoundAndObtain() {
@Override
public Object doProcess() {
return new LocalSpan(spanIdGenerator++, parentSpanId, operationName);
}
});
span.start();
return push(span);
}
use of org.apache.skywalking.apm.agent.core.context.trace.NoopSpan in project incubator-skywalking by apache.
the class TracingContext method createEntrySpan.
/**
* Create an entry span
*
* @param operationName most likely a service name
* @return span instance.
* Ref to {@link EntrySpan}
*/
@Override
public AbstractSpan createEntrySpan(final String operationName) {
if (isLimitMechanismWorking()) {
NoopSpan span = new NoopSpan();
return push(span);
}
AbstractSpan entrySpan;
final AbstractSpan parentSpan = peek();
final int parentSpanId = parentSpan == null ? -1 : parentSpan.getSpanId();
if (parentSpan != null && parentSpan.isEntry()) {
entrySpan = (AbstractTracingSpan) DictionaryManager.findOperationNameCodeSection().findOnly(segment.getApplicationId(), operationName).doInCondition(new PossibleFound.FoundAndObtain() {
@Override
public Object doProcess(int operationId) {
return parentSpan.setOperationId(operationId);
}
}, new PossibleFound.NotFoundAndObtain() {
@Override
public Object doProcess() {
return parentSpan.setOperationName(operationName);
}
});
return entrySpan.start();
} else {
entrySpan = (AbstractTracingSpan) DictionaryManager.findOperationNameCodeSection().findOnly(segment.getApplicationId(), operationName).doInCondition(new PossibleFound.FoundAndObtain() {
@Override
public Object doProcess(int operationId) {
return new EntrySpan(spanIdGenerator++, parentSpanId, operationId);
}
}, new PossibleFound.NotFoundAndObtain() {
@Override
public Object doProcess() {
return new EntrySpan(spanIdGenerator++, parentSpanId, operationName);
}
});
entrySpan.start();
return push(entrySpan);
}
}
Aggregations