Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix method name missing in spring-plugins:scheduled-annotation-plugin with spring 6.1.x #691

Merged
merged 3 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/plugins-jdk17-test.1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ jobs:
- activemq-artemis-2.x-scenario
- c3p0-0.9.0.x-0.9.1.x-scenario
- c3p0-0.9.2.x-0.10.x-scenario
- spring-scheduled-6.x-scenario
steps:
- uses: actions/checkout@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/plugins-test.3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
- spring-kafka-1.3.x-scenario
- spring-kafka-2.2.x-scenario
- spring-kafka-2.3.x-scenario
- spring-scheduled-scenario
- spring-scheduled-3.x-5.x-scenario
- elasticjob-2.x-scenario
- quartz-scheduler-2.x-scenario
- xxl-job-2.2.0-scenario
Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Release Notes.
* Use a daemon thread to flush logs.
* Fix typos in `URLParser`.
* Add support for `Derby`/`Sybase`/`SQLite`/`DB2`/`OceanBase` jdbc url format in `URLParser`.
* Optimize spring-plugins:scheduled-annotation-plugin compatibility.
CzyerChen marked this conversation as resolved.
Show resolved Hide resolved

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@ public ElementMatcher<MethodDescription> getConstructorMatcher() {
public String getConstructorInterceptor() {
return CONSTRUCTOR_WITH_STRING_INTERCEPTOR_CLASS;
}
},
new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return takesArguments(4)
.and(takesArgument(0, Object.class))
.and(takesArgument(1, Method.class));
}

@Override
public String getConstructorInterceptor() {
return CONSTRUCTOR_WITH_METHOD_INTERCEPTOR_CLASS;
}
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion docs/en/setup/service-agent/java-agent/Supported-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ metrics based on the tracing data.
* Scheduler
* [Elastic Job](https://github.com/elasticjob/elastic-job) 2.x
* [Apache ShardingSphere-Elasticjob](https://github.com/apache/shardingsphere-elasticjob) 3.x
* [Spring @Scheduled](https://github.com/spring-projects/spring-framework) 3.1+
* [Spring @Scheduled](https://github.com/spring-projects/spring-framework) 3.1.x -> 6.1.x
* [Quartz Scheduler](https://github.com/quartz-scheduler/quartz) 2.x (Optional²)
* [XXL Job](https://github.com/xuxueli/xxl-job) 2.x
* OpenTracing community supported
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public void sendNormalMessageAsync(String topic, String tag, String group) throw
.build();
try {
CompletableFuture<SendReceipt> future = producer.sendAsync(message);
future.join();
log.info("Send async message successfully");
SendReceipt sendReceipt = future.join();
log.info("Send async message successfully, messageId={}", sendReceipt.getMessageId());
} catch (Throwable t) {
log.error("Failed to send message", t);
}
Expand Down Expand Up @@ -142,17 +142,34 @@ public void simpleConsumes(List<String> topics,
.build();

Duration invisibleDuration = Duration.ofSeconds(duration);
final List<MessageView> messages = consumer.receive(maxMessageNum, invisibleDuration);
messages.forEach(messageView -> {
log.info("Received message: {}", messageView);
});
for (MessageView msg : messages) {
final MessageId messageId = msg.getMessageId();
try {
consumer.ack(msg);
log.info("Message is acknowledged successfully, messageId={}", messageId);
} catch (Throwable t) {
log.error("Message is failed to be acknowledged, messageId={}", messageId, t);
int counter = 0;
int checkCounter = 0;
while (true) {
final List<MessageView> messages = consumer.receive(maxMessageNum, invisibleDuration);
messages.forEach(messageView -> {
log.info("Received message: {}", messageView);
});
boolean finishFlag = false;
for (MessageView msg : messages) {
final MessageId messageId = msg.getMessageId();
try {
consumer.ack(msg);
log.info("Message is acknowledged successfully, messageId={}", messageId);
counter++;
if (counter >= 2) {
finishFlag = true;
}
} catch (Throwable t) {
log.error("Message is failed to be acknowledged, messageId={}", messageId, t);
}
}
checkCounter++;
if (finishFlag) {
break;
}
if (checkCounter >= 3) {
log.error("Message is failed to receive after 3 attempts");
break;
}
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# 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.
segmentItems:
- serviceName: spring-scheduled-3.x-5.x-scenario
segmentSize: ge 2
segments:
- segmentId: not null
spans:
- operationName: GET:/spring-scheduled-3.x-5.x-scenario/case/call
parentSpanId: -1
spanId: 0
spanLayer: Http
startTime: nq 0
endTime: nq 0
componentId: 1
isError: false
spanType: Entry
peer: ''
skipAnalysis: false
tags:
- {key: url, value: 'http://localhost:8080/spring-scheduled-3.x-5.x-scenario/case/call'}
- {key: http.method, value: GET}
- {key: http.status_code, value: '200'}
refs:
- {parentEndpoint: SpringScheduled/org.apache.skywalking.apm.testcase.spring.scheduled.job.SchedulingJob.work, networkAddress: 'localhost:8080', refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: not null, traceId: not null}
- segmentId: not null
spans:
- operationName: /spring-scheduled-3.x-5.x-scenario/case/call
parentSpanId: 0
spanId: 1
spanLayer: Http
startTime: not null
endTime: not null
componentId: 12
isError: false
spanType: Exit
peer: localhost:8080
skipAnalysis: false
tags:
- {key: http.method, value: GET}
- {key: url, value: 'http://localhost:8080/spring-scheduled-3.x-5.x-scenario/case/call'}
- {key: http.status_code, value: '200'}
- operationName: SpringScheduled/org.apache.skywalking.apm.testcase.spring.scheduled.job.SchedulingJob.work
parentSpanId: -1
spanId: 0
spanLayer: Unknown
startTime: not null
endTime: not null
componentId: 96
isError: false
spanType: Local
peer: ''
skipAnalysis: false
tags:
- {key: x-le, value: '{"logic-span":true}'}
Original file line number Diff line number Diff line change
@@ -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.

type: tomcat
entryService: http://localhost:8080/spring-scheduled-3.x-5.x-scenario/case/healthCheck
healthCheck: http://localhost:8080/spring-scheduled-3.x-5.x-scenario/case/healthCheck
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<groupId>org.apache.skywalking.apm.testcase</groupId>
<artifactId>spring-scheduled-scenario</artifactId>
<artifactId>spring-scheduled-3.x-5.x-scenario</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>

<modelVersion>4.0.0</modelVersion>

<name>skywalking-spring-scheduled-scenario</name>
<name>skywalking-spring-scheduled-3.x-5.x-scenario</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -92,7 +92,7 @@
</dependencies>

<build>
<finalName>spring-scheduled-scenario</finalName>
<finalName>spring-scheduled-3.x-5.x-scenario</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
Expand All @@ -109,7 +109,7 @@
<version>2.1</version>
<configuration>
<port>8080</port>
<path>/spring-scheduled-scenario</path>
<path>/spring-scheduled-3.x-5.x-scenario</path>
<uriEncoding>UTF-8</uriEncoding>
<server>tomcat7</server>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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.testcase.spring.scheduled.job;

import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import java.io.IOException;

@Configuration
@EnableScheduling
public class SchedulingJob {

private static final Logger LOGGER = LogManager.getLogger(SchedulingJob.class);

private static final OkHttpClient CLIENT = new OkHttpClient.Builder().build();

@Scheduled(fixedDelay = 5000)
public void work() throws IOException {
LOGGER.info("work job running!");

Request request = new Request.Builder().url("http://localhost:8080/spring-scheduled-3.x-5.x-scenario/case/call").build();
Response response = CLIENT.newCall(request).execute();
response.body().close();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<!--
~ 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.
~
-->
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<display-name>skywalking-spring-scheduled-3.x-5.x-scenario</display-name>

<servlet>
<servlet-name>spring-mvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring-mvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
4.3.28.RELEASE
5.0.18.RELEASE
5.1.17.RELEASE
5.2.8.RELEASE
5.2.25.RELEASE
5.3.34
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
segmentItems:
- serviceName: spring-scheduled-scenario
- serviceName: spring-scheduled-6.x-scenario
segmentSize: ge 2
segments:
- segmentId: not null
spans:
- operationName: GET:/spring-scheduled-scenario/case/call
- operationName: GET:/spring-scheduled-6.x-scenario/case/call
parentSpanId: -1
spanId: 0
spanLayer: Http
Expand All @@ -31,14 +31,14 @@ segmentItems:
peer: ''
skipAnalysis: false
tags:
- {key: url, value: 'http://localhost:8080/spring-scheduled-scenario/case/call'}
- {key: url, value: 'http://localhost:8080/spring-scheduled-6.x-scenario/case/call'}
- {key: http.method, value: GET}
- {key: http.status_code, value: '200'}
refs:
- {parentEndpoint: SpringScheduled/org.apache.skywalking.apm.testcase.spring.scheduled.job.SchedulingJob.work, networkAddress: 'localhost:8080', refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not null, parentService: not null, traceId: not null}
- segmentId: not null
spans:
- operationName: /spring-scheduled-scenario/case/call
- operationName: /spring-scheduled-6.x-scenario/case/call
parentSpanId: 0
spanId: 1
spanLayer: Http
Expand All @@ -51,7 +51,7 @@ segmentItems:
skipAnalysis: false
tags:
- {key: http.method, value: GET}
- {key: url, value: 'http://localhost:8080/spring-scheduled-scenario/case/call'}
- {key: url, value: 'http://localhost:8080/spring-scheduled-6.x-scenario/case/call'}
- {key: http.status_code, value: '200'}
- operationName: SpringScheduled/org.apache.skywalking.apm.testcase.spring.scheduled.job.SchedulingJob.work
parentSpanId: -1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
# limitations under the License.

type: tomcat
entryService: http://localhost:8080/spring-scheduled-scenario/case/healthCheck
healthCheck: http://localhost:8080/spring-scheduled-scenario/case/healthCheck
entryService: http://localhost:8080/spring-scheduled-6.x-scenario/case/healthCheck
healthCheck: http://localhost:8080/spring-scheduled-6.x-scenario/case/healthCheck
Loading
Loading