diff --git a/.github/workflows/plugins-jdk17-test.0.yaml b/.github/workflows/plugins-jdk17-test.0.yaml index 46ec012f6..808d22d0a 100644 --- a/.github/workflows/plugins-jdk17-test.0.yaml +++ b/.github/workflows/plugins-jdk17-test.0.yaml @@ -57,6 +57,8 @@ jobs: case: - jdk17-with-gson-scenario - resttemplate-6.x-scenario + - jetty-thread-pool-scenario + - jetty-11.x-thread-pool-scenario steps: - uses: actions/checkout@v2 with: diff --git a/CHANGES.md b/CHANGES.md index 1fee03223..808e7621a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,6 +8,7 @@ Release Notes. * Exclude `synthetic` methods for the WitnessMethod mechanism * Support ForkJoinPool trace * Support clickhouse-jdbc-plugin trace sql parameters +* Support monitor jetty server work thread pool metric #### Documentation diff --git a/apm-sniffer/apm-sdk-plugin/jetty-thread-pool-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/jetty-thread-pool-plugin/pom.xml new file mode 100644 index 000000000..2744f50ae --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/jetty-thread-pool-plugin/pom.xml @@ -0,0 +1,45 @@ + + + + + + apm-sdk-plugin + org.apache.skywalking + 8.16.0-SNAPSHOT + + 4.0.0 + + apm-jetty-thread-pool-plugin + jetty-thread-pool-plugin + http://maven.apache.org + + + 9.1.0.v20131115 + + + + + + org.eclipse.jetty + jetty-server + ${jetty-server.version} + provided + + + \ No newline at end of file diff --git a/apm-sniffer/apm-sdk-plugin/jetty-thread-pool-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/thread/pool/JettyServerInterceptor.java b/apm-sniffer/apm-sdk-plugin/jetty-thread-pool-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/thread/pool/JettyServerInterceptor.java new file mode 100644 index 000000000..8d20c457e --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/jetty-thread-pool-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/thread/pool/JettyServerInterceptor.java @@ -0,0 +1,60 @@ +/* + * 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.jetty.thread.pool; + +import org.apache.skywalking.apm.agent.core.meter.MeterFactory; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.util.thread.QueuedThreadPool; + +public class JettyServerInterceptor implements InstanceConstructorInterceptor { + + private static final String METER_NAME = "thread_pool"; + private static final String METRIC_POOL_NAME_TAG_NAME = "pool_name"; + private static final String THREAD_POOL_NAME = "jetty_execute_pool"; + private static final String METRIC_TYPE_TAG_NAME = "metric_type"; + + @Override + public void onConstruct(EnhancedInstance objInst, Object[] allArguments) throws Throwable { + Server server = (Server) objInst; + QueuedThreadPool queuedThreadPool = (QueuedThreadPool) server.getThreadPool(); + MeterFactory.gauge(METER_NAME, () -> (double) queuedThreadPool.getMinThreads()) + .tag(METRIC_POOL_NAME_TAG_NAME, THREAD_POOL_NAME) + .tag(METRIC_TYPE_TAG_NAME, "core_pool_size") + .build(); + MeterFactory.gauge(METER_NAME, () -> (double) queuedThreadPool.getMaxThreads()) + .tag(METRIC_POOL_NAME_TAG_NAME, THREAD_POOL_NAME) + .tag(METRIC_TYPE_TAG_NAME, "max_pool_size") + .build(); + MeterFactory.gauge(METER_NAME, () -> (double) queuedThreadPool.getThreads()) + .tag(METRIC_POOL_NAME_TAG_NAME, THREAD_POOL_NAME) + .tag(METRIC_TYPE_TAG_NAME, "pool_size") + .build(); + MeterFactory.gauge(METER_NAME, () -> (double) queuedThreadPool.getQueueSize()) + .tag(METRIC_POOL_NAME_TAG_NAME, THREAD_POOL_NAME) + .tag(METRIC_TYPE_TAG_NAME, "queue_size") + .build(); + MeterFactory.gauge(METER_NAME, () -> (double) queuedThreadPool.getThreads() - queuedThreadPool.getIdleThreads()) + .tag(METRIC_POOL_NAME_TAG_NAME, THREAD_POOL_NAME) + .tag(METRIC_TYPE_TAG_NAME, "active_size") + .build(); + + } +} \ No newline at end of file diff --git a/apm-sniffer/apm-sdk-plugin/jetty-thread-pool-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/thread/pool/define/JettyServerInstrumentation.java b/apm-sniffer/apm-sdk-plugin/jetty-thread-pool-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/thread/pool/define/JettyServerInstrumentation.java new file mode 100644 index 000000000..df8743125 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/jetty-thread-pool-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/thread/pool/define/JettyServerInstrumentation.java @@ -0,0 +1,78 @@ +/* + * 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.jetty.thread.pool.define; + +import static net.bytebuddy.matcher.ElementMatchers.any; +import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName; + +import java.util.Collections; +import java.util.List; +import net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.matcher.ElementMatcher; +import org.apache.skywalking.apm.agent.core.plugin.WitnessMethod; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; +import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch; + +public class JettyServerInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + + private static final String JETTY_SERVER_CLASS = "org.eclipse.jetty.server.Server"; + + private static final String JETTY_SERVER_INTERCEPTOR = "org.apache.skywalking.apm.plugin.jetty.thread.pool.JettyServerInterceptor"; + + private static final String QUEUED_THREAD_POOL_CLASS_NAME = "org.eclipse.jetty.util.thread.QueuedThreadPool"; + + private static final String QUEUED_THREAD_POOL_GET_QUEUE_SIZE = "getQueueSize"; + + @Override + protected ClassMatch enhanceClass() { + return byName(JETTY_SERVER_CLASS); + } + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[]{new ConstructorInterceptPoint() { + @Override + public ElementMatcher getConstructorMatcher() { + return any(); + } + + @Override + public String getConstructorInterceptor() { + return JETTY_SERVER_INTERCEPTOR; + } + } + }; + } + + @Override + public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[0]; + } + + @Override + protected List witnessMethods() { + return Collections.singletonList(new WitnessMethod( + QUEUED_THREAD_POOL_CLASS_NAME, + named(QUEUED_THREAD_POOL_GET_QUEUE_SIZE) + )); + } +} diff --git a/apm-sniffer/apm-sdk-plugin/jetty-thread-pool-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/jetty-thread-pool-plugin/src/main/resources/skywalking-plugin.def new file mode 100644 index 000000000..c62145a5b --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/jetty-thread-pool-plugin/src/main/resources/skywalking-plugin.def @@ -0,0 +1,17 @@ +# 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. + +jetty-thread-pool=org.apache.skywalking.apm.plugin.jetty.thread.pool.define.JettyServerInstrumentation \ No newline at end of file diff --git a/apm-sniffer/apm-sdk-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/pom.xml index 7e686229b..2cbe18b16 100644 --- a/apm-sniffer/apm-sdk-plugin/pom.xml +++ b/apm-sniffer/apm-sdk-plugin/pom.xml @@ -126,6 +126,7 @@ jedis-plugins impala-jdbc-2.6.x-plugin apm-armeria-plugins + jetty-thread-pool-plugin pom diff --git a/docs/en/setup/service-agent/java-agent/Plugin-list.md b/docs/en/setup/service-agent/java-agent/Plugin-list.md index 02be2af88..4b7a84387 100644 --- a/docs/en/setup/service-agent/java-agent/Plugin-list.md +++ b/docs/en/setup/service-agent/java-agent/Plugin-list.md @@ -158,3 +158,4 @@ - nats-client-2.14.x-2.15.x - impala-jdbc-2.6.x - jdk-forkjoinpool-plugin +- jetty-thread-pool diff --git a/docs/en/setup/service-agent/java-agent/Supported-list.md b/docs/en/setup/service-agent/java-agent/Supported-list.md index df70f8803..86dbd10b1 100644 --- a/docs/en/setup/service-agent/java-agent/Supported-list.md +++ b/docs/en/setup/service-agent/java-agent/Supported-list.md @@ -155,6 +155,7 @@ The meter plugin provides the advanced metrics collections, which are not a part * [Undertow](https://github.com/undertow-io/undertow) 2.1.x -> 2.6.x * [Tomcat](https://github.com/apache/tomcat) 7.0.x -> 10.0.x * [Dubbo](https://github.com/apache/dubbo) 2.5.x -> 2.7.x + * [Jetty](https://github.com/eclipse/jetty.project) 9.1.x -> 11.x ___ ¹Due to license incompatibilities/restrictions these plugins are hosted and released in 3rd part repository, go to [SkyAPM java plugin extension repository](https://github.com/SkyAPM/java-plugin-extensions) to get these. diff --git a/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/bin/startup.sh b/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/bin/startup.sh new file mode 100644 index 000000000..c060e9ca9 --- /dev/null +++ b/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/bin/startup.sh @@ -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/jetty-11.x-thread-pool-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/config/expectedData.yaml b/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/config/expectedData.yaml new file mode 100644 index 000000000..d911caaa1 --- /dev/null +++ b/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/config/expectedData.yaml @@ -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. +meterItems: + - serviceName: jetty-11.x-thread-pool-scenario + meterSize: 5 + meters: + - meterId: + name: thread_pool + tags: + - {name: metric_type, value: core_pool_size} + - {name: pool_name, value: jetty_execute_pool} + singleValue: ge 1 + - meterId: + name: thread_pool + tags: + - {name: metric_type, value: max_pool_size} + - {name: pool_name, value: jetty_execute_pool} + singleValue: ge 1 + - meterId: + name: thread_pool + tags: + - {name: metric_type, value: pool_size} + - {name: pool_name, value: jetty_execute_pool} + singleValue: ge 0 + - meterId: + name: thread_pool + tags: + - {name: metric_type, value: active_size} + - {name: pool_name, value: jetty_execute_pool} + singleValue: ge 0 + - meterId: + name: thread_pool + tags: + - {name: metric_type, value: queue_size} + - {name: pool_name, value: jetty_execute_pool} + singleValue: ge 0 diff --git a/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/configuration.yml b/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/configuration.yml new file mode 100644 index 000000000..173e59056 --- /dev/null +++ b/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/configuration.yml @@ -0,0 +1,22 @@ +# 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:18080/jetty-11.x-thread-pool-scenario/case/jetty-11.x-thread-pool-scenario +healthCheck: http://localhost:18080/jetty-11.x-thread-pool-scenario/case/jetty-11.x-thread-pool-scenario +startScript: ./bin/startup.sh +environment: +dependencies: diff --git a/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/pom.xml b/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/pom.xml new file mode 100644 index 000000000..9e6561ecd --- /dev/null +++ b/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/pom.xml @@ -0,0 +1,122 @@ + + + + + org.apache.skywalking.apm.testcase + jetty-11.x-thread-pool-scenario + 1.0.0 + jar + + 4.0.0 + + + UTF-8 + 1.8 + 3.8.1 + + 11.0.15 + + 2.6.2 + + + skywalking-jetty-11.x-thread-pool-scenario + + + + org.eclipse.jetty + jetty-server + ${test.framework.version} + + + org.eclipse.jetty + jetty-servlet + ${test.framework.version} + + + + + + jetty-11.x-thread-pool-scenario + + + org.apache.maven.plugins + maven-shade-plugin + 3.1.0 + + + package + + shade + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + org.apache.skywalking.apm.testcase.jetty11xthreadpool.Application + + + + + + + + + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${compiler.version} + ${compiler.version} + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-assembly-plugin + + + assemble + package + + single + + + + src/main/assembly/assembly.xml + + ./target/ + + + + + + + diff --git a/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/src/main/assembly/assembly.xml new file mode 100644 index 000000000..2cba0a860 --- /dev/null +++ b/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/jetty-11.x-thread-pool-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty11xthreadpool/Application.java b/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty11xthreadpool/Application.java new file mode 100644 index 000000000..2ad7c015c --- /dev/null +++ b/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty11xthreadpool/Application.java @@ -0,0 +1,37 @@ +/* + * 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.jetty11xthreadpool; + +import java.net.InetSocketAddress; +import org.apache.skywalking.apm.testcase.jetty11xthreadpool.controller.CaseController; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.servlet.ServletContextHandler; + +public class Application { + + public static void main(String[] args) throws Exception { + Server jettyServer = new Server(new InetSocketAddress("0.0.0.0", Integer.valueOf(18080))); + String contextPath = "/jetty-11.x-thread-pool-scenario"; + ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS); + servletContextHandler.setContextPath(contextPath); + servletContextHandler.addServlet(CaseController.class, CaseController.SERVLET_PATH); + jettyServer.setHandler(servletContextHandler); + jettyServer.start(); + } +} diff --git a/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty11xthreadpool/controller/CaseController.java b/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty11xthreadpool/controller/CaseController.java new file mode 100644 index 000000000..b17f564ab --- /dev/null +++ b/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty11xthreadpool/controller/CaseController.java @@ -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.testcase.jetty11xthreadpool.controller; + +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; + +public class CaseController extends HttpServlet { + + public static String SERVLET_PATH = "/case/jetty-11.x-thread-pool-scenario"; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + } + } +} diff --git a/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/src/main/resources/log4j2.xml new file mode 100644 index 000000000..9849ed5a8 --- /dev/null +++ b/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/support-version.list b/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/support-version.list new file mode 100644 index 000000000..2488c22ce --- /dev/null +++ b/test/plugin/scenarios/jetty-11.x-thread-pool-scenario/support-version.list @@ -0,0 +1,18 @@ +# 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. + +11.0.15 + diff --git a/test/plugin/scenarios/jetty-thread-pool-scenario/bin/startup.sh b/test/plugin/scenarios/jetty-thread-pool-scenario/bin/startup.sh new file mode 100644 index 000000000..1267796e8 --- /dev/null +++ b/test/plugin/scenarios/jetty-thread-pool-scenario/bin/startup.sh @@ -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/jetty-thread-pool-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/jetty-thread-pool-scenario/config/expectedData.yaml b/test/plugin/scenarios/jetty-thread-pool-scenario/config/expectedData.yaml new file mode 100644 index 000000000..00b0074a8 --- /dev/null +++ b/test/plugin/scenarios/jetty-thread-pool-scenario/config/expectedData.yaml @@ -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. +meterItems: + - serviceName: jetty-thread-pool-scenario + meterSize: 5 + meters: + - meterId: + name: thread_pool + tags: + - {name: metric_type, value: core_pool_size} + - {name: pool_name, value: jetty_execute_pool} + singleValue: ge 1 + - meterId: + name: thread_pool + tags: + - {name: metric_type, value: max_pool_size} + - {name: pool_name, value: jetty_execute_pool} + singleValue: ge 1 + - meterId: + name: thread_pool + tags: + - {name: metric_type, value: pool_size} + - {name: pool_name, value: jetty_execute_pool} + singleValue: ge 0 + - meterId: + name: thread_pool + tags: + - {name: metric_type, value: active_size} + - {name: pool_name, value: jetty_execute_pool} + singleValue: ge 0 + - meterId: + name: thread_pool + tags: + - {name: metric_type, value: queue_size} + - {name: pool_name, value: jetty_execute_pool} + singleValue: ge 0 diff --git a/test/plugin/scenarios/jetty-thread-pool-scenario/configuration.yml b/test/plugin/scenarios/jetty-thread-pool-scenario/configuration.yml new file mode 100644 index 000000000..e86fd18ec --- /dev/null +++ b/test/plugin/scenarios/jetty-thread-pool-scenario/configuration.yml @@ -0,0 +1,22 @@ +# 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:18080/jetty-thread-pool-scenario/case/jetty-thread-pool-scenario +healthCheck: http://localhost:18080/jetty-thread-pool-scenario/case/jetty-thread-pool-scenario +startScript: ./bin/startup.sh +environment: +dependencies: diff --git a/test/plugin/scenarios/jetty-thread-pool-scenario/pom.xml b/test/plugin/scenarios/jetty-thread-pool-scenario/pom.xml new file mode 100644 index 000000000..99511d42b --- /dev/null +++ b/test/plugin/scenarios/jetty-thread-pool-scenario/pom.xml @@ -0,0 +1,122 @@ + + + + + org.apache.skywalking.apm.testcase + jetty-thread-pool-scenario + 1.0.0 + jar + + 4.0.0 + + + UTF-8 + 1.8 + 3.8.1 + + 10.0.15 + + 2.6.2 + + + skywalking-jetty-thread-pool-scenario + + + + org.eclipse.jetty + jetty-server + ${test.framework.version} + + + org.eclipse.jetty + jetty-servlet + ${test.framework.version} + + + + + + jetty-thread-pool-scenario + + + org.apache.maven.plugins + maven-shade-plugin + 3.1.0 + + + package + + shade + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + org.apache.skywalking.apm.testcase.jettythreadpool.Application + + + + + + + + + maven-compiler-plugin + ${maven-compiler-plugin.version} + + ${compiler.version} + ${compiler.version} + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-assembly-plugin + + + assemble + package + + single + + + + src/main/assembly/assembly.xml + + ./target/ + + + + + + + diff --git a/test/plugin/scenarios/jetty-thread-pool-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/jetty-thread-pool-scenario/src/main/assembly/assembly.xml new file mode 100644 index 000000000..80a4a5322 --- /dev/null +++ b/test/plugin/scenarios/jetty-thread-pool-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/jetty-thread-pool-scenario.jar + ./libs + 0775 + + + \ No newline at end of file diff --git a/test/plugin/scenarios/jetty-thread-pool-scenario/src/main/java/org/apache/skywalking/apm/testcase/jettythreadpool/Application.java b/test/plugin/scenarios/jetty-thread-pool-scenario/src/main/java/org/apache/skywalking/apm/testcase/jettythreadpool/Application.java new file mode 100644 index 000000000..4985132d1 --- /dev/null +++ b/test/plugin/scenarios/jetty-thread-pool-scenario/src/main/java/org/apache/skywalking/apm/testcase/jettythreadpool/Application.java @@ -0,0 +1,37 @@ +/* + * 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.jettythreadpool; + +import java.net.InetSocketAddress; +import org.apache.skywalking.apm.testcase.jettythreadpool.controller.CaseController; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.servlet.ServletContextHandler; + +public class Application { + + public static void main(String[] args) throws Exception { + Server jettyServer = new Server(new InetSocketAddress("0.0.0.0", Integer.valueOf(18080))); + String contextPath = "/jetty-thread-pool-scenario"; + ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS); + servletContextHandler.setContextPath(contextPath); + servletContextHandler.addServlet(CaseController.class, CaseController.SERVLET_PATH); + jettyServer.setHandler(servletContextHandler); + jettyServer.start(); + } +} diff --git a/test/plugin/scenarios/jetty-thread-pool-scenario/src/main/java/org/apache/skywalking/apm/testcase/jettythreadpool/controller/CaseController.java b/test/plugin/scenarios/jetty-thread-pool-scenario/src/main/java/org/apache/skywalking/apm/testcase/jettythreadpool/controller/CaseController.java new file mode 100644 index 000000000..6e4ba7144 --- /dev/null +++ b/test/plugin/scenarios/jetty-thread-pool-scenario/src/main/java/org/apache/skywalking/apm/testcase/jettythreadpool/controller/CaseController.java @@ -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.testcase.jettythreadpool.controller; + +import java.io.IOException; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class CaseController extends HttpServlet { + + public static String SERVLET_PATH = "/case/jetty-thread-pool-scenario"; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + try { + Thread.sleep(2000); + } catch (InterruptedException e) { + } + } +} diff --git a/test/plugin/scenarios/jetty-thread-pool-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/jetty-thread-pool-scenario/src/main/resources/log4j2.xml new file mode 100644 index 000000000..9849ed5a8 --- /dev/null +++ b/test/plugin/scenarios/jetty-thread-pool-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/jetty-thread-pool-scenario/support-version.list b/test/plugin/scenarios/jetty-thread-pool-scenario/support-version.list new file mode 100644 index 000000000..67e1a6188 --- /dev/null +++ b/test/plugin/scenarios/jetty-thread-pool-scenario/support-version.list @@ -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. + +# lists your version here (Contains only the last version number of each minor version.) + +9.1.0.v20131115 +9.2.30.v20200428 +9.3.30.v20211001 +9.4.51.v20230217 +10.0.15 \ No newline at end of file