You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2019/12/14 01:47:21 UTC

[skywalking] branch reduce-register-load updated: Fix config, plugin, and document, as exit span is not required register anymore.

This is an automated email from the ASF dual-hosted git repository.

wusheng pushed a commit to branch reduce-register-load
in repository https://gitbox.apache.org/repos/asf/skywalking.git


The following commit(s) were added to refs/heads/reduce-register-load by this push:
     new 2885ccb  Fix config, plugin, and document, as exit span is not required register anymore.
2885ccb is described below

commit 2885ccb943250dd17d24da5eb790df89d321d79e
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Sat Dec 14 09:47:02 2019 +0800

    Fix config, plugin, and document, as exit span is not required register anymore.
---
 .../org/apache/skywalking/apm/agent/core/conf/Config.java | 11 +++++++----
 .../spring/resttemplate/async/RestExecuteInterceptor.java | 11 +----------
 .../spring/resttemplate/sync/RestExecuteInterceptor.java  | 15 +++------------
 docs/en/setup/service-agent/java-agent/README.md          |  3 +++
 .../setup/service-agent/java-agent/op_name_group_rule.md  |  3 +--
 5 files changed, 15 insertions(+), 28 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 5e788a3..2bc276c 100755
--- 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
@@ -317,11 +317,14 @@ public class Config {
          */
         public static class OPGroup {
             /**
-             * Rules for RestTemplate plugin
+             * Since 6.6.0, exit span is not requesting endpoint register,
+             * this group rule is not required.
+             *
+             * Keep this commented, just as a reminder that, it will be reused in a RPC server side plugin.
              */
-            public static class RestTemplate implements OPGroupDefinition {
-                public static Map<String, String> RULE = new HashMap<String, String>();
-            }
+//            public static class RestTemplate implements OPGroupDefinition {
+//                public static Map<String, String> RULE = new HashMap<String, String>();
+//            }
         }
 
         public static class Light4J {
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/RestExecuteInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/RestExecuteInterceptor.java
index 81c0eb8..48bbf2a 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/RestExecuteInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/RestExecuteInterceptor.java
@@ -20,12 +20,9 @@ package org.apache.skywalking.apm.plugin.spring.resttemplate.async;
 
 import java.lang.reflect.Method;
 import java.net.URI;
-import org.apache.skywalking.apm.agent.core.boot.ServiceManager;
-import org.apache.skywalking.apm.agent.core.conf.Config;
 import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
 import org.apache.skywalking.apm.agent.core.context.ContextManager;
 import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
-import org.apache.skywalking.apm.agent.core.context.OperationNameFormatService;
 import org.apache.skywalking.apm.agent.core.context.tag.Tags;
 import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
 import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
@@ -37,8 +34,6 @@ import org.apache.skywalking.apm.plugin.spring.commons.EnhanceCacheObjects;
 import org.springframework.http.HttpMethod;
 
 public class RestExecuteInterceptor implements InstanceMethodsAroundInterceptor {
-    private OperationNameFormatService nameFormatService;
-
     @Override
     public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
         MethodInterceptResult result) throws Throwable {
@@ -46,13 +41,9 @@ public class RestExecuteInterceptor implements InstanceMethodsAroundInterceptor
         final HttpMethod httpMethod = (HttpMethod)allArguments[1];
         final ContextCarrier contextCarrier = new ContextCarrier();
 
-        if (nameFormatService == null) {
-            nameFormatService = ServiceManager.INSTANCE.findService(OperationNameFormatService.class);
-        }
-
         String remotePeer = requestURL.getHost() + ":" + (requestURL.getPort() > 0 ? requestURL.getPort() : "https".equalsIgnoreCase(requestURL.getScheme()) ? 443 : 80);
 
-        String formatURIPath = nameFormatService.formatOperationName(Config.Plugin.OPGroup.RestTemplate.class, requestURL.getPath());
+        String formatURIPath = requestURL.getPath();
         AbstractSpan span = ContextManager.createExitSpan(
             formatURIPath,
             contextCarrier, remotePeer);
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/RestExecuteInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/RestExecuteInterceptor.java
index c5060b4..66b0e77 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/RestExecuteInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/RestExecuteInterceptor.java
@@ -20,23 +20,18 @@ package org.apache.skywalking.apm.plugin.spring.resttemplate.sync;
 
 import java.lang.reflect.Method;
 import java.net.URI;
-import org.apache.skywalking.apm.agent.core.boot.ServiceManager;
-import org.apache.skywalking.apm.agent.core.conf.Config;
 import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
-import org.apache.skywalking.apm.agent.core.context.OperationNameFormatService;
+import org.apache.skywalking.apm.agent.core.context.ContextManager;
 import org.apache.skywalking.apm.agent.core.context.tag.Tags;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
 import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
 import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
-import org.apache.skywalking.apm.agent.core.context.ContextManager;
-import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
 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.network.trace.component.ComponentsDefine;
 import org.springframework.http.HttpMethod;
 
 public class RestExecuteInterceptor implements InstanceMethodsAroundInterceptor {
-    private OperationNameFormatService nameFormatService;
-
     @Override
     public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
         MethodInterceptResult result) throws Throwable {
@@ -44,12 +39,8 @@ public class RestExecuteInterceptor implements InstanceMethodsAroundInterceptor
         final HttpMethod httpMethod = (HttpMethod)allArguments[1];
         final ContextCarrier contextCarrier = new ContextCarrier();
 
-        if (nameFormatService == null) {
-            nameFormatService = ServiceManager.INSTANCE.findService(OperationNameFormatService.class);
-        }
-
         String remotePeer = requestURL.getHost() + ":" + (requestURL.getPort() > 0 ? requestURL.getPort() : "https".equalsIgnoreCase(requestURL.getScheme()) ? 443 : 80);
-        String formatURIPath = nameFormatService.formatOperationName(Config.Plugin.OPGroup.RestTemplate.class, requestURL.getPath());
+        String formatURIPath = requestURL.getPath();
         AbstractSpan span = ContextManager.createExitSpan(formatURIPath, contextCarrier, remotePeer);
 
         span.setComponent(ComponentsDefine.SPRING_REST_TEMPLATE);
diff --git a/docs/en/setup/service-agent/java-agent/README.md b/docs/en/setup/service-agent/java-agent/README.md
index bf80d5f..787d90e 100755
--- a/docs/en/setup/service-agent/java-agent/README.md
+++ b/docs/en/setup/service-agent/java-agent/README.md
@@ -158,6 +158,9 @@ Now, we have the following known bootstrap plugins.
 SkyWalking java agent supports plugin to extend [the supported list](Supported-list.md). Please follow 
 our [Plugin Development Guide](../../../guides/Java-Plugin-Development-Guide.md).
 
+If some RPC framework endpoints(server side) could include parameter, please read [Operation Name Group Rule](op_name_group_rule.md),
+and consider to add this feature.
+
 # Test
 If you are interested in plugin compatible tests or agent performance, see the following reports.
 * [Plugin Test](https://github.com/SkyAPMTest/agent-integration-test-report)
diff --git a/docs/en/setup/service-agent/java-agent/op_name_group_rule.md b/docs/en/setup/service-agent/java-agent/op_name_group_rule.md
index ea24f18..6deaca2 100644
--- a/docs/en/setup/service-agent/java-agent/op_name_group_rule.md
+++ b/docs/en/setup/service-agent/java-agent/op_name_group_rule.md
@@ -4,8 +4,7 @@ Those operation name are also as known endpoint name in most cases.
 Such as /api/checkTicket/tk/{userToken}.
 
 We solved most of these cases, by leverage the parameter pattern path in framework, such as SpringMVC, Webflux, etc. 
-But it is undetected in RPC client side, such as HTTP restful client.
-In this case, we have to ask the users to set the group rule manually.
+In this case, it is undetected in this way, so we have to ask the users to set the group rule manually.
 
 All rules are supported to set through agent.config, system properties and system env, like other agent settings.
 - Config format, `plugin.opgroup.`plugin name`.rule[`rule name`]`=pattern regex expression