Skip to content

Commit 162e088

Browse files
committed
Add E2E test scenario for spring-kafka 3.3.10
1 parent 6d27462 commit 162e088

File tree

14 files changed

+622
-10
lines changed

14 files changed

+622
-10
lines changed

.github/workflows/plugins-test.3.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ jobs:
8181
- spring-kafka-1.3.x-scenario
8282
- spring-kafka-2.2.x-scenario
8383
- spring-kafka-2.3.x-scenario
84+
- spring-kafka-3.3.x-scenario
8485
- spring-scheduled-3.x-5.x-scenario
8586
- elasticjob-2.x-scenario
8687
- quartz-scheduler-2.x-scenario

CHANGES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Release Notes.
2020
* Eliminate repeated code with HttpServletRequestWrapper in mvc-annotation-commons.
2121
* Add the jdk httpclient plugin.
2222
* Fix Gateway 2.0.x plugin not activated for spring-cloud-starter-gateway 2.0.0.RELEASE.
23-
* Enhance spring-kafka plugin to support kafka-clients 3.7.1+ with spring-kafka 3.1.0+
24-
* Upgrade kafka-clients version in optional-reporter-plugins to 3.9.1
23+
* Enhance spring-kafka plugin to support spring-kafka 3.1.0+ and rename spring-kafka-2.x-plugin to spring-kafka-2.x-3.x-plugin.
24+
* Upgrade kafka-clients version in optional-reporter-plugins to 3.9.1.
2525

2626
All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/242?closed=1)
2727

apm-sniffer/apm-sdk-plugin/spring-plugins/spring-kafka-2.x-3.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/kafka/ExtendedConstructorInterceptPoint.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@
1818

1919
package org.apache.skywalking.apm.plugin.spring.kafka;
2020

21+
import java.util.List;
22+
import java.util.Map;
2123
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
2224
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
23-
import org.apache.skywalking.apm.util.StringUtil;
2425

