diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml b/apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml index da106f5e6..a475473dc 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml @@ -30,6 +30,7 @@ async-annotation-plugin concurrent-util-4.x-plugin + resttemplate-3.x-plugin resttemplate-4.x-plugin mvc-annotation-4.x-plugin spring-cloud @@ -42,6 +43,7 @@ spring-kafka-2.x-plugin scheduled-annotation-plugin spring-webflux-5.x-webclient-plugin + resttemplate-commons pom diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-3.x-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-3.x-plugin/pom.xml new file mode 100644 index 000000000..86ae89c48 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-3.x-plugin/pom.xml @@ -0,0 +1,54 @@ + + + + + spring-plugins + org.apache.skywalking + 8.15.0-SNAPSHOT + + 4.0.0 + + apm-resttemplate-3.x-plugin + + resttemplate-3.x-plugin + + + 3.2.18.RELEASE + + + + + org.springframework + spring-web + ${spring-web.version} + provided + + + + org.apache.skywalking + spring-commons + ${project.version} + + + org.apache.skywalking + resttemplate-commons + ${project.version} + + + diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/define/ResponseExtractorFutureInstrumentation3x.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/define/ResponseExtractorFutureInstrumentation3x.java new file mode 100644 index 000000000..f8fa39b2b --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/define/ResponseExtractorFutureInstrumentation3x.java @@ -0,0 +1,43 @@ +/* + * 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.resttemplate.async.define; + +import org.apache.skywalking.apm.agent.core.context.ContextSnapshot; +import org.apache.skywalking.apm.plugin.spring.resttemplate.async.ResponseCallBackInterceptor; + +import java.net.URI; + +/** + * {@link ResponseExtractorFutureInstrumentation3x} enhance the addCallback method and + * getDefault method of org.springframework.web.client.AsyncRestTemplate$ResponseExtractorFuture + * by + * ResponseCallBackInterceptor and + * FutureGetInterceptor. + *

+ * {@link ResponseCallBackInterceptor} set the {@link URI} and {@link ContextSnapshot} to inherited + * org.springframework.util.concurrent.SuccessCallback and org.springframework.util.concurrent.FailureCallback + */ +public class ResponseExtractorFutureInstrumentation3x extends ResponseExtractorFutureInstrumentation { + @Override + protected String[] witnessClasses() { + return new String[] { + "org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer" + }; + } +} diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/define/RestTemplateInstrumentation3x.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/define/RestTemplateInstrumentation3x.java new file mode 100644 index 000000000..4a88b277d --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/define/RestTemplateInstrumentation3x.java @@ -0,0 +1,41 @@ +/* + * 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.resttemplate.async.define; + +import org.apache.skywalking.apm.agent.core.context.ContextSnapshot; + +import java.net.URI; + +/** + * {@link RestTemplateInstrumentation3x} enhance the doExecute method and createAsyncRequest + * method of org.springframework.web.client.AsyncRestTemplate by RestExecuteInterceptor and + * org.springframework.http.client.RestRequestInterceptor. + * + * org.springframework.http.client.RestRequestInterceptor set {@link URI} and {@link ContextSnapshot} to + * org.springframework.web.client.AsyncRestTemplate$ResponseExtractorFuture for propagate trace context + * after execute doExecute . + */ +public class RestTemplateInstrumentation3x extends RestTemplateInstrumentation { + @Override + protected String[] witnessClasses() { + return new String[] { + "org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer" + }; + } +} diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/define/RestTemplateInstrumentation3x.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/define/RestTemplateInstrumentation3x.java new file mode 100644 index 000000000..8c10616d0 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/define/RestTemplateInstrumentation3x.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.plugin.spring.resttemplate.sync.define; + +/** + * {@link RestTemplateInstrumentation} enhance the doExecute method,handleResponse method and + * handleResponse method of org.springframework.web.client.RestTemplate by + * RestExecuteInterceptor, + * RestResponseInterceptor and + * RestRequestInterceptor. + * + * RestResponseInterceptor set context to header for + * propagate trace context after execute createRequest. + */ +public class RestTemplateInstrumentation3x extends RestTemplateInstrumentation { + @Override + protected String[] witnessClasses() { + return new String[] { + "org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer" + }; + } +} diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-3.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-3.x-plugin/src/main/resources/skywalking-plugin.def new file mode 100644 index 000000000..651bbca24 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-3.x-plugin/src/main/resources/skywalking-plugin.def @@ -0,0 +1,19 @@ +# 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-resttemplate-3.x=org.apache.skywalking.apm.plugin.spring.resttemplate.sync.define.RestTemplateInstrumentation3x +spring-resttemplate-3.x=org.apache.skywalking.apm.plugin.spring.resttemplate.async.define.ResponseExtractorFutureInstrumentation3x +spring-resttemplate-3.x=org.apache.skywalking.apm.plugin.spring.resttemplate.async.define.RestTemplateInstrumentation3x diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/pom.xml index bcc756a8a..071a42021 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/pom.xml +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/pom.xml @@ -47,5 +47,10 @@ spring-commons ${project.version} + + org.apache.skywalking + resttemplate-commons + ${project.version} + 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/define/ResponseExtractorFutureInstrumentation4x.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/define/ResponseExtractorFutureInstrumentation4x.java new file mode 100644 index 000000000..74f90fef5 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/define/ResponseExtractorFutureInstrumentation4x.java @@ -0,0 +1,43 @@ +/* + * 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.resttemplate.async.define; + +import org.apache.skywalking.apm.agent.core.context.ContextSnapshot; +import org.apache.skywalking.apm.plugin.spring.resttemplate.async.ResponseCallBackInterceptor; + +import java.net.URI; + +/** + * {@link ResponseExtractorFutureInstrumentation4x} enhance the addCallback method and + * getDefault method of org.springframework.web.client.AsyncRestTemplate$ResponseExtractorFuture + * by + * ResponseCallBackInterceptor and + * FutureGetInterceptor. + *

