Merge pull request #290 from ascrutae/zhangxin/fix/peer_id_set_failured
add configuration and fix set peerID failed
This commit is contained in:
commit
1b5cd9e253
|
|
@ -34,7 +34,18 @@ public class Config {
|
|||
}
|
||||
|
||||
public static class Collector {
|
||||
public static long DISCOVERY_CHECK_INTERVAL = 60 * 1000;
|
||||
/**
|
||||
* grpc channel status check interval
|
||||
*/
|
||||
public static long GRPC_CHANNEL_CHECK_INTERVAL = 30;
|
||||
/**
|
||||
* application and service registry check interval
|
||||
*/
|
||||
public static long APP_AND_SERVICE_REGISTER_CHECK_INTERVAL = 10;
|
||||
/**
|
||||
* discovery rest check interval
|
||||
*/
|
||||
public static long DISCOVERY_CHECK_INTERVAL = 60;
|
||||
/**
|
||||
* Collector REST-Service address.
|
||||
* e.g.
|
||||
|
|
@ -46,7 +57,7 @@ public class Config {
|
|||
/**
|
||||
* Collector service discovery REST service name
|
||||
*/
|
||||
public static String DISCOVERY_SERVICE_NAME = "grpc/addresses";
|
||||
public static String DISCOVERY_SERVICE_NAME = "/grpc/addresses";
|
||||
}
|
||||
|
||||
public static class Buffer {
|
||||
|
|
|
|||
|
|
@ -108,10 +108,12 @@ public class ExitSpan extends AbstractTracingSpan {
|
|||
|
||||
@Override public SpanObject.Builder transform() {
|
||||
SpanObject.Builder spanBuilder = super.transform();
|
||||
if (peerId == DictionaryUtil.nullValue()) {
|
||||
if (peerId != DictionaryUtil.nullValue()) {
|
||||
spanBuilder.setPeerId(peerId);
|
||||
} else {
|
||||
spanBuilder.setPeer(peer);
|
||||
if (peer != null) {
|
||||
spanBuilder.setPeer(peer);
|
||||
}
|
||||
}
|
||||
return spanBuilder;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public class AppAndServiceRegisterClient implements BootService, GRPCChannelList
|
|||
public void boot() throws Throwable {
|
||||
applicationRegisterFuture = Executors
|
||||
.newSingleThreadScheduledExecutor()
|
||||
.scheduleAtFixedRate(this, 0, 10, TimeUnit.SECONDS);
|
||||
.scheduleAtFixedRate(this, 0, Config.Collector.APP_AND_SERVICE_REGISTER_CHECK_INTERVAL, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public class CollectorDiscoveryService implements BootService {
|
|||
public void boot() throws Throwable {
|
||||
Executors.newSingleThreadScheduledExecutor()
|
||||
.scheduleAtFixedRate(new DiscoveryRestServiceClient(), 0,
|
||||
Config.Collector.DISCOVERY_CHECK_INTERVAL, TimeUnit.MILLISECONDS);
|
||||
Config.Collector.DISCOVERY_CHECK_INTERVAL, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ import org.skywalking.apm.agent.core.conf.RemoteDownstreamConfig;
|
|||
import org.skywalking.apm.logging.ILog;
|
||||
import org.skywalking.apm.logging.LogManager;
|
||||
|
||||
import static org.skywalking.apm.agent.core.conf.Config.Collector.GRPC_CHANNEL_CHECK_INTERVAL;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
|
|
@ -29,7 +31,6 @@ public class GRPCChannelManager implements BootService, Runnable {
|
|||
private volatile boolean reconnect = true;
|
||||
private Random random = new Random();
|
||||
private List<GRPCChannelListener> listeners = Collections.synchronizedList(new LinkedList<GRPCChannelListener>());
|
||||
private final int retryCycle = 30;
|
||||
|
||||
@Override
|
||||
public void beforeBoot() throws Throwable {
|
||||
|
|
@ -40,7 +41,7 @@ public class GRPCChannelManager implements BootService, Runnable {
|
|||
public void boot() throws Throwable {
|
||||
connectCheckFuture = Executors
|
||||
.newSingleThreadScheduledExecutor()
|
||||
.scheduleAtFixedRate(this, 0, retryCycle, TimeUnit.SECONDS);
|
||||
.scheduleAtFixedRate(this, 0, GRPC_CHANNEL_CHECK_INTERVAL, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -75,7 +76,7 @@ public class GRPCChannelManager implements BootService, Runnable {
|
|||
}
|
||||
}
|
||||
|
||||
logger.debug("Selected collector grpc service is not available. Wait {} seconds to retry", retryCycle);
|
||||
logger.debug("Selected collector grpc service is not available. Wait {} seconds to retry", GRPC_CHANNEL_CHECK_INTERVAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import org.mockito.Spy;
|
|||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.reflect.Whitebox;
|
||||
import org.skywalking.apm.agent.core.conf.Config;
|
||||
import org.skywalking.apm.agent.core.conf.RemoteDownstreamConfig;
|
||||
import org.skywalking.apm.agent.core.test.tools.AgentServiceRule;
|
||||
|
||||
|
|
@ -52,7 +53,7 @@ public class GRPCChannelManagerTest {
|
|||
List<String> grpcServers = new ArrayList<String>();
|
||||
grpcServers.add("127.0.0.1:2181");
|
||||
RemoteDownstreamConfig.Collector.GRPC_SERVERS = grpcServers;
|
||||
Whitebox.setInternalState(grpcChannelManager, "retryCycle", 1);
|
||||
Config.Collector.GRPC_CHANNEL_CHECK_INTERVAL = 1;
|
||||
|
||||
mockStatic(NettyChannelBuilder.class);
|
||||
when(NettyChannelBuilder.forAddress(anyString(), anyInt())).thenReturn(mock);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package org.skywalking.apm.plugin.mongodb.v3.define;
|
||||
|
||||
import com.mongodb.connection.Cluster;
|
||||
import net.bytebuddy.description.method.MethodDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
|
||||
|
|
@ -9,7 +8,7 @@ import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMet
|
|||
import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
|
||||
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
|
||||
import static org.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
|
||||
import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
|
||||
|
||||
public class MongoDBInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
|
||||
|
|
@ -24,7 +23,7 @@ public class MongoDBInstrumentation extends ClassInstanceMethodsEnhancePluginDef
|
|||
new ConstructorInterceptPoint() {
|
||||
@Override
|
||||
public ElementMatcher<MethodDescription> getConstructorMatcher() {
|
||||
return takesArgument(1, Cluster.class);
|
||||
return takesArgumentWithType(0, "com.mongodb.connection.Cluster");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue