Fix no telemetry metrics when the oap role is receiver. (#5038)

This commit is contained in:
Ax1an 2020-07-06 18:50:14 +08:00 committed by GitHub
parent a3ae7b4dc6
commit 3df2e8ddce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 4 additions and 14 deletions

View File

@ -33,7 +33,6 @@ import org.apache.skywalking.oap.server.core.cluster.RemoteInstance;
import org.apache.skywalking.oap.server.core.cluster.ServiceRegisterException;
import org.apache.skywalking.oap.server.core.remote.client.Address;
import org.apache.skywalking.oap.server.library.util.CollectionUtils;
import org.apache.skywalking.oap.server.telemetry.api.TelemetryRelatedContext;
public class ConsulCoordinator implements ClusterRegister, ClusterNodesQuery {
@ -79,7 +78,6 @@ public class ConsulCoordinator implements ClusterRegister, ClusterNodesQuery {
AgentClient agentClient = client.agentClient();
this.selfAddress = remoteInstance.getAddress();
TelemetryRelatedContext.INSTANCE.setId(selfAddress.toString());
Registration registration = ImmutableRegistration.builder()
.id(remoteInstance.getAddress().toString())

View File

@ -31,7 +31,6 @@ import org.apache.skywalking.oap.server.core.cluster.ClusterRegister;
import org.apache.skywalking.oap.server.core.cluster.RemoteInstance;
import org.apache.skywalking.oap.server.core.remote.client.Address;
import org.apache.skywalking.oap.server.library.module.ModuleProvider;
import org.apache.skywalking.oap.server.telemetry.api.TelemetryRelatedContext;
import org.junit.Before;
import org.junit.Test;
import org.powermock.reflect.Whitebox;
@ -196,7 +195,6 @@ public class ITClusterModuleConsulProviderFunctionalTest {
Consul client = Whitebox.getInternalState(consulCoordinator, "client");
AgentClient agentClient = client.agentClient();
Whitebox.setInternalState(consulCoordinator, "selfAddress", remoteInstance.getAddress());
TelemetryRelatedContext.INSTANCE.setId(remoteInstance.getAddress().toString());
Registration registration = ImmutableRegistration.builder()
.id(remoteInstance.getAddress().toString())
.name(serviceName)

View File

@ -33,7 +33,6 @@ import org.apache.skywalking.oap.server.core.cluster.ClusterRegister;
import org.apache.skywalking.oap.server.core.cluster.RemoteInstance;
import org.apache.skywalking.oap.server.core.cluster.ServiceRegisterException;
import org.apache.skywalking.oap.server.core.remote.client.Address;
import org.apache.skywalking.oap.server.telemetry.api.TelemetryRelatedContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -93,7 +92,6 @@ public class EtcdCoordinator implements ClusterRegister, ClusterNodesQuery {
}
this.selfAddress = remoteInstance.getAddress();
TelemetryRelatedContext.INSTANCE.setId(selfAddress.toString());
EtcdEndpoint endpoint = new EtcdEndpoint.Builder().serviceName(serviceName)
.host(selfAddress.getHost())

View File

@ -33,7 +33,6 @@ import org.apache.skywalking.oap.server.core.cluster.ServiceRegisterException;
import org.apache.skywalking.oap.server.core.config.ConfigService;
import org.apache.skywalking.oap.server.core.remote.client.Address;
import org.apache.skywalking.oap.server.library.module.ModuleDefineHolder;
import org.apache.skywalking.oap.server.telemetry.api.TelemetryRelatedContext;
/**
* Read collector pod info from api-server of kubernetes, then using all containerIp list to construct the list of
@ -81,7 +80,6 @@ public class KubernetesCoordinator implements ClusterRegister, ClusterNodesQuery
@Override
public void registerRemote(final RemoteInstance remoteInstance) throws ServiceRegisterException {
this.port = remoteInstance.getAddress().getPort();
TelemetryRelatedContext.INSTANCE.setId(remoteInstance.toString());
}
private List<V1Pod> selfPod() {

View File

@ -23,7 +23,6 @@ import java.util.List;
import org.apache.skywalking.oap.server.core.cluster.ClusterNodesQuery;
import org.apache.skywalking.oap.server.core.cluster.ClusterRegister;
import org.apache.skywalking.oap.server.core.cluster.RemoteInstance;
import org.apache.skywalking.oap.server.telemetry.api.TelemetryRelatedContext;
/**
* A cluster manager simulator. Work in memory only. Also return the current instance.
@ -36,7 +35,6 @@ public class StandaloneManager implements ClusterNodesQuery, ClusterRegister {
public void registerRemote(RemoteInstance remoteInstance) {
this.remoteInstance = remoteInstance;
this.remoteInstance.getAddress().setSelf(true);
TelemetryRelatedContext.INSTANCE.setId("standalone");
}
@Override

View File

@ -30,7 +30,6 @@ import org.apache.skywalking.oap.server.core.cluster.ClusterRegister;
import org.apache.skywalking.oap.server.core.cluster.RemoteInstance;
import org.apache.skywalking.oap.server.core.cluster.ServiceRegisterException;
import org.apache.skywalking.oap.server.core.remote.client.Address;
import org.apache.skywalking.oap.server.telemetry.api.TelemetryRelatedContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -74,7 +73,6 @@ public class ZookeeperCoordinator implements ClusterRegister, ClusterNodesQuery
serviceDiscovery.registerService(thisInstance);
this.selfAddress = remoteInstance.getAddress();
TelemetryRelatedContext.INSTANCE.setId(selfAddress.toString());
} catch (Exception e) {
throw new ServiceRegisterException(e.getMessage());
}

View File

@ -92,6 +92,7 @@ import org.apache.skywalking.oap.server.library.server.grpc.GRPCServer;
import org.apache.skywalking.oap.server.library.server.jetty.JettyServer;
import org.apache.skywalking.oap.server.library.util.ResourceUtils;
import org.apache.skywalking.oap.server.telemetry.TelemetryModule;
import org.apache.skywalking.oap.server.telemetry.api.TelemetryRelatedContext;
/**
* Core module provider includes the recommended and default implementations of {@link CoreModule#services()}. All
@ -282,14 +283,15 @@ public class CoreModuleProvider extends ModuleProvider {
throw new ModuleStartException(e.getMessage(), e);
}
Address gRPCServerInstanceAddress = new Address(moduleConfig.getGRPCHost(), moduleConfig.getGRPCPort(), true);
TelemetryRelatedContext.INSTANCE.setId(gRPCServerInstanceAddress.toString());
if (CoreModuleConfig.Role.Mixed.name()
.equalsIgnoreCase(
moduleConfig.getRole())
|| CoreModuleConfig.Role.Aggregator.name()
.equalsIgnoreCase(
moduleConfig.getRole())) {
RemoteInstance gRPCServerInstance = new RemoteInstance(
new Address(moduleConfig.getGRPCHost(), moduleConfig.getGRPCPort(), true));
RemoteInstance gRPCServerInstance = new RemoteInstance(gRPCServerInstanceAddress);
this.getManager()
.find(ClusterModule.NAME)
.provider()