This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git
The following commit(s) were added to refs/heads/master by this push:
new b1dea4c Provide a configuration to control the length of the peer
field (#3105)
b1dea4c is described below
commit b1dea4c54083e0bf9e65333dc759e63edf8892eb
Author: 于玉桔 <[email protected]>
AuthorDate: Sat Jul 20 16:50:28 2019 +0800
Provide a configuration to control the length of the peer field (#3105)
* Fix 3096
---
.../skywalking/apm/agent/core/conf/Config.java | 6 +++
.../agent/core/conf/SnifferConfigInitializer.java | 18 ++++----
.../apm/agent/core/context/util/PeerFormat.java | 38 +++++++++++++++++
.../apm/agent/core/util/PeerFormatTest.java | 39 +++++++++++++++++
...nstructorWithListHostAndPortArgInterceptor.java | 6 ++-
...uctorWithListHostAndPortArgInterceptorTest.java | 31 ++++++++++++--
.../v11/ConsumerConstructorInterceptorTest.java | 4 +-
.../redisson/v3/ConnectionManagerInterceptor.java | 9 ++--
.../RedisClusterClientConstructorInterceptor.java | 3 +-
.../v5/RedisChannelWriterInterceptorTest.java | 17 ++++++++
.../lettuce/v5/mock/MockRedisClusterClient.java} | 49 ++++++++++++++++------
...kRedisClusterClientConstructorInterceptor.java} | 14 +++----
docs/en/setup/service-agent/java-agent/README.md | 3 +-
13 files changed, 193 insertions(+), 44 deletions(-)
diff --git
a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
index 9efab98..48418d2 100644
---
a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
+++
b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/Config.java
@@ -158,6 +158,12 @@ public class Config {
}
public static class Plugin {
+
+ /**
+ * Control the length of the peer field.
+ */
+ public static int PEER_MAX_LENGTH = 200;
+
public static class MongoDB {
/**
* If true, trace all the parameters in MongoDB access, default is
false. Only trace the operation, not include parameters.
diff --git
a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/SnifferConfigInitializer.java
b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/SnifferConfigInitializer.java
index c4fbcdf..b7ed19d 100644
---
a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/SnifferConfigInitializer.java
+++
b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/SnifferConfigInitializer.java
@@ -18,17 +18,6 @@
package org.apache.skywalking.apm.agent.core.conf;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
import org.apache.skywalking.apm.agent.core.boot.AgentPackageNotFoundException;
import org.apache.skywalking.apm.agent.core.boot.AgentPackagePath;
import org.apache.skywalking.apm.agent.core.logging.api.ILog;
@@ -37,6 +26,9 @@ import org.apache.skywalking.apm.util.ConfigInitializer;
import org.apache.skywalking.apm.util.PropertyPlaceholderHelper;
import org.apache.skywalking.apm.util.StringUtil;
+import java.io.*;
+import java.util.*;
+
/**
* The <code>SnifferConfigInitializer</code> initializes all configs in
several way.
*
@@ -100,6 +92,10 @@ public class SnifferConfigInitializer {
if (StringUtil.isEmpty(Config.Collector.BACKEND_SERVICE)) {
throw new ExceptionInInitializerError("`collector.backend_service`
is missing.");
}
+ if (Config.Plugin.PEER_MAX_LENGTH <= 3) {
+ logger.warn("PEER_MAX_LENGTH configuration:{} error, the default
value of 200 will be used.", Config.Plugin.PEER_MAX_LENGTH);
+ Config.Plugin.PEER_MAX_LENGTH = 200;
+ }
IS_INIT_COMPLETED = true;
}
diff --git
a/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/util/PeerFormat.java
b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/util/PeerFormat.java
new file mode 100644
index 0000000..1c27c36
--- /dev/null
+++
b/apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/context/util/PeerFormat.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.agent.core.context.util;
+
+import org.apache.skywalking.apm.agent.core.conf.Config;
+import org.apache.skywalking.apm.util.StringUtil;
+
+/**
+ * @author zhaoyuguang
+ */
+
+public class PeerFormat {
+
+ private static final String ABBR = "...";
+
+ public static String shorten(String original) {
+ if (!StringUtil.isEmpty(original) && original.length() >
Config.Plugin.PEER_MAX_LENGTH) {
+ return original.substring(0, Config.Plugin.PEER_MAX_LENGTH - 3) +
ABBR;
+ }
+ return original;
+ }
+}
diff --git
a/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/util/PeerFormatTest.java
b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/util/PeerFormatTest.java
new file mode 100644
index 0000000..dea8fd3
--- /dev/null
+++
b/apm-sniffer/apm-agent-core/src/test/java/org/apache/skywalking/apm/agent/core/util/PeerFormatTest.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.agent.core.util;
+
+import org.apache.skywalking.apm.agent.core.context.util.PeerFormat;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @author zhaoyuguang
+ */
+
+public class PeerFormatTest {
+
+ @Test
+ public void testShorten() {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < 100; i++) {
+ sb.append("localhost:" + i + ";");
+ }
+ Assert.assertTrue(PeerFormat.shorten(sb.toString()).length() == 200);
+ }
+}
diff --git
a/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisClusterConstructorWithListHostAndPortArgInterceptor.java
b/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisClusterConstructorWithListHostAndPortArgInterceptor.java
index d7d420b..f4f4367 100644
---
a/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisClusterConstructorWithListHostAndPortArgInterceptor.java
+++
b/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisClusterConstructorWithListHostAndPortArgInterceptor.java
@@ -19,11 +19,13 @@
package org.apache.skywalking.apm.plugin.jedis.v2;
-import java.util.Set;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
+import org.apache.skywalking.apm.agent.core.context.util.PeerFormat;
import redis.clients.jedis.HostAndPort;
+import java.util.Set;
+
public class JedisClusterConstructorWithListHostAndPortArgInterceptor
implements InstanceConstructorInterceptor {
@Override
@@ -34,6 +36,6 @@ public class
JedisClusterConstructorWithListHostAndPortArgInterceptor implements
redisConnInfo.append(hostAndPort.toString()).append(";");
}
- objInst.setSkyWalkingDynamicField(redisConnInfo.toString());
+
objInst.setSkyWalkingDynamicField(PeerFormat.shorten(redisConnInfo.toString()));
}
}
diff --git
a/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisClusterConstructorWithListHostAndPortArgInterceptorTest.java
b/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisClusterConstructorWithListHostAndPortArgInterceptorTest.java
index b2fbc81..b0abfe5 100644
---
a/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisClusterConstructorWithListHostAndPortArgInterceptorTest.java
+++
b/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisClusterConstructorWithListHostAndPortArgInterceptorTest.java
@@ -18,10 +18,9 @@
package org.apache.skywalking.apm.plugin.jedis.v2;
-import java.util.LinkedHashSet;
-import java.util.Set;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.junit.After;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -29,6 +28,9 @@ import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import redis.clients.jedis.HostAndPort;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
import static org.mockito.Mockito.verify;
@RunWith(MockitoJUnitRunner.class)
@@ -56,9 +58,32 @@ public class
JedisClusterConstructorWithListHostAndPortArgInterceptorTest {
@Test
public void onConstruct() throws Exception {
- interceptor.onConstruct(enhancedInstance, new Object[]
{hostAndPortSet});
+ interceptor.onConstruct(enhancedInstance, new
Object[]{hostAndPortSet});
verify(enhancedInstance).setSkyWalkingDynamicField("127.0.0.1:6379;127.0.0.1:16379;");
}
+ @Test
+ public void onHugeClusterConstruct() throws Exception {
+ hostAndPortSet = new LinkedHashSet<HostAndPort>();
+ for (int i = 0; i < 100; i++) {
+ hostAndPortSet.add(new HostAndPort("localhost", i));
+ }
+ enhancedInstance = new EnhancedInstance() {
+ private Object v;
+
+ @Override
+ public Object getSkyWalkingDynamicField() {
+ return v;
+ }
+
+ @Override
+ public void setSkyWalkingDynamicField(Object value) {
+ this.v = value;
+ }
+ };
+ interceptor.onConstruct(enhancedInstance, new
Object[]{hostAndPortSet});
+
Assert.assertTrue(enhancedInstance.getSkyWalkingDynamicField().toString().length()
== 200);
+ }
+
}
diff --git
a/apm-sniffer/apm-sdk-plugin/kafka-v1-plugin/src/test/java/org/apache/skywalking/apm/plugin/kafka/v11/ConsumerConstructorInterceptorTest.java
b/apm-sniffer/apm-sdk-plugin/kafka-v1-plugin/src/test/java/org/apache/skywalking/apm/plugin/kafka/v11/ConsumerConstructorInterceptorTest.java
index e6125ba..ad642dd 100644
---
a/apm-sniffer/apm-sdk-plugin/kafka-v1-plugin/src/test/java/org/apache/skywalking/apm/plugin/kafka/v11/ConsumerConstructorInterceptorTest.java
+++
b/apm-sniffer/apm-sdk-plugin/kafka-v1-plugin/src/test/java/org/apache/skywalking/apm/plugin/kafka/v11/ConsumerConstructorInterceptorTest.java
@@ -18,8 +18,6 @@
package org.apache.skywalking.apm.plugin.kafka.v11;
-import java.util.ArrayList;
-import java.util.List;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import
org.apache.skywalking.apm.plugin.kafka.v1.ConsumerConstructorInterceptor;
@@ -29,6 +27,8 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
+import java.util.ArrayList;
+import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
diff --git
a/apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/ConnectionManagerInterceptor.java
b/apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/ConnectionManagerInterceptor.java
index 6ff4cec..07c9917 100644
---
a/apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/ConnectionManagerInterceptor.java
+++
b/apm-sniffer/apm-sdk-plugin/redisson-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/redisson/v3/ConnectionManagerInterceptor.java
@@ -23,6 +23,7 @@ import
org.apache.skywalking.apm.agent.core.logging.api.LogManager;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.apache.skywalking.apm.agent.core.context.util.PeerFormat;
import org.redisson.config.*;
import org.redisson.connection.ConnectionManager;
@@ -60,24 +61,24 @@ public class ConnectionManagerInterceptor implements
InstanceMethodsAroundInterc
if (sentinelServersConfig != null) {
appendAddresses(peer,
sentinelServersConfig.getSentinelAddresses());
- retInst.setSkyWalkingDynamicField(peer.toString());
+
retInst.setSkyWalkingDynamicField(PeerFormat.shorten(peer.toString()));
return ret;
}
if (masterSlaveServersConfig != null) {
URI masterAddress =
masterSlaveServersConfig.getMasterAddress();
peer.append(masterAddress.getHost()).append(":").append(masterAddress.getPort());
appendAddresses(peer,
masterSlaveServersConfig.getSlaveAddresses());
- retInst.setSkyWalkingDynamicField(peer.toString());
+
retInst.setSkyWalkingDynamicField(PeerFormat.shorten(peer.toString()));
return ret;
}
if (clusterServersConfig != null) {
appendAddresses(peer, clusterServersConfig.getNodeAddresses());
- retInst.setSkyWalkingDynamicField(peer.toString());
+
retInst.setSkyWalkingDynamicField(PeerFormat.shorten(peer.toString()));
return ret;
}
if (replicatedServersConfig != null) {
appendAddresses(peer,
replicatedServersConfig.getNodeAddresses());
- retInst.setSkyWalkingDynamicField(peer.toString());
+
retInst.setSkyWalkingDynamicField(PeerFormat.shorten(peer.toString()));
return ret;
}
} catch (Exception e) {
diff --git
a/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/lettuce/v5/RedisClusterClientConstructorInterceptor.java
b/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/lettuce/v5/RedisClusterClientConstructorInterceptor.java
index a8f7165..035b06b 100644
---
a/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/lettuce/v5/RedisClusterClientConstructorInterceptor.java
+++
b/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/lettuce/v5/RedisClusterClientConstructorInterceptor.java
@@ -23,6 +23,7 @@ import io.lettuce.core.RedisURI;
import io.lettuce.core.cluster.RedisClusterClient;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
+import org.apache.skywalking.apm.agent.core.context.util.PeerFormat;
/**
* @author zhaoyuguang
@@ -39,6 +40,6 @@ public class RedisClusterClientConstructorInterceptor
implements InstanceConstru
peer.append(redisURI.getHost()).append(":").append(redisURI.getPort()).append(";");
}
EnhancedInstance optionsInst = (EnhancedInstance)
redisClusterClient.getOptions();
- optionsInst.setSkyWalkingDynamicField(peer.toString());
+
optionsInst.setSkyWalkingDynamicField(PeerFormat.shorten(peer.toString()));
}
}
diff --git
a/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/lettuce/v5/RedisChannelWriterInterceptorTest.java
b/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/lettuce/v5/RedisChannelWriterInterceptorTest.java
index 28f8b47..4ee94ca 100644
---
a/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/lettuce/v5/RedisChannelWriterInterceptorTest.java
+++
b/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/lettuce/v5/RedisChannelWriterInterceptorTest.java
@@ -18,6 +18,7 @@
package org.apache.skywalking.apm.plugin.lettuce.v5;
+import io.lettuce.core.RedisURI;
import io.lettuce.core.protocol.Command;
import io.lettuce.core.protocol.CommandType;
import io.lettuce.core.protocol.RedisCommand;
@@ -32,6 +33,8 @@ import
org.apache.skywalking.apm.agent.test.tools.AgentServiceRule;
import org.apache.skywalking.apm.agent.test.tools.SegmentStorage;
import org.apache.skywalking.apm.agent.test.tools.SegmentStoragePoint;
import org.apache.skywalking.apm.agent.test.tools.TracingSegmentRunner;
+import org.apache.skywalking.apm.plugin.lettuce.v5.mock.MockRedisClusterClient;
+import
org.apache.skywalking.apm.plugin.lettuce.v5.mock.MockRedisClusterClientConstructorInterceptor;
import org.hamcrest.CoreMatchers;
import org.hamcrest.MatcherAssert;
import org.hamcrest.core.Is;
@@ -43,6 +46,7 @@ import org.mockito.Mock;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.modules.junit4.PowerMockRunnerDelegate;
+import java.util.ArrayList;
import java.util.List;
import static org.hamcrest.CoreMatchers.is;
@@ -109,4 +113,17 @@ public class RedisChannelWriterInterceptorTest {
assertThat(tags.get(0).getValue(), is("Redis"));
assertThat(SpanHelper.getLayer(spans.get(0)),
CoreMatchers.is(SpanLayer.CACHE));
}
+
+
+ @Test
+ public void testOnHugeClusterConsumerConfig() {
+ List<RedisURI> redisURIs = new ArrayList<>(100);
+ for (int i = 0; i < 100; i++) {
+ redisURIs.add(RedisURI.create("localhost", i));
+ }
+ MockRedisClusterClient mockRedisClusterClient = new
MockRedisClusterClient();
+ MockRedisClusterClientConstructorInterceptor constructorInterceptor =
new MockRedisClusterClientConstructorInterceptor();
+ constructorInterceptor.onConstruct(mockRedisClusterClient, new
Object[]{null, redisURIs});
+
assertThat(mockRedisClusterClient.getOptions().getSkyWalkingDynamicField().toString().length(),
Is.is(200));
+ }
}
diff --git
a/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisClusterConstructorWithListHostAndPortArgInterceptor.java
b/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/lettuce/v5/mock/MockRedisClusterClient.java
similarity index 52%
copy from
apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisClusterConstructorWithListHostAndPortArgInterceptor.java
copy to
apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/lettuce/v5/mock/MockRedisClusterClient.java
index d7d420b..21b1bca 100644
---
a/apm-sniffer/apm-sdk-plugin/jedis-2.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jedis/v2/JedisClusterConstructorWithListHostAndPortArgInterceptor.java
+++
b/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/lettuce/v5/mock/MockRedisClusterClient.java
@@ -16,24 +16,47 @@
*
*/
+package org.apache.skywalking.apm.plugin.lettuce.v5.mock;
-package org.apache.skywalking.apm.plugin.jedis.v2;
-
-import java.util.Set;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
-import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
-import redis.clients.jedis.HostAndPort;
-public class JedisClusterConstructorWithListHostAndPortArgInterceptor
implements InstanceConstructorInterceptor {
+/**
+ * @author zhaoyuguang
+ */
+
+public class MockRedisClusterClient implements EnhancedInstance {
- @Override
- public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
- StringBuilder redisConnInfo = new StringBuilder();
- Set<HostAndPort> hostAndPorts = (Set<HostAndPort>)allArguments[0];
- for (HostAndPort hostAndPort : hostAndPorts) {
- redisConnInfo.append(hostAndPort.toString()).append(";");
+ private Object ms;
+
+ private EnhancedInstance options = new EnhancedInstance() {
+ private Object os;
+
+ @Override
+ public Object getSkyWalkingDynamicField() {
+ return os;
+ }
+
+ @Override
+ public void setSkyWalkingDynamicField(Object value) {
+ this.os = value;
}
+ };
- objInst.setSkyWalkingDynamicField(redisConnInfo.toString());
+ public EnhancedInstance getOptions() {
+ return options;
+ }
+
+ public void setOptions(EnhancedInstance options) {
+ this.options = options;
+ }
+
+ @Override
+ public Object getSkyWalkingDynamicField() {
+ return ms;
+ }
+
+ @Override
+ public void setSkyWalkingDynamicField(Object value) {
+ this.ms = value;
}
}
diff --git
a/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/lettuce/v5/RedisClusterClientConstructorInterceptor.java
b/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/lettuce/v5/mock/MockRedisClusterClientConstructorInterceptor.java
similarity index 75%
copy from
apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/lettuce/v5/RedisClusterClientConstructorInterceptor.java
copy to
apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/lettuce/v5/mock/MockRedisClusterClientConstructorInterceptor.java
index a8f7165..a9502f0 100644
---
a/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/lettuce/v5/RedisClusterClientConstructorInterceptor.java
+++
b/apm-sniffer/optional-plugins/lettuce-5.x-plugin/src/test/java/org/apache/skywalking/apm/plugin/lettuce/v5/mock/MockRedisClusterClientConstructorInterceptor.java
@@ -16,29 +16,29 @@
*
*/
-
-package org.apache.skywalking.apm.plugin.lettuce.v5;
+package org.apache.skywalking.apm.plugin.lettuce.v5.mock;
import io.lettuce.core.RedisURI;
-import io.lettuce.core.cluster.RedisClusterClient;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
+import org.apache.skywalking.apm.agent.core.context.util.PeerFormat;
/**
* @author zhaoyuguang
*/
-public class RedisClusterClientConstructorInterceptor implements
InstanceConstructorInterceptor {
+
+public class MockRedisClusterClientConstructorInterceptor implements
InstanceConstructorInterceptor {
@Override
public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
@SuppressWarnings("unchecked")
Iterable<RedisURI> redisURIs = (Iterable<RedisURI>) allArguments[1];
- RedisClusterClient redisClusterClient = (RedisClusterClient) objInst;
+ MockRedisClusterClient redisClusterClient = (MockRedisClusterClient)
objInst;
StringBuilder peer = new StringBuilder();
for (RedisURI redisURI : redisURIs) {
peer.append(redisURI.getHost()).append(":").append(redisURI.getPort()).append(";");
}
- EnhancedInstance optionsInst = (EnhancedInstance)
redisClusterClient.getOptions();
- optionsInst.setSkyWalkingDynamicField(peer.toString());
+ EnhancedInstance optionsInst = redisClusterClient.getOptions();
+
optionsInst.setSkyWalkingDynamicField(PeerFormat.shorten(peer.toString()));
}
}
diff --git a/docs/en/setup/service-agent/java-agent/README.md
b/docs/en/setup/service-agent/java-agent/README.md
index 247dd43..1e186c2 100644
--- a/docs/en/setup/service-agent/java-agent/README.md
+++ b/docs/en/setup/service-agent/java-agent/README.md
@@ -65,7 +65,7 @@ property key | Description | Default |
`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.cause_exception_depth`|How depth the agent goes, when log all cause
exceptions.|5|
+`agent.cause_exception_depth`|How depth the agent goes, when log all cause
exceptions.|`5`|
`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`|
@@ -79,6 +79,7 @@ property key | Description | Default |
`buffer.buffer_size`|The buffer size.|`300`|
`dictionary.service_code_buffer_size`|The buffer size of application codes and
peer|`10 * 10000`|
`dictionary.endpoint_name_buffer_size`|The buffer size of endpoint names and
peer|`1000 * 10000`|
+`plugin.peer_max_length `|Peer maximum description limit.|`200`|
`plugin.mongodb.trace_param`|If true, trace all the parameters in MongoDB
access, default is false. Only trace the operation, not include
parameters.|`false`|
`plugin.elasticsearch.trace_dsl`|If true, trace all the DSL(Domain Specific
Language) in ElasticSearch access, default is false.|`false`|
`plugin.springmvc.use_qualified_name_as_endpoint_name`|If true, the fully
qualified method name will be used as the endpoint name instead of the request
URL, default is false.|`false`|