Optimize the entry span’s operationName.
This commit is contained in:
parent
786263cc0a
commit
b67ad99c26
|
|
@ -202,7 +202,7 @@ public class TracingContext implements AbstractTracerContext {
|
|||
final int parentSpanId = parentSpan == null ? -1 : parentSpan.getSpanId();
|
||||
if (parentSpan == null) {
|
||||
entrySpan = (AbstractTracingSpan)DictionaryManager.findOperationNameCodeSection()
|
||||
.find(segment.getApplicationId(), operationName)
|
||||
.findOnly(segment.getApplicationId(), operationName)
|
||||
.doInCondition(new PossibleFound.FoundAndObtain() {
|
||||
@Override public Object doProcess(int operationId) {
|
||||
return new EntrySpan(spanIdGenerator++, parentSpanId, operationId);
|
||||
|
|
@ -216,7 +216,7 @@ public class TracingContext implements AbstractTracerContext {
|
|||
return push(entrySpan);
|
||||
} else if (parentSpan.isEntry()) {
|
||||
entrySpan = (AbstractTracingSpan)DictionaryManager.findOperationNameCodeSection()
|
||||
.find(segment.getApplicationId(), operationName)
|
||||
.findOnly(segment.getApplicationId(), operationName)
|
||||
.doInCondition(new PossibleFound.FoundAndObtain() {
|
||||
@Override public Object doProcess(int operationId) {
|
||||
return parentSpan.setOperationId(operationId);
|
||||
|
|
@ -244,7 +244,7 @@ public class TracingContext implements AbstractTracerContext {
|
|||
AbstractTracingSpan parentSpan = peek();
|
||||
final int parentSpanId = parentSpan == null ? -1 : parentSpan.getSpanId();
|
||||
AbstractTracingSpan span = (AbstractTracingSpan)DictionaryManager.findOperationNameCodeSection()
|
||||
.find(segment.getApplicationId(), operationName)
|
||||
.findOrPrepare4Register(segment.getApplicationId(), operationName)
|
||||
.doInCondition(new PossibleFound.FoundAndObtain() {
|
||||
@Override
|
||||
public Object doProcess(int operationId) {
|
||||
|
|
@ -282,7 +282,7 @@ public class TracingContext implements AbstractTracerContext {
|
|||
@Override
|
||||
public Object doProcess(final int applicationId) {
|
||||
return DictionaryManager.findOperationNameCodeSection()
|
||||
.find(applicationId, operationName)
|
||||
.findOrPrepare4Register(applicationId, operationName)
|
||||
.doInCondition(
|
||||
new PossibleFound.FoundAndObtain() {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package org.skywalking.apm.agent.core.context.trace;
|
||||
|
||||
import org.skywalking.apm.agent.core.dictionary.DictionaryManager;
|
||||
import org.skywalking.apm.agent.core.dictionary.DictionaryUtil;
|
||||
import org.skywalking.apm.agent.core.dictionary.PossibleFound;
|
||||
import org.skywalking.apm.network.trace.component.Component;
|
||||
|
||||
/**
|
||||
|
|
@ -82,6 +84,22 @@ public class EntrySpan extends AbstractTracingSpan {
|
|||
@Override
|
||||
public boolean finish(TraceSegment owner) {
|
||||
if (--stackDepth == 0) {
|
||||
if (this.operationId == DictionaryUtil.nullValue()) {
|
||||
this.operationId = (Integer)DictionaryManager.findOperationNameCodeSection()
|
||||
.findOrPrepare4Register(owner.getApplicationId(), operationName)
|
||||
.doInCondition(
|
||||
new PossibleFound.FoundAndObtain() {
|
||||
@Override public Object doProcess(int value) {
|
||||
return value;
|
||||
}
|
||||
},
|
||||
new PossibleFound.NotFoundAndObtain() {
|
||||
@Override public Object doProcess() {
|
||||
return DictionaryUtil.nullValue();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return super.finish(owner);
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,15 @@ public enum OperationNameDictionary {
|
|||
private Map<OperationNameKey, Integer> operationNameDictionary = new ConcurrentHashMap<OperationNameKey, Integer>();
|
||||
private Set<OperationNameKey> unRegisterOperationNames = new ConcurrentSet<OperationNameKey>();
|
||||
|
||||
public PossibleFound find(int applicationId, String operationName) {
|
||||
public PossibleFound findOrPrepare4Register(int applicationId, String operationName) {
|
||||
return find0(applicationId, operationName, true);
|
||||
}
|
||||
|
||||
public PossibleFound findOnly(int applicationId, String operationName) {
|
||||
return find0(applicationId, operationName, false);
|
||||
}
|
||||
|
||||
private PossibleFound find0(int applicationId, String operationName, boolean registerWhenNotFound) {
|
||||
if (operationName == null || operationName.length() == 0) {
|
||||
return new NotFound();
|
||||
}
|
||||
|
|
@ -29,7 +37,8 @@ public enum OperationNameDictionary {
|
|||
if (operationId != null) {
|
||||
return new Found(applicationId);
|
||||
} else {
|
||||
if (operationNameDictionary.size() + unRegisterOperationNames.size() < OPERATION_NAME_BUFFER_SIZE) {
|
||||
if (registerWhenNotFound &&
|
||||
operationNameDictionary.size() + unRegisterOperationNames.size() < OPERATION_NAME_BUFFER_SIZE) {
|
||||
unRegisterOperationNames.add(key);
|
||||
}
|
||||
return new NotFound();
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public abstract class AbstractClassEnhancePluginDefine {
|
|||
logger.debug("prepare to enhance class {} by {}.", transformClassName, interceptorDefineClassName);
|
||||
|
||||
/**
|
||||
* find witness classes for enhance class
|
||||
* findOrPrepare4Register witness classes for enhance class
|
||||
*/
|
||||
String[] witnessClasses = witnessClasses();
|
||||
if (witnessClasses != null) {
|
||||
|
|
@ -51,7 +51,7 @@ public abstract class AbstractClassEnhancePluginDefine {
|
|||
}
|
||||
|
||||
/**
|
||||
* find origin class source code for interceptor
|
||||
* findOrPrepare4Register origin class source code for interceptor
|
||||
*/
|
||||
DynamicType.Builder<?> newClassBuilder = this.enhance(transformClassName, builder, classLoader);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import static net.bytebuddy.matcher.ElementMatchers.isInterface;
|
|||
import static net.bytebuddy.matcher.ElementMatchers.not;
|
||||
|
||||
/**
|
||||
* The <code>PluginFinder</code> represents a finder , which assist to find the one
|
||||
* The <code>PluginFinder</code> represents a finder , which assist to findOrPrepare4Register the one
|
||||
* from the given {@link AbstractClassEnhancePluginDefine} list.
|
||||
*
|
||||
* @author wusheng
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ public class PluginResourcesResolver {
|
|||
while (urls.hasMoreElements()) {
|
||||
URL pluginUrl = urls.nextElement();
|
||||
cfgUrlPaths.add(pluginUrl);
|
||||
logger.info("find skywalking plugin define in {}", pluginUrl);
|
||||
logger.info("findOrPrepare4Register skywalking plugin define in {}", pluginUrl);
|
||||
}
|
||||
|
||||
return cfgUrlPaths;
|
||||
|
|
@ -42,7 +42,7 @@ public class PluginResourcesResolver {
|
|||
* First get current thread's classloader,
|
||||
* if fail, get {@link PluginResourcesResolver}'s classloader.
|
||||
*
|
||||
* @return the classloader to find plugin definitions.
|
||||
* @return the classloader to findOrPrepare4Register plugin definitions.
|
||||
*/
|
||||
private ClassLoader getDefaultClassLoader() {
|
||||
ClassLoader cl = null;
|
||||
|
|
|
|||
Loading…
Reference in New Issue