You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2020/08/18 02:31:32 UTC

[GitHub] [skywalking] wu-sheng commented on a change in pull request #5339: Add support for spring @Scheduled

wu-sheng commented on a change in pull request #5339:
URL: https://github.com/apache/skywalking/pull/5339#discussion_r471877418



##########
File path: test/plugin/scenarios/spring-scheduled-scenario/config/expectedData.yaml
##########
@@ -0,0 +1,48 @@
+# 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.
+segmentItems:
+  - serviceName: spring-scheduled-scenario
+    segmentSize: ge 2
+    segments:

Review comment:
       From my reading of your test case codes, there should be a segment starting with `SchedulingJob#work`, where it is? Or do I miss anything?

##########
File path: .github/workflows/plugins-test.3.yaml
##########
@@ -55,6 +55,7 @@ jobs:
           - { name: 'hbase-scenario', title: 'hbase-scenario (5)' }
           - { name: 'spring-kafka-2.2.x-scenario', title: 'Spring-Kafka 2.2.x (7)' }
           - { name: 'spring-kafka-2.3.x-scenario', title: 'Spring-Kafka 2.3.x (7)' }
+          - { name: 'spring-scheduled-scenario', title: 'Spring Scheduled 3.1.x-5.2.x (119)' }

Review comment:
       Don't use all 119 versions, it costs too many CI resources and time. Just choose the typical ones, such as choose the latest version in 5.0.x to represent all versions.

##########
File path: apm-sniffer/apm-sdk-plugin/spring-plugins/scheduled-annotation-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/scheduled/ScheduledMethodInterceptor.java
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.plugin.spring.scheduled;
+
+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.trace.AbstractSpan;
+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.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 java.lang.reflect.Method;
+
+public class ScheduledMethodInterceptor implements InstanceMethodsAroundInterceptor, InstanceConstructorInterceptor {
+
+    private static final String DEFAULT_OPERATION_NAME = "SpringScheduled";
+
+    @Override
+    public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
+        String targetMethodName = (String) objInst.getSkyWalkingDynamicField();
+        String operationName = targetMethodName != null ? targetMethodName : DEFAULT_OPERATION_NAME;
+
+        AbstractSpan span = ContextManager.createEntrySpan(operationName, new ContextCarrier());

Review comment:
       This is just a local scheduler task, not an entry. Please read the plugin dev document. This should be a local span. Could you share why you put this as Entry Span?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org