diff --git a/.github/workflows/plugins-jdk17-test.0.yaml b/.github/workflows/plugins-jdk17-test.0.yaml index 556214b9db..88ec2e1750 100644 --- a/.github/workflows/plugins-jdk17-test.0.yaml +++ b/.github/workflows/plugins-jdk17-test.0.yaml @@ -62,6 +62,8 @@ jobs: - jetty-11.x-thread-pool-scenario - grizzly-2.3.x-4.x-scenario - grizzly-2.3.x-4.x-workthreadpool-scenario + - jetty-11.x-scenario + - jetty-10.x-scenario steps: - uses: actions/checkout@v2 with: diff --git a/CHANGES.md b/CHANGES.md index a641b1cb68..95d404c07e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ Release Notes. ------------------ * Support Jdk17 ZGC metric collect +* Support Jetty 11.x plugin #### Documentation diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-11.x-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-11.x-plugin/pom.xml new file mode 100644 index 0000000000..f8cecfea1a --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-11.x-plugin/pom.xml @@ -0,0 +1,45 @@ + + + + + jetty-plugins + org.apache.skywalking + 8.17.0-SNAPSHOT + + 4.0.0 + + apm-jetty-client-11.x-plugin + jar + + jetty-client-11.x-plugin + http://maven.apache.org + + + 11.0.15 + + + + + org.eclipse.jetty + jetty-client + ${jetty-client.version} + provided + + + diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/client/SyncHttpRequestSendInterceptor.java b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/client/SyncHttpRequestSendInterceptor.java new file mode 100644 index 0000000000..06ca5057ba --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/client/SyncHttpRequestSendInterceptor.java @@ -0,0 +1,81 @@ +/* + * 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.v11.client; + +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.network.trace.component.ComponentsDefine; +import org.eclipse.jetty.client.HttpRequest; +import org.eclipse.jetty.http.HttpField; + +import java.lang.reflect.Method; + +public class SyncHttpRequestSendInterceptor implements InstanceMethodsAroundInterceptor { + + @Override + public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + MethodInterceptResult result) throws Throwable { + HttpRequest request = (HttpRequest) objInst; + ContextCarrier contextCarrier = new ContextCarrier(); + AbstractSpan span = ContextManager.createExitSpan(request.getURI() + .getPath(), contextCarrier, request.getHost() + ":" + request + .getPort()); + span.setComponent(ComponentsDefine.JETTY_CLIENT); + + Tags.HTTP.METHOD.set(span, getHttpMethod(request)); + Tags.URL.set(span, request.getURI().toString()); + SpanLayer.asHttp(span); + + CarrierItem next = contextCarrier.items(); + while (next.hasNext()) { + next = next.next(); + request.addHeader(new HttpField(next.getHeadKey(), next.getHeadValue())); + } + } + + @Override + public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + Object ret) throws Throwable { + ContextManager.stopSpan(); + return ret; + } + + @Override + public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, + Class[] argumentsTypes, Throwable t) { + ContextManager.activeSpan().log(t); + } + + public String getHttpMethod(HttpRequest request) { + String method = request.getMethod(); + + if (method == null || method.length() == 0) { + method = "GET"; + } + + return method; + } +} diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/client/define/HttpRequestInstrumentation.java b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/client/define/HttpRequestInstrumentation.java new file mode 100644 index 0000000000..4b9f4b7746 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/client/define/HttpRequestInstrumentation.java @@ -0,0 +1,76 @@ +/* + * 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.v11.client.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 org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; + +import static net.bytebuddy.matcher.ElementMatchers.named; +import static net.bytebuddy.matcher.ElementMatchers.takesArguments; + +public class HttpRequestInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + + private static final String ENHANCE_CLASS = "org.eclipse.jetty.client.HttpRequest"; + private static final String ENHANCE_CLASS_NAME = "send"; + public static final String SYNC_SEND_INTERCEPTOR = "org.apache.skywalking.apm.plugin.jetty.v11.client" + + ".SyncHttpRequestSendInterceptor"; + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[0]; + } + + @Override + public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[]{ + new InstanceMethodsInterceptPoint() { + //sync call interceptor point + @Override + public ElementMatcher getMethodsMatcher() { + return named(ENHANCE_CLASS_NAME).and(takesArguments(0)); + } + + @Override + public String getMethodsInterceptor() { + return SYNC_SEND_INTERCEPTOR; + } + + @Override + public boolean isOverrideArgs() { + return false; + } + } + }; + } + + @Override + protected ClassMatch enhanceClass() { + return NameMatch.byName(ENHANCE_CLASS); + } + + @Override + protected String[] witnessClasses() { + return new String[]{"org.eclipse.jetty.client.jmx.HttpClientMBean"}; + } +} diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-11.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-11.x-plugin/src/main/resources/skywalking-plugin.def new file mode 100644 index 0000000000..3311ec791d --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-11.x-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-client-11.x=org.apache.skywalking.apm.plugin.jetty.v11.client.define.HttpRequestInstrumentation diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/client/define/HttpRequestInstrumentation.java b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/client/define/HttpRequestInstrumentation.java index cb20e10828..d0456c11d0 100644 --- a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/client/define/HttpRequestInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-client-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/client/define/HttpRequestInstrumentation.java @@ -20,12 +20,16 @@ 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; import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; +import java.util.Collections; +import java.util.List; + import static net.bytebuddy.matcher.ElementMatchers.named; import static net.bytebuddy.matcher.ElementMatchers.takesArguments; @@ -78,4 +82,12 @@ protected ClassMatch enhanceClass() { protected String[] witnessClasses() { return new String[] {"org.eclipse.jetty.client.AbstractHttpClientTransport"}; } + + @Override + protected List witnessMethods() { + return Collections.singletonList(new WitnessMethod( + "org.eclipse.jetty.http.HttpFields", + named("getQuality") + )); + } } diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-plugin/pom.xml new file mode 100644 index 0000000000..c73df2d53f --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-plugin/pom.xml @@ -0,0 +1,45 @@ + + + + + jetty-plugins + org.apache.skywalking + 8.17.0-SNAPSHOT + + 4.0.0 + + apm-jetty-server-11.x-plugin + jar + + jetty-server-11.x-plugin + http://maven.apache.org + + + 11.0.15 + + + + + org.eclipse.jetty + jetty-server + ${jetty-server.version} + provided + + + diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/server/Constants.java b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/server/Constants.java new file mode 100644 index 0000000000..156bb0517b --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/server/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.jetty.v11.server; + +public class Constants { + public static final String FORWARD_REQUEST_FLAG = "SW_FORWARD_REQUEST_FLAG"; +} diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/server/ForwardInterceptor.java b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/server/ForwardInterceptor.java new file mode 100644 index 0000000000..f98e15c8af --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/server/ForwardInterceptor.java @@ -0,0 +1,63 @@ +/* + * 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.v11.server; + +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", (String) 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 { + 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[2]); + } +} diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/server/HandleInterceptor.java b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/server/HandleInterceptor.java new file mode 100644 index 0000000000..a8f663a917 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/server/HandleInterceptor.java @@ -0,0 +1,80 @@ +/* + * 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.v11.server; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +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.network.trace.component.ComponentsDefine; +import org.eclipse.jetty.server.HttpChannel; + +import java.lang.reflect.Method; + +public class HandleInterceptor implements InstanceMethodsAroundInterceptor { + + @Override + public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + MethodInterceptResult result) throws Throwable { + HttpChannel httpChannel = (HttpChannel) objInst; + HttpServletRequest servletRequest = httpChannel.getRequest(); + + ContextCarrier contextCarrier = new ContextCarrier(); + + CarrierItem next = contextCarrier.items(); + while (next.hasNext()) { + next = next.next(); + next.setHeadValue(servletRequest.getHeader(next.getHeadKey())); + } + + AbstractSpan span = ContextManager.createEntrySpan(servletRequest.getRequestURI(), contextCarrier); + Tags.URL.set(span, servletRequest.getRequestURL().toString()); + Tags.HTTP.METHOD.set(span, servletRequest.getMethod()); + span.setComponent(ComponentsDefine.JETTY_SERVER); + SpanLayer.asHttp(span); + } + + @Override + public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + Object ret) throws Throwable { + HttpChannel httpChannel = (HttpChannel) objInst; + HttpServletResponse servletResponse = httpChannel.getResponse(); + AbstractSpan span = ContextManager.activeSpan(); + Tags.HTTP_RESPONSE_STATUS_CODE.set(span, servletResponse.getStatus()); + if (servletResponse.getStatus() >= 400) { + span.errorOccurred(); + } + ContextManager.stopSpan(); + ContextManager.getRuntimeContext().remove(Constants.FORWARD_REQUEST_FLAG); + return ret; + } + + @Override + public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments, + Class[] argumentsTypes, Throwable t) { + ContextManager.activeSpan().log(t); + } +} diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/server/define/AbstractWitnessInstrumentation.java b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/server/define/AbstractWitnessInstrumentation.java new file mode 100644 index 0000000000..ae0eef39f3 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/server/define/AbstractWitnessInstrumentation.java @@ -0,0 +1,39 @@ +/* + * 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.v11.server.define; + +import org.apache.skywalking.apm.agent.core.plugin.WitnessMethod; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; + +import java.util.Collections; +import java.util.List; + +import static net.bytebuddy.matcher.ElementMatchers.named; +import static net.bytebuddy.matcher.ElementMatchers.takesArgument; + +public abstract class AbstractWitnessInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + @Override + protected List witnessMethods() { + return Collections.singletonList(new WitnessMethod( + "org.eclipse.jetty.server.Handler", + named("handle").and(takesArgument(2, named("jakarta.servlet.http.HttpServletRequest"))) + )); + } +} diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/server/define/DispatcherInstrumentation.java b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/server/define/DispatcherInstrumentation.java new file mode 100644 index 0000000000..d843ae629f --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/server/define/DispatcherInstrumentation.java @@ -0,0 +1,80 @@ +/* + * 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.v11.server.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.match.ClassMatch; + +import static net.bytebuddy.matcher.ElementMatchers.named; +import static org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType; +import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName; + +public class DispatcherInstrumentation extends AbstractWitnessInstrumentation { + + private static final String ENHANCE_CLASS = "org.eclipse.jetty.server.Dispatcher"; + public static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.jetty.v11.server.ForwardInterceptor"; + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[] { + new ConstructorInterceptPoint() { + @Override + public ElementMatcher getConstructorMatcher() { + return takesArgumentWithType(2, "java.lang.String"); + } + + @Override + public String getConstructorInterceptor() { + return INTERCEPT_CLASS; + } + } + }; + } + + @Override + public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[] { + new InstanceMethodsInterceptPoint() { + @Override + public ElementMatcher getMethodsMatcher() { + return named("forward"); + } + + @Override + public String getMethodsInterceptor() { + return INTERCEPT_CLASS; + } + + @Override + public boolean isOverrideArgs() { + return false; + } + } + }; + } + + @Override + protected ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); + } +} diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/server/define/JettyInstrumentation.java b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/server/define/JettyInstrumentation.java new file mode 100644 index 0000000000..417dc67df3 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v11/server/define/JettyInstrumentation.java @@ -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. + * + */ + +package org.apache.skywalking.apm.plugin.jetty.v11.server.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.match.ClassMatch; +import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; + +import static net.bytebuddy.matcher.ElementMatchers.named; + +/** + * {@link JettyInstrumentation} enhance the handle method in org.eclipse.jetty.server.handler.HandlerList + * by HandleInterceptor + */ +public class JettyInstrumentation extends AbstractWitnessInstrumentation { + + private static final String ENHANCE_CLASS = "org.eclipse.jetty.server.HttpChannel"; + private static final String ENHANCE_METHOD = "handle"; + private static final String INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.jetty.v11.server" + + ".HandleInterceptor"; + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[0]; + } + + @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 NameMatch.byName(ENHANCE_CLASS); + } +} diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-plugin/src/main/resources/skywalking-plugin.def new file mode 100644 index 0000000000..a7828a8f4b --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-11.x-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. + +jetty-server-11.x=org.apache.skywalking.apm.plugin.jetty.v11.server.define.JettyInstrumentation +jetty-server-11.x=org.apache.skywalking.apm.plugin.jetty.v11.server.define.DispatcherInstrumentation diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/server/define/AbstractWitnessInstrumentation.java b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/server/define/AbstractWitnessInstrumentation.java new file mode 100644 index 0000000000..9ed1aba497 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/server/define/AbstractWitnessInstrumentation.java @@ -0,0 +1,39 @@ +/* + * 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.v9.server.define; + +import org.apache.skywalking.apm.agent.core.plugin.WitnessMethod; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine; + +import java.util.Collections; +import java.util.List; + +import static net.bytebuddy.matcher.ElementMatchers.named; +import static net.bytebuddy.matcher.ElementMatchers.takesArgument; + +public abstract class AbstractWitnessInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + @Override + protected List witnessMethods() { + return Collections.singletonList(new WitnessMethod( + "org.eclipse.jetty.server.Handler", + named("handle").and(takesArgument(2, named("javax.servlet.http.HttpServletRequest"))) + )); + } +} diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/server/define/DispatcherInstrumentation.java b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/server/define/DispatcherInstrumentation.java index 309d7eff12..343e7d28c8 100644 --- a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/server/define/DispatcherInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/server/define/DispatcherInstrumentation.java @@ -23,54 +23,53 @@ 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.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType; import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName; -public class DispatcherInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { +public class DispatcherInstrumentation extends AbstractWitnessInstrumentation { private static final String ENHANCE_CLASS = "org.eclipse.jetty.server.Dispatcher"; public static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.jetty.v9.server.ForwardInterceptor"; @Override public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { - return new ConstructorInterceptPoint[] { - new ConstructorInterceptPoint() { - @Override - public ElementMatcher getConstructorMatcher() { - return takesArgumentWithType(2, "java.lang.String"); - } + return new ConstructorInterceptPoint[]{ + new ConstructorInterceptPoint() { + @Override + public ElementMatcher getConstructorMatcher() { + return takesArgumentWithType(2, "java.lang.String"); + } - @Override - public String getConstructorInterceptor() { - return INTERCEPT_CLASS; + @Override + public String getConstructorInterceptor() { + return INTERCEPT_CLASS; + } } - } }; } @Override public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { - return new InstanceMethodsInterceptPoint[] { - new InstanceMethodsInterceptPoint() { - @Override - public ElementMatcher getMethodsMatcher() { - return named("forward"); - } + return new InstanceMethodsInterceptPoint[]{ + new InstanceMethodsInterceptPoint() { + @Override + public ElementMatcher getMethodsMatcher() { + return named("forward"); + } - @Override - public String getMethodsInterceptor() { - return INTERCEPT_CLASS; - } + @Override + public String getMethodsInterceptor() { + return INTERCEPT_CLASS; + } - @Override - public boolean isOverrideArgs() { - return false; + @Override + public boolean isOverrideArgs() { + return false; + } } - } }; } diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/server/define/JettyInstrumentation.java b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/server/define/JettyInstrumentation.java index 439128a89c..59ac7307e6 100644 --- a/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/server/define/JettyInstrumentation.java +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/jetty-server-9.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/jetty/v9/server/define/JettyInstrumentation.java @@ -22,7 +22,6 @@ 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 org.apache.skywalking.apm.agent.core.plugin.match.NameMatch; @@ -32,7 +31,7 @@ * {@link JettyInstrumentation} enhance the handle method in org.eclipse.jetty.server.handler.HandlerList * by HandleInterceptor */ -public class JettyInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { +public class JettyInstrumentation extends AbstractWitnessInstrumentation { private static final String ENHANCE_CLASS = "org.eclipse.jetty.server.HttpChannel"; private static final String ENHANCE_METHOD = "handle"; @@ -45,23 +44,23 @@ public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { @Override public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { - return new InstanceMethodsInterceptPoint[] { - new InstanceMethodsInterceptPoint() { - @Override - public ElementMatcher getMethodsMatcher() { - return named(ENHANCE_METHOD); - } + return new InstanceMethodsInterceptPoint[]{ + new InstanceMethodsInterceptPoint() { + @Override + public ElementMatcher getMethodsMatcher() { + return named(ENHANCE_METHOD); + } - @Override - public String getMethodsInterceptor() { - return INTERCEPTOR_CLASS; - } + @Override + public String getMethodsInterceptor() { + return INTERCEPTOR_CLASS; + } - @Override - public boolean isOverrideArgs() { - return false; + @Override + public boolean isOverrideArgs() { + return false; + } } - } }; } diff --git a/apm-sniffer/apm-sdk-plugin/jetty-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/jetty-plugin/pom.xml index 1b7bc0de2e..1a86067746 100644 --- a/apm-sniffer/apm-sdk-plugin/jetty-plugin/pom.xml +++ b/apm-sniffer/apm-sdk-plugin/jetty-plugin/pom.xml @@ -31,6 +31,8 @@ jetty-client-9.x-plugin jetty-server-9.x-plugin jetty-client-9.0-plugin + jetty-server-11.x-plugin + jetty-client-11.x-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 92beac632d..9043febbf7 100644 --- a/docs/en/setup/service-agent/java-agent/Plugin-list.md +++ b/docs/en/setup/service-agent/java-agent/Plugin-list.md @@ -163,3 +163,5 @@ - jersey-3.x - grizzly-2.3.x-4.x - grizzly-2.3.x-4.x-threadpool +- jetty-server-11.x +- jetty-client-11.x 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 d6e71f4a14..a6ed661e48 100644 --- a/docs/en/setup/service-agent/java-agent/Supported-list.md +++ b/docs/en/setup/service-agent/java-agent/Supported-list.md @@ -14,7 +14,7 @@ metrics based on the tracing data. * [Struts2 MVC](http://struts.apache.org/) 2.3.x -> 2.5.x * [Resin](https://www.caucho.com/resin-4.0/) 3 (Optional¹) * [Resin](https://www.caucho.com/resin-4.0/) 4 (Optional¹) - * [Jetty Server](http://www.eclipse.org/jetty/) 9 + * [Jetty Server](http://www.eclipse.org/jetty/) 9.x -> 11.x * [Spring WebFlux](https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html) 5.x (Optional¹) * [Undertow](http://undertow.io/) 1.3.0.Final -> 2.0.27.Final * [RESTEasy](https://resteasy.github.io/) 3.1.0.Final -> 4.7.6.Final @@ -31,7 +31,7 @@ metrics based on the tracing data. * [Apache httpcomponent HttpClient](http://hc.apache.org/) 2.0 -> 3.1, 4.2, 4.3, 5.0, 5.1 * [Spring RestTemplate](https://github.com/spring-projects/spring-framework) 4.x * [Spring RestTemplate](https://github.com/spring-projects/spring-framework) 6.x (Optional²) - * [Jetty Client](http://www.eclipse.org/jetty/) 9 + * [Jetty Client](http://www.eclipse.org/jetty/) 9.x -> 11.x * [Apache httpcomponent AsyncClient](https://hc.apache.org/httpcomponents-asyncclient-4.1.x/) 4.x * [AsyncHttpClient](https://github.com/AsyncHttpClient/async-http-client) 2.1+ * JRE HttpURLConnection (Optional²) diff --git a/test/plugin/scenarios/jetty-10.x-scenario/bin/startup.sh b/test/plugin/scenarios/jetty-10.x-scenario/bin/startup.sh new file mode 100644 index 0000000000..485d21665b --- /dev/null +++ b/test/plugin/scenarios/jetty-10.x-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-10.x-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/jetty-10.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/jetty-10.x-scenario/config/expectedData.yaml new file mode 100644 index 0000000000..74aeaf7c43 --- /dev/null +++ b/test/plugin/scenarios/jetty-10.x-scenario/config/expectedData.yaml @@ -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: jetty-10.x-scenario + segmentSize: ge 3 + segments: + - segmentId: not null + spans: + - operationName: /jetty-10.x-scenario/case/receive-context + parentSpanId: '-1' + spanId: '0' + spanLayer: Http + tags: + - key: url + value: http://127.0.0.1:18080/jetty-10.x-scenario/case/receive-context + - key: http.method + value: GET + - key: http.status_code + value: '200' + refs: + - parentEndpoint: /jetty-10.x-scenario/case/jetty-10.x-scenario + networkAddress: '127.0.0.1:18080' + refType: CrossProcess + parentSpanId: 1 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: jetty-10.x-scenario + traceId: not null + startTime: gt 0 + endTime: gt 0 + componentId: '19' + isError: 'false' + spanType: Entry + peer: '' + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: /jetty-10.x-scenario/case/receive-context + parentSpanId: '0' + spanId: '1' + spanLayer: Http + tags: + - key: http.method + value: GET + - key: url + value: 'http://127.0.0.1:18080/jetty-10.x-scenario/case/receive-context' + startTime: gt 0 + endTime: gt 0 + componentId: '18' + isError: 'false' + spanType: Exit + peer: '127.0.0.1:18080' + skipAnalysis: 'false' + - operationName: /jetty-10.x-scenario/case/jetty-10.x-scenario + parentSpanId: '-1' + spanId: '0' + spanLayer: Http + startTime: gt 0 + endTime: gt 0 + componentId: '19' + isError: 'false' + spanType: Entry + peer: '' + skipAnalysis: 'false' + tags: + - key: url + value: http://localhost:18080/jetty-10.x-scenario/case/jetty-10.x-scenario + - key: http.method + value: GET + - key: http.status_code + value: '200' + diff --git a/test/plugin/scenarios/jetty-10.x-scenario/configuration.yml b/test/plugin/scenarios/jetty-10.x-scenario/configuration.yml new file mode 100644 index 0000000000..a7e61d09b7 --- /dev/null +++ b/test/plugin/scenarios/jetty-10.x-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-10.x-scenario/case/jetty-10.x-scenario +healthCheck: http://localhost:18080/jetty-10.x-scenario/case/healthCheck +startScript: ./bin/startup.sh +environment: +dependencies: diff --git a/test/plugin/scenarios/jetty-10.x-scenario/pom.xml b/test/plugin/scenarios/jetty-10.x-scenario/pom.xml new file mode 100644 index 0000000000..19b6abf947 --- /dev/null +++ b/test/plugin/scenarios/jetty-10.x-scenario/pom.xml @@ -0,0 +1,127 @@ + + + + + org.apache.skywalking.apm.testcase + jetty-10.x-scenario + 1.0.0 + jar + + 4.0.0 + + + UTF-8 + 1.8 + 3.8.1 + + 10.0.15 + + 2.6.2 + + + skywalking-jetty-10.x-scenario + + + + org.eclipse.jetty + jetty-server + ${test.framework.version} + + + org.eclipse.jetty + jetty-servlet + ${test.framework.version} + + + org.eclipse.jetty + jetty-client + ${test.framework.version} + + + + + + jetty-10.x-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.jetty10xserver.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-10.x-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/jetty-10.x-scenario/src/main/assembly/assembly.xml new file mode 100644 index 0000000000..0b97eb2dae --- /dev/null +++ b/test/plugin/scenarios/jetty-10.x-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/jetty-10.x-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/jetty-10.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty10xserver/Application.java b/test/plugin/scenarios/jetty-10.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty10xserver/Application.java new file mode 100644 index 0000000000..dbcfff57d7 --- /dev/null +++ b/test/plugin/scenarios/jetty-10.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty10xserver/Application.java @@ -0,0 +1,42 @@ +/* + * 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.jetty10xserver; + +import org.apache.skywalking.apm.testcase.jetty10xserver.controller.CaseController; +import org.apache.skywalking.apm.testcase.jetty10xserver.controller.ContextReceiveController; +import org.apache.skywalking.apm.testcase.jetty10xserver.controller.HealCheckController; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.servlet.ServletContextHandler; + +import java.net.InetSocketAddress; + +public class Application { + + public static void main(String[] args) throws Exception { + Server jettyServer = new Server(new InetSocketAddress("0.0.0.0", 18080)); + String contextPath = "/jetty-10.x-scenario"; + ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS); + servletContextHandler.setContextPath(contextPath); + servletContextHandler.addServlet(CaseController.class, CaseController.SERVLET_PATH); + servletContextHandler.addServlet(ContextReceiveController.class, ContextReceiveController.SERVLET_PATH); + servletContextHandler.addServlet(HealCheckController.class, HealCheckController.SERVLET_PATH); + jettyServer.setHandler(servletContextHandler); + jettyServer.start(); + } +} diff --git a/test/plugin/scenarios/jetty-10.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty10xserver/controller/CaseController.java b/test/plugin/scenarios/jetty-10.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty10xserver/controller/CaseController.java new file mode 100644 index 0000000000..1442bc8845 --- /dev/null +++ b/test/plugin/scenarios/jetty-10.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty10xserver/controller/CaseController.java @@ -0,0 +1,46 @@ +/* + * 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.jetty10xserver.controller; + +import org.eclipse.jetty.client.HttpClient; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +public class CaseController extends HttpServlet { + + public static String SERVLET_PATH = "/case/jetty-10.x-scenario"; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + try { + HttpClient client = new HttpClient(); + client.start(); + String cc = client.GET("http://127.0.0.1:18080/jetty-10.x-scenario/case/receive-context") + .getContentAsString(); + resp.getWriter().println(cc); + } catch (InterruptedException ignored) { + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} diff --git a/test/plugin/scenarios/jetty-10.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty10xserver/controller/ContextReceiveController.java b/test/plugin/scenarios/jetty-10.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty10xserver/controller/ContextReceiveController.java new file mode 100644 index 0000000000..9425a8de10 --- /dev/null +++ b/test/plugin/scenarios/jetty-10.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty10xserver/controller/ContextReceiveController.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.jetty10xserver.controller; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +public class ContextReceiveController extends HttpServlet { + public static String SERVLET_PATH = "/case/receive-context"; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + resp.getWriter().println("hello"); + } +} diff --git a/test/plugin/scenarios/jetty-10.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty10xserver/controller/HealCheckController.java b/test/plugin/scenarios/jetty-10.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty10xserver/controller/HealCheckController.java new file mode 100644 index 0000000000..9a14b1adc6 --- /dev/null +++ b/test/plugin/scenarios/jetty-10.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty10xserver/controller/HealCheckController.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.jetty10xserver.controller; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +public class HealCheckController extends HttpServlet { + public static String SERVLET_PATH = "/case/healthCheck"; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + resp.getWriter().println("hello"); + } +} diff --git a/test/plugin/scenarios/jetty-10.x-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/jetty-10.x-scenario/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..9849ed5a8a --- /dev/null +++ b/test/plugin/scenarios/jetty-10.x-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/jetty-10.x-scenario/support-version.list b/test/plugin/scenarios/jetty-10.x-scenario/support-version.list new file mode 100644 index 0000000000..90fcd58492 --- /dev/null +++ b/test/plugin/scenarios/jetty-10.x-scenario/support-version.list @@ -0,0 +1,20 @@ +# 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. + +10.0.0 +10.0.7 +10.0.15 + diff --git a/test/plugin/scenarios/jetty-11.x-scenario/bin/startup.sh b/test/plugin/scenarios/jetty-11.x-scenario/bin/startup.sh new file mode 100644 index 0000000000..524e87667f --- /dev/null +++ b/test/plugin/scenarios/jetty-11.x-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-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/jetty-11.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/jetty-11.x-scenario/config/expectedData.yaml new file mode 100644 index 0000000000..dd65ed929b --- /dev/null +++ b/test/plugin/scenarios/jetty-11.x-scenario/config/expectedData.yaml @@ -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. +segmentItems: + - serviceName: jetty-11.x-scenario + segmentSize: ge 3 + segments: + - segmentId: not null + spans: + - operationName: /jetty-11.x-scenario/case/receive-context + parentSpanId: '-1' + spanId: '0' + spanLayer: Http + tags: + - key: url + value: http://127.0.0.1:18080/jetty-11.x-scenario/case/receive-context + - key: http.method + value: GET + - key: http.status_code + value: '200' + refs: + - parentEndpoint: /jetty-11.x-scenario/case/jetty-11.x-scenario + networkAddress: '127.0.0.1:18080' + refType: CrossProcess + parentSpanId: 1 + parentTraceSegmentId: not null + parentServiceInstance: not null + parentService: jetty-11.x-scenario + traceId: not null + startTime: gt 0 + endTime: gt 0 + componentId: '19' + isError: 'false' + spanType: Entry + peer: '' + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: /jetty-11.x-scenario/case/receive-context + parentSpanId: '0' + spanId: '1' + spanLayer: Http + tags: + - key: http.method + value: GET + - key: url + value: 'http://127.0.0.1:18080/jetty-11.x-scenario/case/receive-context' + startTime: gt 0 + endTime: gt 0 + componentId: '18' + isError: 'false' + spanType: Exit + peer: '127.0.0.1:18080' + skipAnalysis: 'false' + - operationName: /jetty-11.x-scenario/case/jetty-11.x-scenario + parentSpanId: '-1' + spanId: '0' + spanLayer: Http + startTime: gt 0 + endTime: gt 0 + componentId: '19' + isError: 'false' + spanType: Entry + peer: '' + skipAnalysis: 'false' + tags: + - key: url + value: http://localhost:18080/jetty-11.x-scenario/case/jetty-11.x-scenario + - key: http.method + value: GET + - key: http.status_code + value: '200' + + diff --git a/test/plugin/scenarios/jetty-11.x-scenario/configuration.yml b/test/plugin/scenarios/jetty-11.x-scenario/configuration.yml new file mode 100644 index 0000000000..f1bc28fd0f --- /dev/null +++ b/test/plugin/scenarios/jetty-11.x-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-scenario/case/jetty-11.x-scenario +healthCheck: http://localhost:18080/jetty-11.x-scenario/case/healthCheck +startScript: ./bin/startup.sh +environment: +dependencies: diff --git a/test/plugin/scenarios/jetty-11.x-scenario/pom.xml b/test/plugin/scenarios/jetty-11.x-scenario/pom.xml new file mode 100644 index 0000000000..d53b0858ff --- /dev/null +++ b/test/plugin/scenarios/jetty-11.x-scenario/pom.xml @@ -0,0 +1,127 @@ + + + + + org.apache.skywalking.apm.testcase + jetty-11.x-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-scenario + + + + org.eclipse.jetty + jetty-server + ${test.framework.version} + + + org.eclipse.jetty + jetty-servlet + ${test.framework.version} + + + org.eclipse.jetty + jetty-client + ${test.framework.version} + + + + + + jetty-11.x-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.jetty11xserver.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-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/jetty-11.x-scenario/src/main/assembly/assembly.xml new file mode 100644 index 0000000000..fd43a98a06 --- /dev/null +++ b/test/plugin/scenarios/jetty-11.x-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/jetty-11.x-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/jetty-11.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty11xserver/Application.java b/test/plugin/scenarios/jetty-11.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty11xserver/Application.java new file mode 100644 index 0000000000..d705b55190 --- /dev/null +++ b/test/plugin/scenarios/jetty-11.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty11xserver/Application.java @@ -0,0 +1,42 @@ +/* + * 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.jetty11xserver; + +import org.apache.skywalking.apm.testcase.jetty11xserver.controller.CaseController; +import org.apache.skywalking.apm.testcase.jetty11xserver.controller.ContextReceiveController; +import org.apache.skywalking.apm.testcase.jetty11xserver.controller.HealCheckController; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.servlet.ServletContextHandler; + +import java.net.InetSocketAddress; + +public class Application { + + public static void main(String[] args) throws Exception { + Server jettyServer = new Server(new InetSocketAddress("0.0.0.0", 18080)); + String contextPath = "/jetty-11.x-scenario"; + ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS); + servletContextHandler.setContextPath(contextPath); + servletContextHandler.addServlet(CaseController.class, CaseController.SERVLET_PATH); + servletContextHandler.addServlet(ContextReceiveController.class, ContextReceiveController.SERVLET_PATH); + servletContextHandler.addServlet(HealCheckController.class, HealCheckController.SERVLET_PATH); + jettyServer.setHandler(servletContextHandler); + jettyServer.start(); + } +} diff --git a/test/plugin/scenarios/jetty-11.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty11xserver/controller/CaseController.java b/test/plugin/scenarios/jetty-11.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty11xserver/controller/CaseController.java new file mode 100644 index 0000000000..267c3bfa22 --- /dev/null +++ b/test/plugin/scenarios/jetty-11.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty11xserver/controller/CaseController.java @@ -0,0 +1,46 @@ +/* + * 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.jetty11xserver.controller; + +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import org.eclipse.jetty.client.HttpClient; + +import java.io.IOException; + +public class CaseController extends HttpServlet { + + public static String SERVLET_PATH = "/case/jetty-11.x-scenario"; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + try { + HttpClient client = new HttpClient(); + client.start(); + String cc = client.GET("http://127.0.0.1:18080/jetty-11.x-scenario/case/receive-context") + .getContentAsString(); + resp.getWriter().println(cc); + } catch (InterruptedException ignored) { + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} diff --git a/test/plugin/scenarios/jetty-11.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty11xserver/controller/ContextReceiveController.java b/test/plugin/scenarios/jetty-11.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty11xserver/controller/ContextReceiveController.java new file mode 100644 index 0000000000..06add37811 --- /dev/null +++ b/test/plugin/scenarios/jetty-11.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty11xserver/controller/ContextReceiveController.java @@ -0,0 +1,35 @@ +/* + * 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.jetty11xserver.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 ContextReceiveController extends HttpServlet { + public static String SERVLET_PATH = "/case/receive-context"; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + resp.getWriter().println("hello"); + } +} diff --git a/test/plugin/scenarios/jetty-11.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty11xserver/controller/HealCheckController.java b/test/plugin/scenarios/jetty-11.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty11xserver/controller/HealCheckController.java new file mode 100644 index 0000000000..a1331f808a --- /dev/null +++ b/test/plugin/scenarios/jetty-11.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/jetty11xserver/controller/HealCheckController.java @@ -0,0 +1,35 @@ +/* + * 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.jetty11xserver.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 HealCheckController extends HttpServlet { + public static String SERVLET_PATH = "/case/healthCheck"; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + resp.getWriter().println("hello"); + } +} diff --git a/test/plugin/scenarios/jetty-11.x-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/jetty-11.x-scenario/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..9849ed5a8a --- /dev/null +++ b/test/plugin/scenarios/jetty-11.x-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-scenario/support-version.list b/test/plugin/scenarios/jetty-11.x-scenario/support-version.list new file mode 100644 index 0000000000..140bec1629 --- /dev/null +++ b/test/plugin/scenarios/jetty-11.x-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. + +11.0.0 +11.0.7 +11.0.15