2526
public class ExtendedConstructorInterceptPoint implements InstanceConstructorInterceptor {
27+
2628
@Override
2729
public void onConstruct(final EnhancedInstance objInst, final Object[] allArguments) throws Throwable {
2830
ExtendedConsumerEnhanceRequiredInfo requiredInfo = new ExtendedConsumerEnhanceRequiredInfo();
@@ -36,7 +38,7 @@ private void extractConsumerConfig(Object[] allArguments, ExtendedConsumerEnhanc
3638
}
3739

3840
for (Object arg : allArguments) {
39-
if (arg instanceof java.util.Map) {
41+
if (arg instanceof Map) {
4042
extractConfigFromMap(arg, requiredInfo);
4143
break;
4244
}
@@ -45,12 +47,12 @@ private void extractConsumerConfig(Object[] allArguments, ExtendedConsumerEnhanc
4547

4648
private void extractConfigFromMap(Object arg, ExtendedConsumerEnhanceRequiredInfo requiredInfo) {
4749
try {
48-
java.util.Map<String, Object> configMap = (java.util.Map<String, Object>) arg;
50+
Map<String, Object> configMap = (Map<String, Object>) arg;
4951
Object bootstrapServers = configMap.get("bootstrap.servers");
50-
if (bootstrapServers instanceof java.util.List) {
51-
requiredInfo.setBrokerServers(StringUtil.join(';', String.valueOf(bootstrapServers)));
52+
if (bootstrapServers instanceof List) {
53+
requiredInfo.setBrokerServers(String.join(";", (List<String>) bootstrapServers));
5254
} else if (bootstrapServers != null) {
53-
requiredInfo.setBrokerServers(bootstrapServers.toString());
55+
requiredInfo.setBrokerServers(String.valueOf(bootstrapServers).trim().replaceAll("\\s*,\\s*", ";"));
5456
}
5557

5658
Object groupId = configMap.get("group.id");
@@ -62,4 +64,4 @@ private void extractConfigFromMap(Object arg, ExtendedConsumerEnhanceRequiredInf
6264
}
6365
}
6466

65-
}
67+
}

docs/en/setup/service-agent/java-agent/Plugin-list.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@
111111
- spring-concurrent-util-4.x
112112
- spring-core-patch
113113
- spring-kafka-1.x
114-
- spring-kafka-2.x/3.x
114+
- spring-kafka-2.x
115+
- spring-kafka-3.x
115116
- spring-mvc-annotation
116117
- spring-mvc-annotation-3.x
117118
- spring-mvc-annotation-4.x
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
19+
home="$(cd "$(dirname $0)"; pwd)"
20+
21+
java -Dbootstrap.servers=${BOOTSTRAP_SERVERS} -jar ${agent_opts} "-Dskywalking.agent.service_name=spring-kafka-3.3.x-scenario" ${home}/../libs/spring-kafka-3.3.x-scenario.jar &
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
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+
segmentItems:
17+
- serviceName: spring-kafka-3.3.x-scenario
18+
segmentSize: nq 0
19+
segments:
20+
- segmentId: not null
21+
spans:
22+
- operationName: Kafka/spring_test/Producer
23+
parentSpanId: 0
24+
spanId: 1
25+
spanLayer: MQ
26+
startTime: not null
27+
endTime: not null
28+
componentId: 40
29+
isError: false
30+
spanType: Exit
31+
peer: kafka-server:9092
32+
skipAnalysis: false
33+
tags:
34+
- {key: mq.broker, value: 'kafka-server:9092'}
35+
- {key: mq.topic, value: spring_test}
36+
- operationName: Kafka/spring_test/Producer
37+
parentSpanId: 0
38+
spanId: 2
39+
spanLayer: MQ
40+
startTime: not null
41+
endTime: not null
42+
componentId: 40
43+
isError: false
44+
spanType: Exit
45+
peer: kafka-server:9092
46+
skipAnalysis: false
47+
tags:
48+
- { key: mq.broker, value: 'kafka-server:9092' }
49+
- { key: mq.topic, value: spring_test }
50+
- operationName: GET:/case/spring-kafka-case
51+
parentSpanId: -1
52+
spanId: 0
53+
spanLayer: Http
54+
startTime: not null
55+
endTime: not null
56+
componentId: 14
57+
isError: false
58+
spanType: Entry
59+
peer: ''
60+
skipAnalysis: false
61+
tags:
62+
- {key: url, value: 'http://localhost:8080/spring-kafka-3.3.x-scenario/case/spring-kafka-case'}
63+
- {key: http.method, value: GET}
64+
- {key: http.status_code, value: '200'}
65+
- segmentId: not null
66+
spans:
67+
- operationName: GET:/case/spring-kafka-consumer-ping
68+
parentSpanId: -1
69+
spanId: 0
70+
spanLayer: Http
71+
startTime: not null
72+
endTime: not null
73+
componentId: 14
74+
isError: false
75+
spanType: Entry
76+
peer: ''
77+
skipAnalysis: false
78+
tags:
79+
- {key: url, value: 'http://localhost:8080/spring-kafka-3.3.x-scenario/case/spring-kafka-consumer-ping'}
80+
- {key: http.method, value: GET}
81+
- {key: http.status_code, value: '200'}
82+
refs:
83+
- {parentEndpoint: 'Kafka/spring_test/Consumer/group:spring_test', networkAddress: 'localhost:8080',
84+
refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null,
85+
parentServiceInstance: not null, parentService: spring-kafka-3.3.x-scenario,
86+
traceId: not null}
87+
- segmentId: not null
88+
spans:
89+
- operationName: /spring-kafka-3.3.x-scenario/case/spring-kafka-consumer-ping
90+
parentSpanId: 0
91+
spanId: 1
92+
spanLayer: Http
93+
startTime: not null
94+
endTime: not null
95+
componentId: 12
96+
isError: false
97+
spanType: Exit
98+
peer: localhost:8080
99+
skipAnalysis: false
100+
tags:
101+
- {key: http.method, value: GET}
102+
- {key: url, value: 'http://localhost:8080/spring-kafka-3.3.x-scenario/case/spring-kafka-consumer-ping'}
103+
- {key: http.status_code, value: '200'}
104+
- operationName: Kafka/spring_test/Consumer/group:spring_test
105+
parentSpanId: -1
106+
spanId: 0
107+
spanLayer: MQ
108+
startTime: not null
109+
endTime: not null
110+
componentId: 41
111+
isError: false
112+
spanType: Entry
113+
peer: kafka-server:9092
114+
skipAnalysis: false
115+
tags:
116+
- {key: mq.broker, value: 'kafka-server:9092'}
117+
- {key: mq.topic, value: spring_test}
118+
- {key: transmission.latency, value: not null}
119+
refs:
120+
- {parentEndpoint: GET:/case/spring-kafka-case, networkAddress: 'kafka-server:9092',
121+
refType: CrossProcess, parentSpanId: not null, parentTraceSegmentId: not null,
122+
parentServiceInstance: not null, parentService: spring-kafka-3.3.x-scenario,
123+
traceId: not null}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
type: jvm
18+
entryService: http://localhost:8080/spring-kafka-3.3.x-scenario/case/spring-kafka-case
19+
healthCheck: http://localhost:8080/spring-kafka-3.3.x-scenario/case/healthCheck
20+
startScript: ./bin/startup.sh
21+
environment:
22+
- BOOTSTRAP_SERVERS=kafka-server:9092
23+
depends_on:
24+
- zookeeper-server
25+
- kafka-server
26+
dependencies:
27+
zookeeper-server:
28+
image: zookeeper:3.4
29+
hostname: zookeeper-server
30+
kafka-server:
31+
image: bitnamilegacy/kafka:2.4.1
32+
hostname: kafka-server
33+
environment:
34+
- KAFKA_ZOOKEEPER_CONNECT=zookeeper-server:2181
35+
- KAFKA_BROKER_ID=1
36+
- ALLOW_PLAINTEXT_LISTENER=yes
37+
- KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092
38+
depends_on:
39+
- zookeeper-server
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one or more
4+
~ contributor license agreements. See the NOTICE file distributed with
5+
~ this work for additional information regarding copyright ownership.
6+
~ The ASF licenses this file to You under the Apache License, Version 2.0
7+
~ (the "License"); you may not use this file except in compliance with
8+
~ the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License.
17+
~
18+
-->
19+
<project xmlns="http://maven.apache.org/POM/4.0.0"
20+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
21+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
22+
<modelVersion>4.0.0</modelVersion>
23+
24+
<groupId>org.apache.skywalking</groupId>
25+
<artifactId>spring-kafka-3.3.x-scenario</artifactId>
26+
<version>5.0.0</version>
27+
28+
<properties>
29+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
30+
<compiler.version>1.8</compiler.version>
31+
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
32+
<test.framework.version>3.3.10</test.framework.version>
33+
<log4j.version>2.6.2</log4j.version>
34+
<spring.boot.version>3.3.10</spring.boot.version>
35+
<kafka-version>3.9.1</kafka-version>
36+
<okhttp-version>3.0.0</okhttp-version>
37+
</properties>
38+
39+
<name>skywalking-spring-kafka-3.3.x-scenario</name>
40+
41+
<dependencies>
42+
<dependency>
43+
<groupId>org.springframework.boot</groupId>
44+
<artifactId>spring-boot-starter-web</artifactId>
45+
<version>${spring.boot.version}</version>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.springframework.kafka</groupId>
49+
<artifactId>spring-kafka</artifactId>
50+
<version>${test.framework.version}</version>
51+
<exclusions>
52+
<exclusion>
53+
<groupId>org.slf4j</groupId>
54+
<artifactId>*</artifactId>
55+
</exclusion>
56+
</exclusions>
57+
</dependency>
58+
<dependency>
59+
<groupId>org.apache.kafka</groupId>
60+
<artifactId>kafka-clients</artifactId>
61+
<version>${kafka-version}</version>
62+
<exclusions>
63+
<exclusion>
64+
<artifactId>slf4j-api</artifactId>
65+
<groupId>*</groupId>
66+
</exclusion>
67+
</exclusions>
68+
</dependency>
69+
<dependency>
70+
<groupId>com.squareup.okhttp3</groupId>
71+
<artifactId>okhttp</artifactId>
72+
<version>${okhttp-version}</version>
73+
</dependency>
74+
</dependencies>
75+
76+
<build>
77+
<finalName>spring-kafka-3.3.x-scenario</finalName>
78+
<plugins>
79+
<plugin>
80+
<groupId>org.springframework.boot</groupId>
81+
<artifactId>spring-boot-maven-plugin</artifactId>
82+
<version>${spring.boot.version}</version>
83+
<executions>
84+
<execution>
85+
<goals>
86+
<goal>repackage</goal>
87+
</goals>
88+
</execution>
89+
</executions>
90+
</plugin>
91+
<plugin>
92+
<artifactId>maven-compiler-plugin</artifactId>
93+
<version>${maven-compiler-plugin.version}</version>
94+
<configuration>
95+
<source>${compiler.version}</source>
96+
<target>${compiler.version}</target>
97+
<encoding>${project.build.sourceEncoding}</encoding>
98+
</configuration>
99+
</plugin>
100+
<plugin>
101+
<groupId>org.apache.maven.plugins</groupId>
102+
<artifactId>maven-assembly-plugin</artifactId>
103+
<executions>
104+
<execution>
105+
<id>assemble</id>
106+
<phase>package</phase>
107+
<goals>
108+
<goal>single</goal>
109+
</goals>
110+
<configuration>
111+
<descriptors>
112+
<descriptor>src/main/assembly/assembly.xml</descriptor>
113+
</descriptors>
114+
<outputDirectory>./target/</outputDirectory>
115+
</configuration>
116+
</execution>
117+
</executions>
118+
</plugin>
119+
</plugins>
120+
</build>
121+
122+
<pluginRepositories>
123+
<pluginRepository>
124+
<id>spring-snapshots</id>
125+
<url>https://repo.spring.io/snapshot</url>
126+
</pluginRepository>
127+
<pluginRepository>
128+
<id>spring-milestones</id>
129+
<url>https://repo.spring.io/milestone</url>
130+
</pluginRepository>
131+
</pluginRepositories>
132+
</project>

0 commit comments

Comments
 (0)