Fix Spring 6 test case (#463)
This commit is contained in:
parent
20c8b98cd9
commit
0b1af4fd18
|
|
@ -30,6 +30,7 @@
|
|||
<modules>
|
||||
<module>async-annotation-plugin</module>
|
||||
<module>concurrent-util-4.x-plugin</module>
|
||||
<module>resttemplate-3.x-plugin</module>
|
||||
<module>resttemplate-4.x-plugin</module>
|
||||
<module>mvc-annotation-4.x-plugin</module>
|
||||
<module>spring-cloud</module>
|
||||
|
|
@ -42,6 +43,7 @@
|
|||
<module>spring-kafka-2.x-plugin</module>
|
||||
<module>scheduled-annotation-plugin</module>
|
||||
<module>spring-webflux-5.x-webclient-plugin</module>
|
||||
<module>resttemplate-commons</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
~
|
||||
-->
|
||||
|
||||
<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>
|
||||
<version>8.15.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>apm-resttemplate-3.x-plugin</artifactId>
|
||||
|
||||
<name>resttemplate-3.x-plugin</name>
|
||||
|
||||
<properties>
|
||||
<spring-web.version>3.2.18.RELEASE</spring-web.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
<version>${spring-web.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
<artifactId>spring-commons</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
<artifactId>resttemplate-commons</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -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 <code>addCallback</code> method and
|
||||
* <code>getDefault</code> method of <code>org.springframework.web.client.AsyncRestTemplate$ResponseExtractorFuture</code>
|
||||
* by
|
||||
* <code>ResponseCallBackInterceptor</code> and
|
||||
* <code>FutureGetInterceptor</code>.
|
||||
* <p>
|
||||
* {@link ResponseCallBackInterceptor} set the {@link URI} and {@link ContextSnapshot} to inherited
|
||||
* <code>org.springframework.util.concurrent.SuccessCallback</code> and <code>org.springframework.util.concurrent.FailureCallback</code>
|
||||
*/
|
||||
public class ResponseExtractorFutureInstrumentation3x extends ResponseExtractorFutureInstrumentation {
|
||||
@Override
|
||||
protected String[] witnessClasses() {
|
||||
return new String[] {
|
||||
"org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -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 <code>doExecute</code> method and <code>createAsyncRequest</code>
|
||||
* method of <code>org.springframework.web.client.AsyncRestTemplate</code> by <code>RestExecuteInterceptor</code> and
|
||||
* <code>org.springframework.http.client.RestRequestInterceptor</code>.
|
||||
*
|
||||
* <code>org.springframework.http.client.RestRequestInterceptor</code> set {@link URI} and {@link ContextSnapshot} to
|
||||
* <code>org.springframework.web.client.AsyncRestTemplate$ResponseExtractorFuture</code> for propagate trace context
|
||||
* after execute <code>doExecute</code> .
|
||||
*/
|
||||
public class RestTemplateInstrumentation3x extends RestTemplateInstrumentation {
|
||||
@Override
|
||||
protected String[] witnessClasses() {
|
||||
return new String[] {
|
||||
"org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -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 <code>doExecute</code> method,<code>handleResponse</code> method and
|
||||
* <code>handleResponse</code> method of <code>org.springframework.web.client.RestTemplate</code> by
|
||||
* <code>RestExecuteInterceptor</code>,
|
||||
* <code>RestResponseInterceptor</code> and
|
||||
* <code>RestRequestInterceptor</code>.
|
||||
*
|
||||
* <code>RestResponseInterceptor</code> set context to header for
|
||||
* propagate trace context after execute <code>createRequest</code>.
|
||||
*/
|
||||
public class RestTemplateInstrumentation3x extends RestTemplateInstrumentation {
|
||||
@Override
|
||||
protected String[] witnessClasses() {
|
||||
return new String[] {
|
||||
"org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -47,5 +47,10 @@
|
|||
<artifactId>spring-commons</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
<artifactId>resttemplate-commons</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -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 <code>addCallback</code> method and
|
||||
* <code>getDefault</code> method of <code>org.springframework.web.client.AsyncRestTemplate$ResponseExtractorFuture</code>
|
||||
* by
|
||||
* <code>ResponseCallBackInterceptor</code> and
|
||||
* <code>FutureGetInterceptor</code>.
|
||||
* <p>
|
||||
* {@link ResponseCallBackInterceptor} set the {@link URI} and {@link ContextSnapshot} to inherited
|
||||
* <code>org.springframework.util.concurrent.SuccessCallback</code> and <code>org.springframework.util.concurrent.FailureCallback</code>
|
||||
*/
|
||||
public class ResponseExtractorFutureInstrumentation4x extends ResponseExtractorFutureInstrumentation {
|
||||
@Override
|
||||
protected String[] witnessClasses() {
|
||||
return new String[] {
|
||||
"org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -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 <code>doExecute</code> method and <code>createAsyncRequest</code>
|
||||
* method of <code>org.springframework.web.client.AsyncRestTemplate</code> by <code>RestExecuteInterceptor</code> and
|
||||
* <code>org.springframework.http.client.RestRequestInterceptor</code>.
|
||||
*
|
||||
* <code>org.springframework.http.client.RestRequestInterceptor</code> set {@link URI} and {@link ContextSnapshot} to
|
||||
* <code>org.springframework.web.client.AsyncRestTemplate$ResponseExtractorFuture</code> for propagate trace context
|
||||
* after execute <code>doExecute</code> .
|
||||
*/
|
||||
public class RestTemplateInstrumentation4x extends RestTemplateInstrumentation {
|
||||
@Override
|
||||
protected String[] witnessClasses() {
|
||||
return new String[] {
|
||||
"org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -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 <code>doExecute</code> method,<code>handleResponse</code> method and
|
||||
* <code>handleResponse</code> method of <code>org.springframework.web.client.RestTemplate</code> by
|
||||
* <code>RestExecuteInterceptor</code>,
|
||||
* <code>RestResponseInterceptor</code> and
|
||||
* <code>RestRequestInterceptor</code>.
|
||||
*
|
||||
* <code>RestResponseInterceptor</code> set context to header for
|
||||
* propagate trace context after execute <code>createRequest</code>.
|
||||
*/
|
||||
public class RestTemplateInstrumentation4x extends RestTemplateInstrumentation {
|
||||
@Override
|
||||
protected String[] witnessClasses() {
|
||||
return new String[] {
|
||||
"org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
<!--
|
||||
~ 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.
|
||||
~
|
||||
-->
|
||||
|
||||
<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>
|
||||
<version>8.15.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>resttemplate-commons</artifactId>
|
||||
|
||||
<name>resttemplate-commons</name>
|
||||
|
||||
<properties>
|
||||
<spring-web.version>4.3.10.RELEASE</spring-web.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-web</artifactId>
|
||||
<version>${spring-web.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
<artifactId>spring-commons</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -41,7 +41,7 @@ import static net.bytebuddy.matcher.ElementMatchers.named;
|
|||
* {@link ResponseCallBackInterceptor} set the {@link URI} and {@link ContextSnapshot} to inherited
|
||||
* <code>org.springframework.util.concurrent.SuccessCallback</code> and <code>org.springframework.util.concurrent.FailureCallback</code>
|
||||
*/
|
||||
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"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -39,7 +39,7 @@ import static net.bytebuddy.matcher.ElementMatchers.named;
|
|||
* <code>org.springframework.web.client.AsyncRestTemplate$ResponseExtractorFuture</code> for propagate trace context
|
||||
* after execute <code>doExecute</code> .
|
||||
*/
|
||||
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"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -38,7 +38,7 @@ import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName
|
|||
* <code>RestResponseInterceptor</code> set context to header for
|
||||
* propagate trace context after execute <code>createRequest</code>.
|
||||
*/
|
||||
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"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -47,5 +47,11 @@
|
|||
<artifactId>spring-commons</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
<artifactId>resttemplate-commons</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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<MethodDescription> 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"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue