Skip to content

Commit 0b1af4f

Browse files
authored
Fix Spring 6 test case (#463)
1 parent 20c8b98 commit 0b1af4f

29 files changed

Lines changed: 393 additions & 84 deletions

File tree

apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
<modules>
3131
<module>async-annotation-plugin</module>
3232
<module>concurrent-util-4.x-plugin</module>
33+
<module>resttemplate-3.x-plugin</module>
3334
<module>resttemplate-4.x-plugin</module>
3435
<module>mvc-annotation-4.x-plugin</module>
3536
<module>spring-cloud</module>
@@ -42,6 +43,7 @@
4243
<module>spring-kafka-2.x-plugin</module>
4344
<module>scheduled-annotation-plugin</module>
4445
<module>spring-webflux-5.x-webclient-plugin</module>
46+
<module>resttemplate-commons</module>
4547
</modules>
4648
<packaging>pom</packaging>
4749

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<!--
2+
~ Licensed to the Apache Software Foundation (ASF) under one or more
3+
~ contributor license agreements. See the NOTICE file distributed with
4+
~ this work for additional information regarding copyright ownership.
5+
~ The ASF licenses this file to You under the Apache License, Version 2.0
6+
~ (the "License"); you may not use this file except in compliance with
7+
~ the License. You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
~
17+
-->
18+
19+
<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">
20+
<parent>
21+
<artifactId>spring-plugins</artifactId>
22+
<groupId>org.apache.skywalking</groupId>
23+
<version>8.15.0-SNAPSHOT</version>
24+
</parent>
25+
<modelVersion>4.0.0</modelVersion>
26+
27+
<artifactId>apm-resttemplate-3.x-plugin</artifactId>
28+
29+
<name>resttemplate-3.x-plugin</name>
30+
31+
<properties>
32+
<spring-web.version>3.2.18.RELEASE</spring-web.version>
33+
</properties>
34+
35+
<dependencies>
36+
<dependency>
37+
<groupId>org.springframework</groupId>
38+
<artifactId>spring-web</artifactId>
39+
<version>${spring-web.version}</version>
40+
<scope>provided</scope>
41+
</dependency>
42+
43+
<dependency>
44+
<groupId>org.apache.skywalking</groupId>
45+
<artifactId>spring-commons</artifactId>
46+
<version>${project.version}</version>
47+
</dependency>
48+
<dependency>
49+
<groupId>org.apache.skywalking</groupId>
50+
<artifactId>resttemplate-commons</artifactId>
51+
<version>${project.version}</version>
52+
</dependency>
53+
</dependencies>
54+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.apm.plugin.spring.resttemplate.async.define;
20+
21+
import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
22+
import org.apache.skywalking.apm.plugin.spring.resttemplate.async.ResponseCallBackInterceptor;
23+
24+
import java.net.URI;
25+
26+
/**
27+
* {@link ResponseExtractorFutureInstrumentation3x} enhance the <code>addCallback</code> method and
28+
* <code>getDefault</code> method of <code>org.springframework.web.client.AsyncRestTemplate$ResponseExtractorFuture</code>
29+
* by
30+
* <code>ResponseCallBackInterceptor</code> and
31+
* <code>FutureGetInterceptor</code>.
32+
* <p>
33+
* {@link ResponseCallBackInterceptor} set the {@link URI} and {@link ContextSnapshot} to inherited
34+
* <code>org.springframework.util.concurrent.SuccessCallback</code> and <code>org.springframework.util.concurrent.FailureCallback</code>
35+
*/
36+
public class ResponseExtractorFutureInstrumentation3x extends ResponseExtractorFutureInstrumentation {
37+
@Override
38+
protected String[] witnessClasses() {
39+
return new String[] {
40+
"org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer"
41+
};
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.apm.plugin.spring.resttemplate.async.define;
20+
21+
import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
22+
23+
import java.net.URI;
24+
25+
/**
26+
* {@link RestTemplateInstrumentation3x} enhance the <code>doExecute</code> method and <code>createAsyncRequest</code>
27+
* method of <code>org.springframework.web.client.AsyncRestTemplate</code> by <code>RestExecuteInterceptor</code> and
28+
* <code>org.springframework.http.client.RestRequestInterceptor</code>.
29+
*
30+
* <code>org.springframework.http.client.RestRequestInterceptor</code> set {@link URI} and {@link ContextSnapshot} to
31+
* <code>org.springframework.web.client.AsyncRestTemplate$ResponseExtractorFuture</code> for propagate trace context
32+
* after execute <code>doExecute</code> .
33+
*/
34+
public class RestTemplateInstrumentation3x extends RestTemplateInstrumentation {
35+
@Override
36+
protected String[] witnessClasses() {
37+
return new String[] {
38+
"org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer"
39+
};
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.apm.plugin.spring.resttemplate.sync.define;
20+
21+
/**
22+
* {@link RestTemplateInstrumentation} enhance the <code>doExecute</code> method,<code>handleResponse</code> method and
23+
* <code>handleResponse</code> method of <code>org.springframework.web.client.RestTemplate</code> by
24+
* <code>RestExecuteInterceptor</code>,
25+
* <code>RestResponseInterceptor</code> and
26+
* <code>RestRequestInterceptor</code>.
27+
*
28+
* <code>RestResponseInterceptor</code> set context to header for
29+
* propagate trace context after execute <code>createRequest</code>.
30+
*/
31+
public class RestTemplateInstrumentation3x extends RestTemplateInstrumentation {
32+
@Override
33+
protected String[] witnessClasses() {
34+
return new String[] {
35+
"org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer"
36+
};
37+
}
38+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
spring-resttemplate-3.x=org.apache.skywalking.apm.plugin.spring.resttemplate.sync.define.RestTemplateInstrumentation3x
18+
spring-resttemplate-3.x=org.apache.skywalking.apm.plugin.spring.resttemplate.async.define.ResponseExtractorFutureInstrumentation3x
19+
spring-resttemplate-3.x=org.apache.skywalking.apm.plugin.spring.resttemplate.async.define.RestTemplateInstrumentation3x

apm-sniffer/apm-sdk-plugin/spring-plugins/resttemplate-4.x-plugin/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,10 @@
4747
<artifactId>spring-commons</artifactId>
4848
<version>${project.version}</version>
4949
</dependency>
50+
<dependency>
51+
<groupId>org.apache.skywalking</groupId>
52+
<artifactId>resttemplate-commons</artifactId>
53+
<version>${project.version}</version>
54+
</dependency>
5055
</dependencies>
5156
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.apm.plugin.spring.resttemplate.async.define;
20+
21+
import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
22+
import org.apache.skywalking.apm.plugin.spring.resttemplate.async.ResponseCallBackInterceptor;
23+
24+
import java.net.URI;
25+
26+
/**
27+
* {@link ResponseExtractorFutureInstrumentation4x} enhance the <code>addCallback</code> method and
28+
* <code>getDefault</code> method of <code>org.springframework.web.client.AsyncRestTemplate$ResponseExtractorFuture</code>
29+
* by
30+
* <code>ResponseCallBackInterceptor</code> and
31+
* <code>FutureGetInterceptor</code>.
32+
* <p>
33+
* {@link ResponseCallBackInterceptor} set the {@link URI} and {@link ContextSnapshot} to inherited
34+
* <code>org.springframework.util.concurrent.SuccessCallback</code> and <code>org.springframework.util.concurrent.FailureCallback</code>
35+
*/
36+
public class ResponseExtractorFutureInstrumentation4x extends ResponseExtractorFutureInstrumentation {
37+
@Override
38+
protected String[] witnessClasses() {
39+
return new String[] {
40+
"org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor"
41+
};
42+
}
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.apm.plugin.spring.resttemplate.async.define;
20+
21+
import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
22+
23+
import java.net.URI;
24+
25+
/**
26+
* {@link RestTemplateInstrumentation4x} enhance the <code>doExecute</code> method and <code>createAsyncRequest</code>
27+
* method of <code>org.springframework.web.client.AsyncRestTemplate</code> by <code>RestExecuteInterceptor</code> and
28+
* <code>org.springframework.http.client.RestRequestInterceptor</code>.
29+
*
30+
* <code>org.springframework.http.client.RestRequestInterceptor</code> set {@link URI} and {@link ContextSnapshot} to
31+
* <code>org.springframework.web.client.AsyncRestTemplate$ResponseExtractorFuture</code> for propagate trace context
32+
* after execute <code>doExecute</code> .
33+
*/
34+
public class RestTemplateInstrumentation4x extends RestTemplateInstrumentation {
35+
@Override
36+
protected String[] witnessClasses() {
37+
return new String[] {
38+
"org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor"
39+
};
40+
}
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.apm.plugin.spring.resttemplate.sync.define;
20+
21+
/**
22+
* {@link RestTemplateInstrumentation} enhance the <code>doExecute</code> method,<code>handleResponse</code> method and
23+
* <code>handleResponse</code> method of <code>org.springframework.web.client.RestTemplate</code> by
24+
* <code>RestExecuteInterceptor</code>,
25+
* <code>RestResponseInterceptor</code> and
26+
* <code>RestRequestInterceptor</code>.
27+
*
28+
* <code>RestResponseInterceptor</code> set context to header for
29+
* propagate trace context after execute <code>createRequest</code>.
30+
*/
31+
public class RestTemplateInstrumentation4x extends RestTemplateInstrumentation {
32+
@Override
33+
protected String[] witnessClasses() {
34+
return new String[] {
35+
"org.springframework.remoting.httpinvoker.AbstractHttpInvokerRequestExecutor"
36+
};
37+
}
38+
}

0 commit comments

Comments
 (0)