From 129f57c4c148d04279ec2922a7ede8fa8c415b0b Mon Sep 17 00:00:00 2001
From: yswdqz <74546965+yswdqz@users.noreply.github.com>
Date: Sat, 23 Jul 2022 17:54:48 +0800
Subject: [PATCH] Add an agent plugin to support tomcat10.x (#286)
Resolve https://github.com/apache/skywalking/issues/7420
---
.../workflows/plugins-tomcat10-test.0.yaml | 72 +++++++++++
CHANGES.md | 1 +
apm-sniffer/apm-sdk-plugin/pom.xml | 1 +
.../apm-sdk-plugin/tomcat-10x-plugin/pom.xml | 46 +++++++
.../apm/plugin/tomcat10x/Constants.java | 24 ++++
.../plugin/tomcat10x/ForwardInterceptor.java | 64 +++++++++
.../tomcat10x/TomcatExceptionInterceptor.java | 47 +++++++
.../tomcat10x/TomcatInvokeInterceptor.java | 122 ++++++++++++++++++
.../plugin/tomcat10x/TomcatPluginConfig.java | 43 ++++++
.../ApplicationDispatcherInstrumentation.java | 86 ++++++++++++
.../define/TomcatInstrumentation.java | 100 ++++++++++++++
.../src/main/resources/skywalking-plugin.def | 18 +++
.../ApplicationDispatcherInstrumentation.java | 5 +
.../define/TomcatInstrumentation.java | 5 +
.../service-agent/java-agent/Plugin-list.md | 1 +
.../java-agent/Supported-list.md | 1 +
.../config/expectedData.yaml | 74 +++++++++++
.../tomcat-10x-scenario/configuration.yml | 19 +++
.../scenarios/tomcat-10x-scenario/pom.xml | 81 ++++++++++++
.../apm/testcase/tomcat10x/CaseServlet.java | 61 +++++++++
.../testcase/tomcat10x/ErrorCatchServlet.java | 41 ++++++
.../tomcat10x/HealthCheckServlet.java | 41 ++++++
.../src/main/resources/log4j2.xml | 30 +++++
.../src/main/webapp/WEB-INF/web.xml | 58 +++++++++
.../tomcat-10x-scenario/support-version.list | 19 +++
25 files changed, 1060 insertions(+)
create mode 100644 .github/workflows/plugins-tomcat10-test.0.yaml
create mode 100644 apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/pom.xml
create mode 100644 apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/Constants.java
create mode 100644 apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/ForwardInterceptor.java
create mode 100644 apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/TomcatExceptionInterceptor.java
create mode 100644 apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/TomcatInvokeInterceptor.java
create mode 100644 apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/TomcatPluginConfig.java
create mode 100644 apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/define/ApplicationDispatcherInstrumentation.java
create mode 100644 apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/define/TomcatInstrumentation.java
create mode 100644 apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/resources/skywalking-plugin.def
create mode 100644 test/plugin/scenarios/tomcat-10x-scenario/config/expectedData.yaml
create mode 100644 test/plugin/scenarios/tomcat-10x-scenario/configuration.yml
create mode 100644 test/plugin/scenarios/tomcat-10x-scenario/pom.xml
create mode 100644 test/plugin/scenarios/tomcat-10x-scenario/src/main/java/org/apache/skywalking/apm/testcase/tomcat10x/CaseServlet.java
create mode 100644 test/plugin/scenarios/tomcat-10x-scenario/src/main/java/org/apache/skywalking/apm/testcase/tomcat10x/ErrorCatchServlet.java
create mode 100644 test/plugin/scenarios/tomcat-10x-scenario/src/main/java/org/apache/skywalking/apm/testcase/tomcat10x/HealthCheckServlet.java
create mode 100644 test/plugin/scenarios/tomcat-10x-scenario/src/main/resources/log4j2.xml
create mode 100644 test/plugin/scenarios/tomcat-10x-scenario/src/main/webapp/WEB-INF/web.xml
create mode 100644 test/plugin/scenarios/tomcat-10x-scenario/support-version.list
diff --git a/.github/workflows/plugins-tomcat10-test.0.yaml b/.github/workflows/plugins-tomcat10-test.0.yaml
new file mode 100644
index 000000000..cc16810d2
--- /dev/null
+++ b/.github/workflows/plugins-tomcat10-test.0.yaml
@@ -0,0 +1,72 @@
+# 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'
+ push:
+ branches:
+ - test/ci/*
+
+concurrency:
+ group: plugins-tomcat10-${{ 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_tomcat: tomcat:10.0.22-jdk8
+
+ test:
+ needs: [ build ]
+ name: ${{ matrix.case }}
+ runs-on: ubuntu-latest
+ timeout-minutes: 90
+ strategy:
+ matrix:
+ case:
+ - tomcat-10x-scenario
+ steps:
+ - uses: actions/checkout@v2
+ with:
+ submodules: true
+ - uses: actions/setup-java@v2
+ with:
+ distribution: adopt
+ java-version: 8
+ - name: Run Plugin Test
+ uses: ./.github/actions/run
+ with:
+ test_case: ${{ matrix.case }}
diff --git a/CHANGES.md b/CHANGES.md
index 4a469eb97..e9a2b9afb 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -9,6 +9,7 @@ Release Notes.
* Fix `onHalfClose` using span operation name `/Request/onComplete` instead of the worng name `/Request/onHalfClose`.
* Add plugin to support RESTeasy 4.x.
* Add plugin to support hutool-http 5.x.
+* Add plugin to support Tomcat 10.x.
* Save http status code regardless of it's status.
#### Documentation
diff --git a/apm-sniffer/apm-sdk-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/pom.xml
index ac5bd9735..93fabad88 100644
--- a/apm-sniffer/apm-sdk-plugin/pom.xml
+++ b/apm-sniffer/apm-sdk-plugin/pom.xml
@@ -34,6 +34,7 @@
jedis-2.x-pluginredisson-3.x-plugintomcat-7.x-8.x-plugin
+ tomcat-10x-pluginmotan-pluginmongodb-3.x-pluginmongodb-4.x-plugin
diff --git a/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/pom.xml
new file mode 100644
index 000000000..93322cb27
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/pom.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+ apm-sdk-plugin
+ org.apache.skywalking
+ 8.11.0
+
+ 4.0.0
+
+ tomcat-10x-plugin
+
+
+ 8
+ 8
+ 10.0.22
+
+
+
+ org.apache.tomcat.embed
+ tomcat-embed-core
+ ${tomcat.version}
+ provided
+
+
+
+
diff --git a/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/Constants.java b/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/Constants.java
new file mode 100644
index 000000000..3aa2d92ae
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/Constants.java
@@ -0,0 +1,24 @@
+/*
+ * 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.tomcat10x;
+
+public class Constants {
+ public static final String FORWARD_REQUEST_FLAG = "SW_FORWARD_REQUEST_FLAG";
+}
diff --git a/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/ForwardInterceptor.java b/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/ForwardInterceptor.java
new file mode 100644
index 000000000..8c64a1d0a
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/ForwardInterceptor.java
@@ -0,0 +1,64 @@
+/*
+ * 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.tomcat10x;
+
+import org.apache.skywalking.apm.agent.core.context.ContextManager;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+
+public class ForwardInterceptor implements InstanceMethodsAroundInterceptor, InstanceConstructorInterceptor {
+
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+ if (ContextManager.isActive()) {
+ AbstractSpan abstractTracingSpan = ContextManager.activeSpan();
+ Map eventMap = new HashMap();
+ eventMap.put("forward-url", objInst.getSkyWalkingDynamicField() == null ? "" : String.valueOf(objInst.getSkyWalkingDynamicField()));
+ abstractTracingSpan.log(System.currentTimeMillis(), eventMap);
+ ContextManager.getRuntimeContext().put(Constants.FORWARD_REQUEST_FLAG, true);
+ }
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ Object ret) throws Throwable {
+ ContextManager.getRuntimeContext().remove(Constants.FORWARD_REQUEST_FLAG);
+ return ret;
+ }
+
+ @Override
+ public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class>[] argumentsTypes, Throwable t) {
+
+ }
+
+ @Override
+ public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
+ objInst.setSkyWalkingDynamicField(allArguments[1]);
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/TomcatExceptionInterceptor.java b/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/TomcatExceptionInterceptor.java
new file mode 100644
index 000000000..ac9ba9f61
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/TomcatExceptionInterceptor.java
@@ -0,0 +1,47 @@
+/*
+ * 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.tomcat10x;
+
+import org.apache.skywalking.apm.agent.core.context.ContextManager;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+
+import java.lang.reflect.Method;
+
+public class TomcatExceptionInterceptor implements InstanceMethodsAroundInterceptor {
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+ ContextManager.activeSpan().log((Throwable) allArguments[2]);
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ Object ret) throws Throwable {
+
+ return ret;
+ }
+
+ @Override
+ public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class>[] argumentsTypes, Throwable t) {
+
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/TomcatInvokeInterceptor.java b/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/TomcatInvokeInterceptor.java
new file mode 100644
index 000000000..fde1fc270
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/TomcatInvokeInterceptor.java
@@ -0,0 +1,122 @@
+/*
+ * 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.tomcat10x;
+
+import jakarta.servlet.http.HttpServletResponse;
+import org.apache.catalina.connector.Request;
+import org.apache.skywalking.apm.agent.core.context.CarrierItem;
+import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
+import org.apache.skywalking.apm.agent.core.context.ContextManager;
+import org.apache.skywalking.apm.agent.core.context.tag.Tags;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
+
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.apache.skywalking.apm.agent.core.util.CollectionUtil;
+import org.apache.skywalking.apm.agent.core.util.MethodUtil;
+import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
+import org.apache.skywalking.apm.util.StringUtil;
+import org.apache.tomcat.util.http.Parameters;
+
+import java.lang.reflect.Method;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+public class TomcatInvokeInterceptor implements InstanceMethodsAroundInterceptor {
+
+ private static boolean IS_SERVLET_GET_STATUS_METHOD_EXIST;
+ private static final String SERVLET_RESPONSE_CLASS = "jakarta.servlet.http.HttpServletResponse";
+ private static final String GET_STATUS_METHOD = "getStatus";
+
+ static {
+ IS_SERVLET_GET_STATUS_METHOD_EXIST = MethodUtil.isMethodExist(
+ TomcatInvokeInterceptor.class.getClassLoader(), SERVLET_RESPONSE_CLASS, GET_STATUS_METHOD);
+ }
+
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+ Request request = (Request) allArguments[0];
+ ContextCarrier contextCarrier = new ContextCarrier();
+
+ CarrierItem next = contextCarrier.items();
+ while (next.hasNext()) {
+ next = next.next();
+ next.setHeadValue(request.getHeader(next.getHeadKey()));
+ }
+ String operationName = String.join(":", request.getMethod(), request.getRequestURI());
+ AbstractSpan span = ContextManager.createEntrySpan(operationName, contextCarrier);
+ Tags.URL.set(span, request.getRequestURL().toString());
+ Tags.HTTP.METHOD.set(span, request.getMethod());
+ span.setComponent(ComponentsDefine.TOMCAT);
+ SpanLayer.asHttp(span);
+
+ if (TomcatPluginConfig.Plugin.Tomcat.COLLECT_HTTP_PARAMS) {
+ collectHttpParam(request, span);
+ }
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ Object ret) throws Throwable {
+ Request request = (Request) allArguments[0];
+ HttpServletResponse response = (HttpServletResponse) allArguments[1];
+
+ AbstractSpan span = ContextManager.activeSpan();
+ if (IS_SERVLET_GET_STATUS_METHOD_EXIST && response.getStatus() >= 400) {
+ span.errorOccurred();
+ Tags.HTTP_RESPONSE_STATUS_CODE.set(span, response.getStatus());
+ }
+ // Active HTTP parameter collection automatically in the profiling context.
+ if (!TomcatPluginConfig.Plugin.Tomcat.COLLECT_HTTP_PARAMS && span.isProfiling()) {
+ collectHttpParam(request, span);
+ }
+ ContextManager.getRuntimeContext().remove(Constants.FORWARD_REQUEST_FLAG);
+ ContextManager.stopSpan();
+ return ret;
+ }
+
+ @Override
+ public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class>[] argumentsTypes, Throwable t) {
+ AbstractSpan span = ContextManager.activeSpan();
+ span.log(t);
+ }
+
+ private void collectHttpParam(Request request, AbstractSpan span) {
+ final Map parameterMap = new HashMap<>();
+ final org.apache.coyote.Request coyoteRequest = request.getCoyoteRequest();
+ final Parameters parameters = coyoteRequest.getParameters();
+ for (final Enumeration names = parameters.getParameterNames(); names.hasMoreElements(); ) {
+ final String name = names.nextElement();
+ parameterMap.put(name, parameters.getParameterValues(name));
+ }
+
+ if (!parameterMap.isEmpty()) {
+ String tagValue = CollectionUtil.toString(parameterMap);
+ tagValue = TomcatPluginConfig.Plugin.Http.HTTP_PARAMS_LENGTH_THRESHOLD > 0 ?
+ StringUtil.cut(tagValue, TomcatPluginConfig.Plugin.Http.HTTP_PARAMS_LENGTH_THRESHOLD) :
+ tagValue;
+ Tags.HTTP.PARAMS.set(span, tagValue);
+ }
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/TomcatPluginConfig.java b/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/TomcatPluginConfig.java
new file mode 100644
index 000000000..2c2865d63
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/TomcatPluginConfig.java
@@ -0,0 +1,43 @@
+/*
+ * 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.tomcat10x;
+
+import org.apache.skywalking.apm.agent.core.boot.PluginConfig;
+
+public class TomcatPluginConfig {
+ public static class Plugin {
+ @PluginConfig(root = TomcatPluginConfig.class)
+ public static class Tomcat {
+ /**
+ * This config item controls that whether the Tomcat plugin should collect the parameters of the request.
+ */
+ public static boolean COLLECT_HTTP_PARAMS = false;
+ }
+
+ @PluginConfig(root = TomcatPluginConfig.class)
+ public static class Http {
+ /**
+ * When either {@link Tomcat#COLLECT_HTTP_PARAMS} is enabled, how many characters to keep and send to the
+ * OAP backend, use negative values to keep and send the complete parameters, NB. this config item is added
+ * for the sake of performance
+ */
+ public static int HTTP_PARAMS_LENGTH_THRESHOLD = 1024;
+ }
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/define/ApplicationDispatcherInstrumentation.java b/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/define/ApplicationDispatcherInstrumentation.java
new file mode 100644
index 000000000..048ee28f3
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/define/ApplicationDispatcherInstrumentation.java
@@ -0,0 +1,86 @@
+/*
+ * 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.tomcat10x.define;
+
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+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;
+
+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;
+
+public class ApplicationDispatcherInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+
+ private static final String ENHANCE_CLASS = "org.apache.catalina.core.ApplicationDispatcher";
+ private static final String ENHANCE_METHOD = "forward";
+ public static final String INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.tomcat10x.ForwardInterceptor";
+
+ @Override
+ protected String[] witnessClasses() {
+ return new String[]{"jakarta.servlet.http.HttpServletResponse"};
+ }
+
+ @Override
+ public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[] {
+ new ConstructorInterceptPoint() {
+ @Override
+ public ElementMatcher getConstructorMatcher() {
+ return any();
+ }
+
+ @Override
+ public String getConstructorInterceptor() {
+ return INTERCEPTOR_CLASS;
+ }
+ }
+ };
+ }
+
+ @Override
+ public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
+ return new InstanceMethodsInterceptPoint[] {
+ new InstanceMethodsInterceptPoint() {
+ @Override
+ public ElementMatcher getMethodsMatcher() {
+ return named(ENHANCE_METHOD);
+ }
+
+ @Override
+ public String getMethodsInterceptor() {
+ return INTERCEPTOR_CLASS;
+ }
+
+ @Override
+ public boolean isOverrideArgs() {
+ return false;
+ }
+ }
+ };
+ }
+
+ @Override
+ protected ClassMatch enhanceClass() {
+ return byName(ENHANCE_CLASS);
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/define/TomcatInstrumentation.java b/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/define/TomcatInstrumentation.java
new file mode 100644
index 000000000..0ba3356a1
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat10x/define/TomcatInstrumentation.java
@@ -0,0 +1,100 @@
+/*
+ * 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.tomcat10x.define;
+
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+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;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
+
+public class TomcatInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+
+ /**
+ * Enhance class.
+ */
+ private static final String ENHANCE_CLASS = "org.apache.catalina.core.StandardHostValve";
+
+ /**
+ * The intercept class for "invoke" method in the class "org.apache.catalina.core.StandardHostValve"
+ */
+ private static final String INVOKE_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.tomcat10x.TomcatInvokeInterceptor";
+
+ /**
+ * The intercept class for "exception" method in the class "org.apache.catalina.core.StandardHostValve"
+ */
+ private static final String EXCEPTION_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.tomcat10x.TomcatExceptionInterceptor";
+
+ @Override
+ protected String[] witnessClasses() {
+ return new String[]{"jakarta.servlet.http.HttpServletResponse"};
+ }
+
+ @Override
+ protected ClassMatch enhanceClass() {
+ return byName(ENHANCE_CLASS);
+ }
+
+ @Override
+ public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return null;
+ }
+
+ @Override
+ public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
+ return new InstanceMethodsInterceptPoint[] {
+ new InstanceMethodsInterceptPoint() {
+ @Override
+ public ElementMatcher getMethodsMatcher() {
+ return named("invoke");
+ }
+
+ @Override
+ public String getMethodsInterceptor() {
+ return INVOKE_INTERCEPT_CLASS;
+ }
+
+ @Override
+ public boolean isOverrideArgs() {
+ return false;
+ }
+ },
+ new InstanceMethodsInterceptPoint() {
+ @Override
+ public ElementMatcher getMethodsMatcher() {
+ return named("throwable");
+ }
+
+ @Override
+ public String getMethodsInterceptor() {
+ return EXCEPTION_INTERCEPT_CLASS;
+ }
+
+ @Override
+ public boolean isOverrideArgs() {
+ return false;
+ }
+ }
+ };
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/resources/skywalking-plugin.def
new file mode 100644
index 000000000..baa002ba2
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/tomcat-10x-plugin/src/main/resources/skywalking-plugin.def
@@ -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.
+
+tomcat-10.x=org.apache.skywalking.apm.plugin.tomcat10x.define.TomcatInstrumentation
+tomcat-10.x=org.apache.skywalking.apm.plugin.tomcat10x.define.ApplicationDispatcherInstrumentation
diff --git a/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat78x/define/ApplicationDispatcherInstrumentation.java b/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat78x/define/ApplicationDispatcherInstrumentation.java
index 719d3dbbb..14158594f 100644
--- a/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat78x/define/ApplicationDispatcherInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat78x/define/ApplicationDispatcherInstrumentation.java
@@ -35,6 +35,11 @@ public class ApplicationDispatcherInstrumentation extends ClassInstanceMethodsEn
private static final String ENHANCE_METHOD = "forward";
public static final String INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.tomcat78x.ForwardInterceptor";
+ @Override
+ protected String[] witnessClasses() {
+ return new String[]{"javax.servlet.http.HttpServletResponse"};
+ }
+
@Override
public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[] {
diff --git a/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat78x/define/TomcatInstrumentation.java b/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat78x/define/TomcatInstrumentation.java
index f4a276ddc..ffcae42fe 100644
--- a/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat78x/define/TomcatInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/tomcat-7.x-8.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/tomcat78x/define/TomcatInstrumentation.java
@@ -45,6 +45,11 @@ public class TomcatInstrumentation extends ClassInstanceMethodsEnhancePluginDefi
*/
private static final String EXCEPTION_INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.tomcat78x.TomcatExceptionInterceptor";
+ @Override
+ protected String[] witnessClasses() {
+ return new String[]{"javax.servlet.http.HttpServletResponse"};
+ }
+
@Override
protected ClassMatch enhanceClass() {
return byName(ENHANCE_CLASS);
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 7d7a40014..3029b158a 100644
--- a/docs/en/setup/service-agent/java-agent/Plugin-list.md
+++ b/docs/en/setup/service-agent/java-agent/Plugin-list.md
@@ -108,6 +108,7 @@
- struts2-2.x
- thrift
- tomcat-7.x/8.x
+- tomcat-10.x
- toolkit-counter
- toolkit-gauge
- toolkit-histogram
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 e27bc1edc..98cdc7658 100644
--- a/docs/en/setup/service-agent/java-agent/Supported-list.md
+++ b/docs/en/setup/service-agent/java-agent/Supported-list.md
@@ -6,6 +6,7 @@ metrics based on the tracing data.
* [Tomcat](https://github.com/apache/tomcat) 7
* [Tomcat](https://github.com/apache/tomcat) 8
* [Tomcat](https://github.com/apache/tomcat) 9
+ * [Tomcat](https://github.com/apache/tomcat) 10
* [Spring Boot](https://github.com/spring-projects/spring-boot) Web 4.x
* Spring MVC 3.x, 4.x 5.x with servlet 3.x
* [Nutz Web Framework](https://github.com/nutzam/nutz) 1.x
diff --git a/test/plugin/scenarios/tomcat-10x-scenario/config/expectedData.yaml b/test/plugin/scenarios/tomcat-10x-scenario/config/expectedData.yaml
new file mode 100644
index 000000000..b8fa2322f
--- /dev/null
+++ b/test/plugin/scenarios/tomcat-10x-scenario/config/expectedData.yaml
@@ -0,0 +1,74 @@
+# 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: tomcat-10x-scenario
+ segmentSize: ge 2
+ segments:
+ - segmentId: not null
+ spans:
+ - operationName: POST:/tomcat-10x-scenario/case/tomcat-10x-scenario
+ operationId: 0
+ 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/tomcat-10x-scenario/case/tomcat-10x-scenario'}
+ - {key: http.method, value: POST}
+ refs:
+ - {parentEndpoint: 'GET:/tomcat-10x-scenario/case/tomcat-10x-scenario', networkAddress: 'localhost:8080',
+ refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null,
+ parentServiceInstance: not null, parentService: tomcat-10x-scenario,
+ traceId: not null}
+ - segmentId: not null
+ spans:
+ - operationName: /tomcat-10x-scenario/case/tomcat-10x-scenario
+ operationId: 0
+ parentSpanId: 0
+ spanId: 1
+ spanLayer: Http
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 2
+ isError: false
+ spanType: Exit
+ peer: localhost:8080
+ skipAnalysis: false
+ tags:
+ - {key: url, value: 'http://localhost:8080/tomcat-10x-scenario/case/tomcat-10x-scenario'}
+ - {key: http.method, value: POST}
+ - {key: http.status_code, value: "200"}
+ - operationName: GET:/tomcat-10x-scenario/case/tomcat-10x-scenario
+ operationId: 0
+ 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/tomcat-10x-scenario/case/tomcat-10x-scenario'}
+ - {key: http.method, value: GET}
diff --git a/test/plugin/scenarios/tomcat-10x-scenario/configuration.yml b/test/plugin/scenarios/tomcat-10x-scenario/configuration.yml
new file mode 100644
index 000000000..fac58bdfd
--- /dev/null
+++ b/test/plugin/scenarios/tomcat-10x-scenario/configuration.yml
@@ -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/tomcat-10x-scenario/case/tomcat-10x-scenario
+healthCheck: http://localhost:8080/tomcat-10x-scenario/case/healthCheck
diff --git a/test/plugin/scenarios/tomcat-10x-scenario/pom.xml b/test/plugin/scenarios/tomcat-10x-scenario/pom.xml
new file mode 100644
index 000000000..17647aed3
--- /dev/null
+++ b/test/plugin/scenarios/tomcat-10x-scenario/pom.xml
@@ -0,0 +1,81 @@
+
+
+
+
+ org.apache.skywalking.apm.testcase
+ tomcat-10x-scenario
+ 1.0.0
+ war
+
+ 4.0.0
+
+ skywalking-tomcat-10x-scenario
+
+
+ UTF-8
+ 1.8
+ 1.0
+ 1.18.20
+
+
+
+
+ jakarta.servlet
+ jakarta.servlet-api
+ 5.0.0
+
+
+ org.apache.logging.log4j
+ log4j-api
+ 2.8.1
+
+
+ org.apache.logging.log4j
+ log4j-core
+ 2.8.1
+
+
+ org.projectlombok
+ lombok
+ ${lombok.version}
+ provided
+
+
+ org.apache.httpcomponents
+ httpclient
+ 4.3
+
+
+
+
+ tomcat-10x-scenario
+
+
+ maven-compiler-plugin
+
+ ${compiler.version}
+ ${compiler.version}
+ ${project.build.sourceEncoding}
+
+
+
+
+
diff --git a/test/plugin/scenarios/tomcat-10x-scenario/src/main/java/org/apache/skywalking/apm/testcase/tomcat10x/CaseServlet.java b/test/plugin/scenarios/tomcat-10x-scenario/src/main/java/org/apache/skywalking/apm/testcase/tomcat10x/CaseServlet.java
new file mode 100644
index 000000000..441f4e0e0
--- /dev/null
+++ b/test/plugin/scenarios/tomcat-10x-scenario/src/main/java/org/apache/skywalking/apm/testcase/tomcat10x/CaseServlet.java
@@ -0,0 +1,61 @@
+/*
+ * 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.tomcat10x;
+
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServlet;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.ResponseHandler;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+public class CaseServlet extends HttpServlet {
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
+ HttpPost httpPost = new HttpPost("http://localhost:8080/tomcat-10x-scenario/case/tomcat-10x-scenario");
+ ResponseHandler responseHandler = response -> {
+ HttpEntity entity = response.getEntity();
+ return entity != null ? EntityUtils.toString(entity) : null;
+ };
+ httpClient.execute(httpPost, responseHandler);
+ }
+ PrintWriter writer = resp.getWriter();
+ writer.write("Success1");
+ writer.flush();
+ writer.close();
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ PrintWriter writer = resp.getWriter();
+ writer.write("Success2");
+ writer.flush();
+ writer.close();
+ }
+
+}
diff --git a/test/plugin/scenarios/tomcat-10x-scenario/src/main/java/org/apache/skywalking/apm/testcase/tomcat10x/ErrorCatchServlet.java b/test/plugin/scenarios/tomcat-10x-scenario/src/main/java/org/apache/skywalking/apm/testcase/tomcat10x/ErrorCatchServlet.java
new file mode 100644
index 000000000..8941b33f9
--- /dev/null
+++ b/test/plugin/scenarios/tomcat-10x-scenario/src/main/java/org/apache/skywalking/apm/testcase/tomcat10x/ErrorCatchServlet.java
@@ -0,0 +1,41 @@
+/*
+ * 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.tomcat10x;
+
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServlet;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+public class ErrorCatchServlet extends HttpServlet {
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ PrintWriter writer = resp.getWriter();
+ writer.write("404");
+ writer.flush();
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ doGet(req, resp);
+ }
+}
diff --git a/test/plugin/scenarios/tomcat-10x-scenario/src/main/java/org/apache/skywalking/apm/testcase/tomcat10x/HealthCheckServlet.java b/test/plugin/scenarios/tomcat-10x-scenario/src/main/java/org/apache/skywalking/apm/testcase/tomcat10x/HealthCheckServlet.java
new file mode 100644
index 000000000..fe5be9a43
--- /dev/null
+++ b/test/plugin/scenarios/tomcat-10x-scenario/src/main/java/org/apache/skywalking/apm/testcase/tomcat10x/HealthCheckServlet.java
@@ -0,0 +1,41 @@
+/*
+ * 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.tomcat10x;
+
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServlet;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+public class HealthCheckServlet extends HttpServlet {
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ PrintWriter writer = resp.getWriter();
+ writer.write("Success");
+ writer.flush();
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ doGet(req, resp);
+ }
+}
diff --git a/test/plugin/scenarios/tomcat-10x-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/tomcat-10x-scenario/src/main/resources/log4j2.xml
new file mode 100644
index 000000000..9849ed5a8
--- /dev/null
+++ b/test/plugin/scenarios/tomcat-10x-scenario/src/main/resources/log4j2.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test/plugin/scenarios/tomcat-10x-scenario/src/main/webapp/WEB-INF/web.xml b/test/plugin/scenarios/tomcat-10x-scenario/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 000000000..2bcf03543
--- /dev/null
+++ b/test/plugin/scenarios/tomcat-10x-scenario/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,58 @@
+
+
+ skywalking-tomcat-10x-scenario
+
+
+ caseServlet
+ org.apache.skywalking.apm.testcase.tomcat10x.CaseServlet
+
+
+
+ healthCheck
+ org.apache.skywalking.apm.testcase.tomcat10x.HealthCheckServlet
+
+
+
+ errorCatch
+ org.apache.skywalking.apm.testcase.tomcat10x.ErrorCatchServlet
+
+
+
+ errorCatch
+ /case/errorCatch
+
+
+
+ healthCheck
+ /case/healthCheck
+
+
+
+ caseServlet
+ /case/tomcat-10x-scenario
+
+
+ 404
+ /case/errorCatch
+
+
diff --git a/test/plugin/scenarios/tomcat-10x-scenario/support-version.list b/test/plugin/scenarios/tomcat-10x-scenario/support-version.list
new file mode 100644
index 000000000..324476b8a
--- /dev/null
+++ b/test/plugin/scenarios/tomcat-10x-scenario/support-version.list
@@ -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.
+
+# Use `.github/workflows/plugins-tomcat10-test.0.yaml` to control Tomcat verion
+# Current tested Tomcat 10.0.22
+all