+ * {@link ResponseCallBackInterceptor} set the {@link URI} and {@link ContextSnapshot} to inherited + * org.springframework.util.concurrent.SuccessCallback and org.springframework.util.concurrent.FailureCallback + */ +public class ResponseExtractorFutureInstrumentation4x extends ResponseExtractorFutureInstrumentation { + @Override + protected String[] witnessClasses() { + return new String[] { + "org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor" + }; + } +} 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/define/RestTemplateInstrumentation4x.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/define/RestTemplateInstrumentation4x.java new file mode 100644 index 000000000..9ecbdafd7 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/define/RestTemplateInstrumentation4x.java @@ -0,0 +1,41 @@ +/* + * 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.resttemplate.async.define; + +import org.apache.skywalking.apm.agent.core.context.ContextSnapshot; + +import java.net.URI; + +/** + * {@link RestTemplateInstrumentation4x} enhance the doExecute method and createAsyncRequest + * method of org.springframework.web.client.AsyncRestTemplate by RestExecuteInterceptor and + * org.springframework.http.client.RestRequestInterceptor. + * + * org.springframework.http.client.RestRequestInterceptor set {@link URI} and {@link ContextSnapshot} to + * org.springframework.web.client.AsyncRestTemplate$ResponseExtractorFuture for propagate trace context + * after execute doExecute . + */ +public class RestTemplateInstrumentation4x extends RestTemplateInstrumentation { + @Override + protected String[] witnessClasses() { + return new String[] { + "org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor" + }; + } +} 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/define/RestTemplateInstrumentation4x.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/define/RestTemplateInstrumentation4x.java new file mode 100644 index 000000000..59817b24f --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/define/RestTemplateInstrumentation4x.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.plugin.spring.resttemplate.sync.define; + +/** + * {@link RestTemplateInstrumentation} enhance the doExecute method,handleResponse method and + * handleResponse method of org.springframework.web.client.RestTemplate by + * RestExecuteInterceptor, + * RestResponseInterceptor and + * RestRequestInterceptor. + * + * RestResponseInterceptor set context to header for + * propagate trace context after execute createRequest. + */ +public class RestTemplateInstrumentation4x extends RestTemplateInstrumentation { + @Override + protected String[] witnessClasses() { + return new String[] { + "org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor" + }; + } +} diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/resources/skywalking-plugin.def index 98a8a1b7c..909ddfb3f 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/resources/skywalking-plugin.def +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/resources/skywalking-plugin.def @@ -14,6 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -spring-resttemplate-4.x=org.apache.skywalking.apm.plugin.spring.resttemplate.sync.define.RestTemplateInstrumentation -spring-resttemplate-4.x=org.apache.skywalking.apm.plugin.spring.resttemplate.async.define.ResponseExtractorFutureInstrumentation -spring-resttemplate-4.x=org.apache.skywalking.apm.plugin.spring.resttemplate.async.define.RestTemplateInstrumentation +spring-resttemplate-4.x=org.apache.skywalking.apm.plugin.spring.resttemplate.sync.define.RestTemplateInstrumentation4x +spring-resttemplate-4.x=org.apache.skywalking.apm.plugin.spring.resttemplate.async.define.ResponseExtractorFutureInstrumentation4x +spring-resttemplate-4.x=org.apache.skywalking.apm.plugin.spring.resttemplate.async.define.RestTemplateInstrumentation4x diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/pom.xml b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/pom.xml new file mode 100644 index 000000000..0a2feba4c --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/pom.xml @@ -0,0 +1,49 @@ + + + + + spring-plugins + org.apache.skywalking + 8.15.0-SNAPSHOT + + 4.0.0 + + resttemplate-commons + + resttemplate-commons + + + 4.3.10.RELEASE + + + + + org.springframework + spring-web + ${spring-web.version} + provided + + + + org.apache.skywalking + spring-commons + ${project.version} + + + 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/FutureGetInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/FutureGetInterceptor.java similarity index 100% rename from apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/FutureGetInterceptor.java rename to apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/FutureGetInterceptor.java 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/ResponseCallBackInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/ResponseCallBackInterceptor.java similarity index 100% rename from apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/ResponseCallBackInterceptor.java rename to apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/ResponseCallBackInterceptor.java 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-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/RestExecuteInterceptor.java similarity index 100% rename from apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/RestExecuteInterceptor.java rename to apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/RestExecuteInterceptor.java 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/RestRequestInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/RestRequestInterceptor.java similarity index 100% rename from apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/RestRequestInterceptor.java rename to apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/RestRequestInterceptor.java 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/define/ResponseExtractorFutureInstrumentation.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/define/ResponseExtractorFutureInstrumentation.java similarity index 93% rename from apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/define/ResponseExtractorFutureInstrumentation.java rename to apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/define/ResponseExtractorFutureInstrumentation.java index cc4208592..f9497fa92 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/define/ResponseExtractorFutureInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/define/ResponseExtractorFutureInstrumentation.java @@ -41,7 +41,7 @@ import static net.bytebuddy.matcher.ElementMatchers.named; * {@link ResponseCallBackInterceptor} set the {@link URI} and {@link ContextSnapshot} to inherited * org.springframework.util.concurrent.SuccessCallback and org.springframework.util.concurrent.FailureCallback */ -public class ResponseExtractorFutureInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { +public abstract class ResponseExtractorFutureInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { private static final String ADD_CALLBACK_METHOD_NAME = "addCallback"; private static final String ADD_CALLBACK_INTERCEPTOR = "org.apache.skywalking.apm.plugin.spring.resttemplate.async.ResponseCallBackInterceptor"; @@ -97,11 +97,4 @@ public class ResponseExtractorFutureInstrumentation extends ClassInstanceMethods protected ClassMatch enhanceClass() { return NameMatch.byName(ENHANCE_CLASS); } - - @Override - protected String[] witnessClasses() { - return new String[] { - "org.springframework.web.context.support.ServletContextAttributeFactoryBean" - }; - } } 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/define/RestTemplateInstrumentation.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/define/RestTemplateInstrumentation.java similarity index 93% rename from apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/define/RestTemplateInstrumentation.java rename to apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/define/RestTemplateInstrumentation.java index c0722f832..d7e914524 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/define/RestTemplateInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/async/define/RestTemplateInstrumentation.java @@ -39,7 +39,7 @@ import static net.bytebuddy.matcher.ElementMatchers.named; * org.springframework.web.client.AsyncRestTemplate$ResponseExtractorFuture for propagate trace context * after execute doExecute . */ -public class RestTemplateInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { +public abstract class RestTemplateInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { private static final String ENHANCE_CLASS = "org.springframework.web.client.AsyncRestTemplate"; private static final String DO_EXECUTE_METHOD_NAME = "doExecute"; @@ -94,11 +94,4 @@ public class RestTemplateInstrumentation extends ClassInstanceMethodsEnhancePlug protected ClassMatch enhanceClass() { return NameMatch.byName(ENHANCE_CLASS); } - - @Override - protected String[] witnessClasses() { - return new String[] { - "org.springframework.web.context.support.ServletContextAttributeFactoryBean" - }; - } } diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/helper/RestTemplateRuntimeContextHelper.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/helper/RestTemplateRuntimeContextHelper.java similarity index 100% rename from apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/helper/RestTemplateRuntimeContextHelper.java rename to apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/helper/RestTemplateRuntimeContextHelper.java 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-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/RestExecuteInterceptor.java similarity index 100% rename from apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/RestExecuteInterceptor.java rename to apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/RestExecuteInterceptor.java 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/RestRequestInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/RestRequestInterceptor.java similarity index 100% rename from apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/RestRequestInterceptor.java rename to apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/RestRequestInterceptor.java 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/RestResponseInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/RestResponseInterceptor.java similarity index 100% rename from apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/RestResponseInterceptor.java rename to apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/RestResponseInterceptor.java 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/define/RestTemplateInstrumentation.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/define/RestTemplateInstrumentation.java similarity index 94% rename from apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/define/RestTemplateInstrumentation.java rename to apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/define/RestTemplateInstrumentation.java index 9c98b81c5..8089e2a7b 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/define/RestTemplateInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-commons/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/sync/define/RestTemplateInstrumentation.java @@ -38,7 +38,7 @@ import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName * RestResponseInterceptor set context to header for * propagate trace context after execute createRequest. */ -public class RestTemplateInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { +public abstract class RestTemplateInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { private static final String ENHANCE_CLASS = "org.springframework.web.client.RestTemplate"; private static final String DO_EXECUTE_METHOD_NAME = "doExecute"; @@ -111,11 +111,4 @@ public class RestTemplateInstrumentation extends ClassInstanceMethodsEnhancePlug protected ClassMatch enhanceClass() { return byName(ENHANCE_CLASS); } - - @Override - protected String[] witnessClasses() { - return new String[] { - "org.springframework.web.context.support.ServletContextAttributeFactoryBean" - }; - } } diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/resttemplate-6.x-plugin/pom.xml b/apm-sniffer/optional-plugins/optional-spring-plugins/resttemplate-6.x-plugin/pom.xml index ecad2c024..0cd440c1b 100644 --- a/apm-sniffer/optional-plugins/optional-spring-plugins/resttemplate-6.x-plugin/pom.xml +++ b/apm-sniffer/optional-plugins/optional-spring-plugins/resttemplate-6.x-plugin/pom.xml @@ -47,5 +47,11 @@ spring-commons ${project.version} + + + org.apache.skywalking + resttemplate-commons + ${project.version} + diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/resttemplate-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/v6x/helper/RestTemplateRuntimeContextHelper.java b/apm-sniffer/optional-plugins/optional-spring-plugins/resttemplate-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/v6x/helper/RestTemplateRuntimeContextHelper.java deleted file mode 100644 index bed866a0b..000000000 --- a/apm-sniffer/optional-plugins/optional-spring-plugins/resttemplate-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/v6x/helper/RestTemplateRuntimeContextHelper.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.resttemplate.v6x.helper; - -import org.apache.skywalking.apm.agent.core.context.ContextCarrier; -import org.apache.skywalking.apm.agent.core.context.ContextManager; - -public class RestTemplateRuntimeContextHelper { - - private static final String REST_TEMPLATE_CONTEXT_CARRIER_KEY_IN_RUNTIME_CONTEXT = "REST_TEMPLATE_CONTEXT_CARRIER"; - - private static final String REST_TEMPLATE_URI_KEY_IN_RUNTIME_CONTEXT = "REST_TEMPLATE_URI"; - - public static void cleanUri() { - ContextManager.getRuntimeContext().remove(REST_TEMPLATE_URI_KEY_IN_RUNTIME_CONTEXT); - } - - public static void cleanContextCarrier() { - ContextManager.getRuntimeContext().remove(REST_TEMPLATE_CONTEXT_CARRIER_KEY_IN_RUNTIME_CONTEXT); - } - - public static void addUri(String uri) { - ContextManager.getRuntimeContext().put(REST_TEMPLATE_URI_KEY_IN_RUNTIME_CONTEXT, uri); - } - - public static void addContextCarrier(ContextCarrier contextCarrier) { - ContextManager.getRuntimeContext().put(REST_TEMPLATE_CONTEXT_CARRIER_KEY_IN_RUNTIME_CONTEXT, contextCarrier); - } - - public static String getUri() { - return (String) ContextManager.getRuntimeContext().get(REST_TEMPLATE_URI_KEY_IN_RUNTIME_CONTEXT); - } - - public static ContextCarrier getContextCarrier() { - return (ContextCarrier) ContextManager.getRuntimeContext().get(REST_TEMPLATE_CONTEXT_CARRIER_KEY_IN_RUNTIME_CONTEXT); - } -} diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/resttemplate-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/v6x/sync/RestExecuteInterceptor.java b/apm-sniffer/optional-plugins/optional-spring-plugins/resttemplate-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/v6x/sync/RestExecuteInterceptor.java index 7b9e7398e..b4fff5568 100644 --- a/apm-sniffer/optional-plugins/optional-spring-plugins/resttemplate-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/v6x/sync/RestExecuteInterceptor.java +++ b/apm-sniffer/optional-plugins/optional-spring-plugins/resttemplate-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/v6x/sync/RestExecuteInterceptor.java @@ -29,7 +29,7 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedI 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.apache.skywalking.apm.plugin.spring.resttemplate.v6x.helper.RestTemplateRuntimeContextHelper; +import org.apache.skywalking.apm.plugin.spring.resttemplate.helper.RestTemplateRuntimeContextHelper; import org.springframework.http.HttpMethod; public class RestExecuteInterceptor implements InstanceMethodsAroundInterceptor { diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/resttemplate-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/v6x/sync/RestRequestInterceptor.java b/apm-sniffer/optional-plugins/optional-spring-plugins/resttemplate-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/v6x/sync/RestRequestInterceptor.java index 455b897c5..f8bbd6bac 100644 --- a/apm-sniffer/optional-plugins/optional-spring-plugins/resttemplate-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/v6x/sync/RestRequestInterceptor.java +++ b/apm-sniffer/optional-plugins/optional-spring-plugins/resttemplate-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/v6x/sync/RestRequestInterceptor.java @@ -24,7 +24,7 @@ import org.apache.skywalking.apm.agent.core.context.ContextCarrier; 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.plugin.spring.resttemplate.v6x.helper.RestTemplateRuntimeContextHelper; +import org.apache.skywalking.apm.plugin.spring.resttemplate.helper.RestTemplateRuntimeContextHelper; import org.springframework.http.client.AbstractClientHttpRequest; import org.springframework.http.client.ClientHttpRequest; diff --git a/apm-sniffer/optional-plugins/optional-spring-plugins/resttemplate-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/v6x/sync/define/RestTemplateInstrumentation.java b/apm-sniffer/optional-plugins/optional-spring-plugins/resttemplate-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/v6x/sync/define/RestTemplateInstrumentation.java index c9fdb3823..2c22415b4 100644 --- a/apm-sniffer/optional-plugins/optional-spring-plugins/resttemplate-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/v6x/sync/define/RestTemplateInstrumentation.java +++ b/apm-sniffer/optional-plugins/optional-spring-plugins/resttemplate-6.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/resttemplate/v6x/sync/define/RestTemplateInstrumentation.java @@ -26,6 +26,7 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterc import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; import static net.bytebuddy.matcher.ElementMatchers.named; +import static net.bytebuddy.matcher.ElementMatchers.takesArgument; import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName; /** @@ -59,7 +60,9 @@ public class RestTemplateInstrumentation extends ClassInstanceMethodsEnhancePlug new InstanceMethodsInterceptPoint() { @Override public ElementMatcher getMethodsMatcher() { - return named(DO_EXECUTE_METHOD_NAME); + return named(DO_EXECUTE_METHOD_NAME) + .and(takesArgument(0, named("java.net.URI"))) + .and(takesArgument(2, named("org.springframework.http.HttpMethod"))); } @Override @@ -115,7 +118,7 @@ public class RestTemplateInstrumentation extends ClassInstanceMethodsEnhancePlug @Override protected String[] witnessClasses() { return new String[] { - "org.springframework.web.client.ClientHttpResponseDecorator" + "org.springframework.http.client.reactive.JdkClientHttpConnector" }; } } diff --git a/docs/en/setup/service-agent/java-agent/Plugin-list.md b/docs/en/setup/service-agent/java-agent/Plugin-list.md index e99b67b09..aeea1528c 100644 --- a/docs/en/setup/service-agent/java-agent/Plugin-list.md +++ b/docs/en/setup/service-agent/java-agent/Plugin-list.md @@ -105,6 +105,7 @@ - spring-mvc-annotation-4.x - spring-mvc-annotation-5.x - spring-mvc-annotation-6.x +- spring-resttemplate-3.x - spring-resttemplate-4.x - spring-resttemplate-6.x - spring-scheduled-annotation