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 48ffd09 Spring @Async plugin support (#2902)
48ffd09 is described below
commit 48ffd0923941e61df778a8fa6588f7a87c05728f
Author: 于玉桔 <[email protected]>
AuthorDate: Tue Jul 2 07:46:25 2019 +0800
Spring @Async plugin support (#2902)
* spring_async_plugin
* fix
* fix
* fix
* fix
* format fix
* rename
* fix
* fix version
* Update SWCallable.java
* Update Supported-list.md
* Update Supported-list.md
---
.../network/trace/component/ComponentsDefine.java | 2 +
.../{ => async-annotation-plugin}/pom.xml | 37 +++++-------
.../spring/async/DoSubmitMethodInterceptor.java | 54 +++++++++++++++++
.../apm/plugin/spring/async/SWCallable.java | 57 ++++++++++++++++++
.../AsyncExecutionInterceptorInstrumentation.java | 69 ++++++++++++++++++++++
.../src/main/resources/skywalking-plugin.def | 17 ++++++
apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml | 1 +
.../service-agent/java-agent/Supported-list.md | 3 +
.../src/test/resources/component-libraries.yml | 3 +
.../src/main/resources/component-libraries.yml | 3 +
10 files changed, 224 insertions(+), 22 deletions(-)
diff --git
a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java
b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java
index c8dec42..e02e8b2 100644
---
a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java
+++
b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java
@@ -124,6 +124,8 @@ public class ComponentsDefine {
public static final OfficialComponent SOLRJ = new OfficialComponent(63,
"solrj");
+ public static final OfficialComponent SPRING_ASYNC = new
OfficialComponent(65, "SpringAsync");
+
private static ComponentsDefine INSTANCE = new ComponentsDefine();
private String[] components;
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml
b/apm-sniffer/apm-sdk-plugin/spring-plugins/async-annotation-plugin/pom.xml
similarity index 54%
copy from apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml
copy to
apm-sniffer/apm-sdk-plugin/spring-plugins/async-annotation-plugin/pom.xml
index 0ed5610..19eec9a 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/async-annotation-plugin/pom.xml
@@ -1,4 +1,3 @@
-<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
@@ -17,36 +16,30 @@
~
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
+ <artifactId>spring-plugins</artifactId>
<groupId>org.apache.skywalking</groupId>
- <artifactId>apm-sdk-plugin</artifactId>
<version>6.3.0-SNAPSHOT</version>
</parent>
+ <modelVersion>4.0.0</modelVersion>
- <artifactId>spring-plugins</artifactId>
- <modules>
- <module>concurrent-util-4.x-plugin</module>
- <module>resttemplate-4.x-plugin</module>
- <module>mvc-annotation-4.x-plugin</module>
- <module>spring-cloud</module>
- <module>mvc-annotation-3.x-plugin</module>
- <module>core-patch</module>
- <module>mvc-annotation-commons</module>
- <module>spring-commons</module>
- <module>mvc-annotation-5.x-plugin</module>
- <module>webflux-5.x-plugin</module>
- </modules>
- <packaging>pom</packaging>
+ <artifactId>apm-spring-async-annotation-plugin</artifactId>
+ <packaging>jar</packaging>
- <name>apm-sdk-plugin</name>
+ <name>async-annotation-plugin</name>
<url>http://maven.apache.org</url>
<properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <sdk.plugin.related.dir>/..</sdk.plugin.related.dir>
+ <spring-aop.version>5.1.4.RELEASE</spring-aop.version>
</properties>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-aop</artifactId>
+ <version>${spring-aop.version}</version>
+ </dependency>
+ </dependencies>
</project>
diff --git
a/apm-sniffer/apm-sdk-plugin/spring-plugins/async-annotation-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/async/DoSubmitMethodInterceptor.java
b/apm-sniffer/apm-sdk-plugin/spring-plugins/async-annotation-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/async/DoSubmitMethodInterceptor.java
new file mode 100644
index 0000000..61ea641
--- /dev/null
+++
b/apm-sniffer/apm-sdk-plugin/spring-plugins/async-annotation-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/async/DoSubmitMethodInterceptor.java
@@ -0,0 +1,54 @@
+/*
+ * 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.async;
+
+import org.apache.skywalking.apm.agent.core.context.ContextManager;
+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 java.lang.reflect.Method;
+import java.util.concurrent.Callable;
+
+
+/**
+ * @author zhaoyuguang
+ */
+public class DoSubmitMethodInterceptor implements
InstanceMethodsAroundInterceptor {
+
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[]
allArguments, Class<?>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+ if (ContextManager.isActive()) {
+ allArguments[0] = new SWCallable((Callable) allArguments[0],
ContextManager.capture());
+ }
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method,
Object[] allArguments,
+ Class<?>[] argumentsTypes, Object ret) throws
Throwable {
+ return ret;
+ }
+
+
+ @Override
+ public void handleMethodException(EnhancedInstance objInst, Method method,
Object[] allArguments,
+ Class<?>[] argumentsTypes, Throwable t) {
+ }
+}
diff --git
a/apm-sniffer/apm-sdk-plugin/spring-plugins/async-annotation-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/async/SWCallable.java
b/apm-sniffer/apm-sdk-plugin/spring-plugins/async-annotation-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/async/SWCallable.java
new file mode 100644
index 0000000..0769309
--- /dev/null
+++
b/apm-sniffer/apm-sdk-plugin/spring-plugins/async-annotation-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/async/SWCallable.java
@@ -0,0 +1,57 @@
+/*
+ * 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.async;
+
+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.trace.AbstractSpan;
+import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
+
+import java.util.concurrent.Callable;
+
+/**
+ * @author zhaoyuguang
+ */
+public class SWCallable<V> implements Callable<V> {
+
+ private static final String OPERATION_NAME = "SpringAsync";
+
+ private Callable<V> callable;
+
+ private ContextSnapshot snapshot;
+
+ SWCallable(Callable<V> callable, ContextSnapshot snapshot) {
+ this.callable = callable;
+ this.snapshot = snapshot;
+ }
+
+ @Override
+ public V call() throws Exception {
+ AbstractSpan span =
ContextManager.createLocalSpan(SWCallable.OPERATION_NAME);
+ span.setComponent(ComponentsDefine.SPRING_ASYNC);
+ try {
+ ContextManager.continued(snapshot);
+ return callable.call();
+ } catch (Exception e) {
+ ContextManager.activeSpan().errorOccurred().log(e);
+ throw e;
+ } finally {
+ ContextManager.stopSpan();
+ }
+ }
+}
diff --git
a/apm-sniffer/apm-sdk-plugin/spring-plugins/async-annotation-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/async/define/AsyncExecutionInterceptorInstrumentation.java
b/apm-sniffer/apm-sdk-plugin/spring-plugins/async-annotation-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/async/define/AsyncExecutionInterceptorInstrumentation.java
new file mode 100644
index 0000000..ff04c5e
--- /dev/null
+++
b/apm-sniffer/apm-sdk-plugin/spring-plugins/async-annotation-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/async/define/AsyncExecutionInterceptorInstrumentation.java
@@ -0,0 +1,69 @@
+/*
+ * 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.async.define;
+
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import
org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
+import
org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
+import
org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
+import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+import static
org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
+import static
org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
+
+/**
+ * @author zhaoyuguang
+ */
+
+public class AsyncExecutionInterceptorInstrumentation extends
ClassInstanceMethodsEnhancePluginDefine {
+
+ @Override
+ protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[0];
+ }
+
+ @Override
+ protected InstanceMethodsInterceptPoint[]
getInstanceMethodsInterceptPoints() {
+ return new InstanceMethodsInterceptPoint[]{
+ new InstanceMethodsInterceptPoint() {
+ @Override
+ public ElementMatcher<MethodDescription> getMethodsMatcher() {
+ return named("doSubmit").and(takesArgumentWithType(0,
"java.util.concurrent.Callable"));
+ }
+
+ @Override
+ public String getMethodsInterceptor() {
+ return
"org.apache.skywalking.apm.plugin.spring.async.DoSubmitMethodInterceptor";
+ }
+
+ @Override
+ public boolean isOverrideArgs() {
+ return true;
+ }
+ }
+ };
+ }
+
+ @Override
+ public ClassMatch enhanceClass() {
+ return
byName("org.springframework.aop.interceptor.AsyncExecutionAspectSupport");
+ }
+}
diff --git
a/apm-sniffer/apm-sdk-plugin/spring-plugins/async-annotation-plugin/src/main/resources/skywalking-plugin.def
b/apm-sniffer/apm-sdk-plugin/spring-plugins/async-annotation-plugin/src/main/resources/skywalking-plugin.def
new file mode 100644
index 0000000..d379198
--- /dev/null
+++
b/apm-sniffer/apm-sdk-plugin/spring-plugins/async-annotation-plugin/src/main/resources/skywalking-plugin.def
@@ -0,0 +1,17 @@
+# 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.
+
+spring-async-annotation-5.x=org.apache.skywalking.apm.plugin.spring.async.define.AsyncExecutionInterceptorInstrumentation
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml
b/apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml
index 0ed5610..64738c6 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml
@@ -28,6 +28,7 @@
<artifactId>spring-plugins</artifactId>
<modules>
+ <module>async-annotation-plugin</module>
<module>concurrent-util-4.x-plugin</module>
<module>resttemplate-4.x-plugin</module>
<module>mvc-annotation-4.x-plugin</module>
diff --git a/docs/en/setup/service-agent/java-agent/Supported-list.md
b/docs/en/setup/service-agent/java-agent/Supported-list.md
index c43fd7d..1f52dff 100644
--- a/docs/en/setup/service-agent/java-agent/Supported-list.md
+++ b/docs/en/setup/service-agent/java-agent/Supported-list.md
@@ -73,6 +73,9 @@
* Vert.x Ecosystem
* Vert.x Eventbus 3.2+
* Vert.x Web 3.x
+* Thread Schedule Framework
+ * [Spring @Async](https://github.com/spring-projects/spring-framework) 4.x
and 5.x
+
¹Due to license incompatibilities/restrictions these plugins are hosted and
released in 3rd part repository,
go to [SkyAPM java plugin extension
repository](https://github.com/SkyAPM/java-plugin-extensions) to get these.
diff --git a/oap-server/server-core/src/test/resources/component-libraries.yml
b/oap-server/server-core/src/test/resources/component-libraries.yml
index defa1d6..f8347e1 100644
--- a/oap-server/server-core/src/test/resources/component-libraries.yml
+++ b/oap-server/server-core/src/test/resources/component-libraries.yml
@@ -204,6 +204,9 @@ SolrJ:
Solr:
id: 64
languages: Java
+SpringAsync:
+ id: 65
+ languages: Java
# .NET/.NET Core components
# [3000, 4000) for C#/.NET only
diff --git
a/oap-server/server-starter/src/main/resources/component-libraries.yml
b/oap-server/server-starter/src/main/resources/component-libraries.yml
index 3179c6b..e4200c2 100644
--- a/oap-server/server-starter/src/main/resources/component-libraries.yml
+++ b/oap-server/server-starter/src/main/resources/component-libraries.yml
@@ -222,6 +222,9 @@ SolrJ:
Solr:
id: 64
languages: Java
+SpringAsync:
+ id: 65
+ languages: Java
# .NET/.NET Core components