add instance id configuration item (#2328)
* add instance id configuration item * add doc about instance uuid
This commit is contained in:
parent
bf242d7529
commit
885ae479e0
|
|
@ -80,6 +80,11 @@ public class Config {
|
|||
* Deactive V1 header in default
|
||||
*/
|
||||
public static boolean ACTIVE_V1_HEADER = false;
|
||||
|
||||
/**
|
||||
* The identify of the instance
|
||||
*/
|
||||
public static String INSTANCE_UUID = "";
|
||||
}
|
||||
|
||||
public static class Collector {
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ import org.apache.skywalking.apm.network.register.v2.ServiceInstances;
|
|||
import org.apache.skywalking.apm.network.register.v2.ServiceRegisterMapping;
|
||||
import org.apache.skywalking.apm.network.register.v2.Services;
|
||||
import org.apache.skywalking.apm.util.RunnableWithExceptionProtection;
|
||||
import org.apache.skywalking.apm.util.StringUtil;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
|
|
@ -53,7 +54,7 @@ import org.apache.skywalking.apm.util.RunnableWithExceptionProtection;
|
|||
@DefaultImplementor
|
||||
public class ServiceAndEndpointRegisterClient implements BootService, Runnable, GRPCChannelListener {
|
||||
private static final ILog logger = LogManager.getLogger(ServiceAndEndpointRegisterClient.class);
|
||||
private static final String PROCESS_UUID = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
private static String INSTANCE_UUID;
|
||||
|
||||
private volatile GRPCChannelStatus status = GRPCChannelStatus.DISCONNECT;
|
||||
private volatile RegisterGrpc.RegisterBlockingStub registerBlockingStub;
|
||||
|
|
@ -76,6 +77,9 @@ public class ServiceAndEndpointRegisterClient implements BootService, Runnable,
|
|||
@Override
|
||||
public void prepare() throws Throwable {
|
||||
ServiceManager.INSTANCE.findService(GRPCChannelManager.class).addChannelListener(this);
|
||||
|
||||
INSTANCE_UUID = StringUtil.isEmpty(Config.Agent.INSTANCE_UUID) ? UUID.randomUUID().toString()
|
||||
.replaceAll("-", "") : Config.Agent.INSTANCE_UUID;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -127,12 +131,12 @@ public class ServiceAndEndpointRegisterClient implements BootService, Runnable,
|
|||
.addInstances(
|
||||
ServiceInstance.newBuilder()
|
||||
.setServiceId(RemoteDownstreamConfig.Agent.SERVICE_ID)
|
||||
.setInstanceUUID(PROCESS_UUID)
|
||||
.setInstanceUUID(INSTANCE_UUID)
|
||||
.setTime(System.currentTimeMillis())
|
||||
.addAllProperties(OSUtil.buildOSInfo())
|
||||
).build());
|
||||
for (KeyIntValuePair serviceInstance : instanceMapping.getServiceInstancesList()) {
|
||||
if (PROCESS_UUID.equals(serviceInstance.getKey())) {
|
||||
if (INSTANCE_UUID.equals(serviceInstance.getKey())) {
|
||||
int serviceInstanceId = serviceInstance.getValue();
|
||||
if (serviceInstanceId != DictionaryUtil.nullValue()) {
|
||||
RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID = serviceInstanceId;
|
||||
|
|
@ -143,7 +147,7 @@ public class ServiceAndEndpointRegisterClient implements BootService, Runnable,
|
|||
serviceInstancePingStub.doPing(ServiceInstancePingPkg.newBuilder()
|
||||
.setServiceInstanceId(RemoteDownstreamConfig.Agent.SERVICE_INSTANCE_ID)
|
||||
.setTime(System.currentTimeMillis())
|
||||
.setServiceInstanceUUID(PROCESS_UUID)
|
||||
.setServiceInstanceUUID(INSTANCE_UUID)
|
||||
.build());
|
||||
|
||||
NetworkAddressDictionary.INSTANCE.syncRemoteDictionary(registerBlockingStub);
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ property key | Description | Default |
|
|||
`agent.ignore_suffix`|If the operation name of the first span is included in this set, this segment should be ignored.|Not set|
|
||||
`agent.is_open_debugging_class`|If true, skywalking agent will save all instrumented classes files in `/debugging` folder.Skywalking team may ask for these files in order to resolve compatible problem.|Not set|
|
||||
`agent.active_v2_header`|Active V2 header in default.|`true`|
|
||||
`agent.instance_uuid` |Instance uuid is the identity of an instance, skywalking treat same instance uuid as one instance.if empty, skywalking agent will generate an 32-bit uuid. |`""`|
|
||||
`agent.active_v1_header `|Deactive V1 header in default.|`false`|
|
||||
`collector.grpc_channel_check_interval`|grpc channel status check interval.|`30`|
|
||||
`collector.app_and_service_register_check_interval`|application and service registry check interval.|`3`|
|
||||
|
|
|
|||
Loading…
Reference in New Issue