Add a new field for operation register.
This commit is contained in:
parent
75be8c879f
commit
ca11058f8e
|
|
@ -0,0 +1,10 @@
|
|||
syntax = "proto3";
|
||||
|
||||
option java_multiple_files = true;
|
||||
option java_package = "org.apache.skywalking.apm.network.proto";
|
||||
|
||||
enum SpanType {
|
||||
Entry = 0;
|
||||
Exit = 1;
|
||||
Local = 2;
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ syntax = "proto3";
|
|||
option java_multiple_files = true;
|
||||
option java_package = "org.apache.skywalking.apm.network.proto";
|
||||
|
||||
import "Common.proto";
|
||||
import "Downstream.proto";
|
||||
|
||||
service InstanceDiscoveryService {
|
||||
|
|
@ -67,4 +68,5 @@ message ServiceNameMappingElement {
|
|||
message ServiceNameElement {
|
||||
string serviceName = 1;
|
||||
int32 applicationId = 2;
|
||||
SpanType srcSpanType = 3;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ syntax = "proto3";
|
|||
option java_multiple_files = true;
|
||||
option java_package = "org.apache.skywalking.apm.network.proto";
|
||||
|
||||
import "Common.proto";
|
||||
import "Downstream.proto";
|
||||
import "KeyWithStringValue.proto";
|
||||
|
||||
|
|
@ -66,12 +67,6 @@ enum RefType {
|
|||
CrossThread = 1;
|
||||
}
|
||||
|
||||
enum SpanType {
|
||||
Entry = 0;
|
||||
Exit = 1;
|
||||
Local = 2;
|
||||
}
|
||||
|
||||
enum SpanLayer {
|
||||
Unknown = 0;
|
||||
Database = 1;
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ public class TracingContext implements AbstractTracerContext {
|
|||
AbstractSpan parentSpan = peek();
|
||||
final int parentSpanId = parentSpan == null ? -1 : parentSpan.getSpanId();
|
||||
AbstractTracingSpan span = (AbstractTracingSpan)DictionaryManager.findOperationNameCodeSection()
|
||||
.findOrPrepare4Register(segment.getApplicationId(), operationName)
|
||||
.findOrPrepare4Register(segment.getApplicationId(), operationName, false, false)
|
||||
.doInCondition(new PossibleFound.FoundAndObtain() {
|
||||
@Override
|
||||
public Object doProcess(int operationId) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.agent.core.context.trace;
|
||||
|
||||
import org.apache.skywalking.apm.agent.core.dictionary.DictionaryManager;
|
||||
|
|
@ -48,7 +47,7 @@ public abstract class StackBasedTracingSpan extends AbstractTracingSpan {
|
|||
if (--stackDepth == 0) {
|
||||
if (this.operationId == DictionaryUtil.nullValue()) {
|
||||
this.operationId = (Integer)DictionaryManager.findOperationNameCodeSection()
|
||||
.findOrPrepare4Register(owner.getApplicationId(), operationName)
|
||||
.findOrPrepare4Register(owner.getApplicationId(), operationName, this.isEntry(), this.isExit())
|
||||
.doInCondition(
|
||||
new PossibleFound.FoundAndObtain() {
|
||||
@Override public Object doProcess(int value) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.agent.core.dictionary;
|
||||
|
||||
import io.netty.util.internal.ConcurrentSet;
|
||||
|
|
@ -28,6 +27,7 @@ import org.apache.skywalking.apm.network.proto.ServiceNameDiscoveryServiceGrpc;
|
|||
import org.apache.skywalking.apm.network.proto.ServiceNameElement;
|
||||
import org.apache.skywalking.apm.network.proto.ServiceNameMappingCollection;
|
||||
import org.apache.skywalking.apm.network.proto.ServiceNameMappingElement;
|
||||
import org.apache.skywalking.apm.network.proto.SpanType;
|
||||
|
||||
import static org.apache.skywalking.apm.agent.core.conf.Config.Dictionary.OPERATION_NAME_BUFFER_SIZE;
|
||||
|
||||
|
|
@ -39,19 +39,21 @@ public enum OperationNameDictionary {
|
|||
private Map<OperationNameKey, Integer> operationNameDictionary = new ConcurrentHashMap<OperationNameKey, Integer>();
|
||||
private Set<OperationNameKey> unRegisterOperationNames = new ConcurrentSet<OperationNameKey>();
|
||||
|
||||
public PossibleFound findOrPrepare4Register(int applicationId, String operationName) {
|
||||
return find0(applicationId, operationName, true);
|
||||
public PossibleFound findOrPrepare4Register(int applicationId, String operationName,
|
||||
boolean isEntry, boolean isExit) {
|
||||
return find0(applicationId, operationName, isEntry, isExit, true);
|
||||
}
|
||||
|
||||
public PossibleFound findOnly(int applicationId, String operationName) {
|
||||
return find0(applicationId, operationName, false);
|
||||
return find0(applicationId, operationName, false, false, false);
|
||||
}
|
||||
|
||||
private PossibleFound find0(int applicationId, String operationName, boolean registerWhenNotFound) {
|
||||
private PossibleFound find0(int applicationId, String operationName,
|
||||
boolean isEntry, boolean isExit, boolean registerWhenNotFound) {
|
||||
if (operationName == null || operationName.length() == 0) {
|
||||
return new NotFound();
|
||||
}
|
||||
OperationNameKey key = new OperationNameKey(applicationId, operationName);
|
||||
OperationNameKey key = new OperationNameKey(applicationId, operationName, isEntry, isExit);
|
||||
Integer operationId = operationNameDictionary.get(key);
|
||||
if (operationId != null) {
|
||||
return new Found(operationId);
|
||||
|
|
@ -78,9 +80,12 @@ public enum OperationNameDictionary {
|
|||
ServiceNameMappingCollection serviceNameMappingCollection = serviceNameDiscoveryServiceBlockingStub.discovery(builder.build());
|
||||
if (serviceNameMappingCollection.getElementsCount() > 0) {
|
||||
for (ServiceNameMappingElement serviceNameMappingElement : serviceNameMappingCollection.getElementsList()) {
|
||||
ServiceNameElement element = serviceNameMappingElement.getElement();
|
||||
OperationNameKey key = new OperationNameKey(
|
||||
serviceNameMappingElement.getElement().getApplicationId(),
|
||||
serviceNameMappingElement.getElement().getServiceName());
|
||||
element.getApplicationId(),
|
||||
element.getServiceName(),
|
||||
SpanType.Entry.equals(element.getSrcSpanType()),
|
||||
SpanType.Exit.equals(element.getSrcSpanType()));
|
||||
unRegisterOperationNames.remove(key);
|
||||
operationNameDictionary.put(key, serviceNameMappingElement.getServiceId());
|
||||
}
|
||||
|
|
@ -91,10 +96,14 @@ public enum OperationNameDictionary {
|
|||
private class OperationNameKey {
|
||||
private int applicationId;
|
||||
private String operationName;
|
||||
private boolean isEntry;
|
||||
private boolean isExit;
|
||||
|
||||
public OperationNameKey(int applicationId, String operationName) {
|
||||
public OperationNameKey(int applicationId, String operationName, boolean isEntry, boolean isExit) {
|
||||
this.applicationId = applicationId;
|
||||
this.operationName = operationName;
|
||||
this.isEntry = isEntry;
|
||||
this.isExit = isExit;
|
||||
}
|
||||
|
||||
public int getApplicationId() {
|
||||
|
|
@ -123,5 +132,13 @@ public enum OperationNameDictionary {
|
|||
result = 31 * result + operationName.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
boolean isEntry() {
|
||||
return isEntry;
|
||||
}
|
||||
|
||||
boolean isExit() {
|
||||
return isExit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue