-
Notifications
You must be signed in to change notification settings - Fork 596
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
Support forkjoinpool plugin in JDK11 #656
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a4833b1
Support forkjoinpool plugin in JDK11
786991884 0416268
Support forkjoinpool plugin in JDK11
786991884 56893b6
Support forkjoinpool plugin in JDK11
786991884 bca00be
Support forkjoinpool plugin in JDK11
786991884 783e8e2
Support forkjoinpool plugin in JDK11+
786991884 75ccd3f
Merge branch 'main' into main
wu-sheng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# 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. | ||
|
||
name: Test | ||
|
||
on: | ||
pull_request: | ||
paths: | ||
- '.github/workflows/plugins-*.yaml' | ||
- 'apm-application-toolkit/**' | ||
- 'apm-commons/**' | ||
- 'apm-protocol/**' | ||
- 'apm-sniffer/**' | ||
- 'test/plugin/**' | ||
- '**/pom.xml' | ||
- '!**.md' | ||
|
||
concurrency: | ||
group: plugins-jdk11-3-${{ github.event.pull_request.number || github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: true | ||
- name: Build | ||
uses: ./.github/actions/build | ||
with: | ||
base_image_java: eclipse-temurin:11-jdk | ||
|
||
test: | ||
needs: [ build ] | ||
name: ${{ matrix.case }} | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 90 | ||
strategy: | ||
matrix: | ||
case: | ||
- jdk11-forkjoinpool-scenario | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
submodules: true | ||
- uses: actions/setup-java@v2 | ||
with: | ||
distribution: temurin | ||
java-version: 11 | ||
- name: Run Plugin Test | ||
uses: ./.github/actions/run | ||
with: | ||
test_case: ${{ matrix.case }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
|
||
package org.apache.skywalking.apm.plugin.jdk.forkjoinpool.define; | ||
|
||
import static net.bytebuddy.matcher.ElementMatchers.named; | ||
import static net.bytebuddy.matcher.ElementMatchers.namedOneOf; | ||
|
||
import net.bytebuddy.description.method.MethodDescription; | ||
import net.bytebuddy.matcher.ElementMatcher; | ||
|
@@ -33,6 +33,17 @@ public class ForkJoinWorkerQueueInstrumentation extends ClassInstanceMethodsEnha | |
private static final String FORK_JOIN_WORKER_QUEUE_CLASS = "java.util.concurrent.ForkJoinPool$WorkQueue"; | ||
|
||
private static final String FORK_JOIN_WORKER_QUEUE_RUN_TASK_METHOD = "runTask"; | ||
|
||
/** | ||
* The runWorker method is one of the core methods of ForkJoinPool, | ||
* responsible for retrieving tasks from the work queue and executing them. | ||
* <p> | ||
* Within the runWorker method, it calls the scan method to search and execute tasks. | ||
* <p> | ||
* in java11+ ForkJoinPool. scan calls WorkQueue.topLevelExec, in JAVA8 it calls WorkQueue.runTask. | ||
*/ | ||
private static final String FORK_JOIN_WORKER_QUEUE_RUN_TASK_METHOD_JDK11 = "topLevelExec"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add comments about why there are two methods to intercept. |
||
|
||
private static final String FORK_JOIN_WORKER_QUEUE_RUN_TASK_METHOD_INTERCEPTOR = "org.apache.skywalking.apm.plugin.jdk.forkjoinpool.ForkJoinWorkerQueueMethodInterceptor"; | ||
|
||
@Override | ||
|
@@ -51,7 +62,7 @@ public InstanceMethodsInterceptV2Point[] getInstanceMethodsInterceptV2Points() { | |
new InstanceMethodsInterceptV2Point() { | ||
@Override | ||
public ElementMatcher<MethodDescription> getMethodsMatcher() { | ||
return named(FORK_JOIN_WORKER_QUEUE_RUN_TASK_METHOD); | ||
return namedOneOf(FORK_JOIN_WORKER_QUEUE_RUN_TASK_METHOD, FORK_JOIN_WORKER_QUEUE_RUN_TASK_METHOD_JDK11); | ||
} | ||
|
||
@Override | ||
|
21 changes: 21 additions & 0 deletions
21
test/plugin/scenarios/jdk11-forkjoinpool-scenario/bin/startup.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
# | ||
# 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. | ||
|
||
home="$(cd "$(dirname $0)"; pwd)" | ||
|
||
java -jar ${agent_opts} ${home}/../libs/jdk11-forkjoinpool-scenario.jar & |
85 changes: 85 additions & 0 deletions
85
test/plugin/scenarios/jdk11-forkjoinpool-scenario/config/expectedData.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# 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: jdk11-forkjoinpool-scenario | ||
segmentSize: ge 3 | ||
segments: | ||
- segmentId: not null | ||
spans: | ||
- operationName: '/apache/skywalking' | ||
parentSpanId: 0 | ||
spanId: 1 | ||
spanLayer: Http | ||
startTime: nq 0 | ||
endTime: nq 0 | ||
componentId: 13 | ||
isError: false | ||
spanType: Exit | ||
peer: 'github.com:443' | ||
tags: | ||
- {key: url, value: 'https://github.com/apache/skywalking'} | ||
- {key: http.method, value: GET} | ||
- {key: http.status_code, value: '200'} | ||
skipAnalysis: 'false' | ||
- operationName: 'ForkJoinPool/java.util.concurrent.ForkJoinPool$WorkQueue/topLevelExec' | ||
parentSpanId: -1 | ||
spanId: 0 | ||
spanLayer: Unknown | ||
startTime: nq 0 | ||
endTime: nq 0 | ||
componentId: 80 | ||
isError: false | ||
spanType: Local | ||
peer: '' | ||
refs: | ||
- {parentEndpoint: 'GET:/jdk11-forkjoinpool-scenario/case/jdk11-forkjoinpool-scenario', networkAddress: '', refType: CrossThread, | ||
parentSpanId: 0, parentTraceSegmentId: not null, parentServiceInstance: not | ||
null, parentService: jdk11-forkjoinpool-scenario, traceId: not null} | ||
skipAnalysis: 'false' | ||
- segmentId: not null | ||
spans: | ||
- operationName: '/apache/skywalking' | ||
parentSpanId: 0 | ||
spanId: 1 | ||
spanLayer: Http | ||
startTime: nq 0 | ||
endTime: nq 0 | ||
componentId: 13 | ||
isError: false | ||
spanType: Exit | ||
peer: 'github.com:443' | ||
tags: | ||
- {key: url, value: 'https://github.com/apache/skywalking'} | ||
- {key: http.method, value: GET} | ||
- {key: http.status_code, value: '200'} | ||
skipAnalysis: 'false' | ||
- operationName: 'GET:/jdk11-forkjoinpool-scenario/case/jdk11-forkjoinpool-scenario' | ||
parentSpanId: -1 | ||
spanId: 0 | ||
spanLayer: Http | ||
startTime: nq 0 | ||
endTime: nq 0 | ||
componentId: 1 | ||
isError: false | ||
spanType: Entry | ||
tags: | ||
- {key: url, value: 'http://localhost:8080/jdk11-forkjoinpool-scenario/case/jdk11-forkjoinpool-scenario'} | ||
- {key: http.method, value: GET} | ||
- {key: http.status_code, value: '200'} | ||
peer: '' | ||
skipAnalysis: 'false' | ||
|
||
|
23 changes: 23 additions & 0 deletions
23
test/plugin/scenarios/jdk11-forkjoinpool-scenario/configuration.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# 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: jvm | ||
entryService: http://localhost:8080/jdk11-forkjoinpool-scenario/case/jdk11-forkjoinpool-scenario | ||
healthCheck: http://localhost:8080/jdk11-forkjoinpool-scenario/case/healthCheck | ||
runningMode: with_bootstrap | ||
withPlugins: apm-jdk-forkjoinpool-plugin-*.jar | ||
startScript: ./bin/startup.sh | ||
|
121 changes: 121 additions & 0 deletions
121
test/plugin/scenarios/jdk11-forkjoinpool-scenario/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ 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"> | ||
|
||
<groupId>org.apache.skywalking.apm.testcase</groupId> | ||
<artifactId>jdk11-forkjoinpool-scenario</artifactId> | ||
<version>1.0.0</version> | ||
<packaging>jar</packaging> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<compiler.version>11</compiler.version> | ||
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version> | ||
<test.framework.version>YOUR VERSION</test.framework.version> | ||
<spring.boot.version>2.1.6.RELEASE</spring.boot.version> | ||
<lombok.version>1.18.20</lombok.version> | ||
</properties> | ||
|
||
<name>skywalking-jdk11-forkjoinpool-scenario</name> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-dependencies</artifactId> | ||
<version>${spring.boot.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-logging</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-log4j2</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.projectlombok</groupId> | ||
<artifactId>lombok</artifactId> | ||
<version>${lombok.version}</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<finalName>jdk11-forkjoinpool-scenario</finalName> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
<version>${spring.boot.version}</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>repackage</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>${maven-compiler-plugin.version}</version> | ||
<configuration> | ||
<source>${compiler.version}</source> | ||
<target>${compiler.version}</target> | ||
<encoding>${project.build.sourceEncoding}</encoding> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>assemble</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
<configuration> | ||
<descriptors> | ||
<descriptor>src/main/assembly/assembly.xml</descriptor> | ||
</descriptors> | ||
<outputDirectory>./target/</outputDirectory> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a new case? I think this is rt.jar(jdk level) change, even the codes are compiled as 1.8, the runtime method is still going to be forced to run in 11, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we not copy the test scenario, but directly write the existing test in jdk11. Was that failing before and running now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, you are right. I will optimize it