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

Support ref endpoint name register (#4422)

上级 b28c7d72
...@@ -69,8 +69,8 @@ public class EndpointInventoryRegister implements IEndpointInventoryRegister { ...@@ -69,8 +69,8 @@ public class EndpointInventoryRegister implements IEndpointInventoryRegister {
} }
@Override @Override
public int get(int serviceId, String endpointName, int detectPoint) { public int get(int serviceId, String endpointName, DetectPoint detectPoint) {
return getCacheService().getEndpointId(serviceId, endpointName, detectPoint); return getCacheService().getEndpointId(serviceId, endpointName, detectPoint.ordinal());
} }
@Override @Override
......
...@@ -25,7 +25,7 @@ public interface IEndpointInventoryRegister extends Service { ...@@ -25,7 +25,7 @@ public interface IEndpointInventoryRegister extends Service {
int getOrCreate(int serviceId, String endpointName, DetectPoint detectPoint); int getOrCreate(int serviceId, String endpointName, DetectPoint detectPoint);
int get(int serviceId, String endpointName, int detectPoint); int get(int serviceId, String endpointName, DetectPoint detectPoint);
void heartbeat(int endpointId, long heartBeatTime); void heartbeat(int endpointId, long heartBeatTime);
} }
...@@ -139,29 +139,19 @@ public class ReferenceIdExchanger implements IdExchanger<ReferenceDecorator> { ...@@ -139,29 +139,19 @@ public class ReferenceIdExchanger implements IdExchanger<ReferenceDecorator> {
standardBuilder.setNetworkAddressId(networkAddressId); standardBuilder.setNetworkAddressId(networkAddressId);
standardBuilder.setNetworkAddress(Const.EMPTY_STRING); standardBuilder.setNetworkAddress(Const.EMPTY_STRING);
} }
} else {
/**
* Since 6.6.0, endpoint id could be -1, as it is not an endpoint. Such as local span and exist span.
*/
} }
return exchanged; return exchanged;
} }
/** /**
* Endpoint in ref could be local or exit span's operation name. Especially if it is local span operation name, * @since 6.6.0 The endpoint in the ref should be server endpoint only. The agent will/should use `-1`, when it can't
* exchange may not happen at agent, such as Java agent, then put literal endpoint string in the header, Need to try * find the endpoint of entry span in the current tracing context when build the ref.
* to get the id by assuming the endpoint name is detected at server, local or client. * @since 5.0 Endpoint in ref could be local or exit span's operation name. Especially if it is local span operation
* <p> * name, * exchange may not happen at agent, such as Java agent, then put literal endpoint string in the header,
* If agent does the exchange, then always use endpoint id. * Need to try * to get the id by assuming the endpoint name is detected at server, local or client. * <p> * If
* agent does the exchange, then always use endpoint id.
*/ */
private int getEndpointId(int serviceId, String endpointName) { private int getEndpointId(int serviceId, String endpointName) {
int endpointId = endpointInventoryRegister.get(serviceId, endpointName, DetectPoint.SERVER.ordinal()); return endpointInventoryRegister.getOrCreate(serviceId, endpointName, DetectPoint.SERVER);
if (endpointId == Const.NONE) {
endpointId = endpointInventoryRegister.get(serviceId, endpointName, DetectPoint.CLIENT.ordinal());
if (endpointId == Const.NONE) {
endpointId = endpointInventoryRegister.get(serviceId, endpointName, DetectPoint.UNRECOGNIZED.ordinal());
}
}
return endpointId;
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册