diff --git a/.github/workflows/plugins-test.yaml b/.github/workflows/plugins-test.yaml index 827088318..c1bccd260 100644 --- a/.github/workflows/plugins-test.yaml +++ b/.github/workflows/plugins-test.yaml @@ -121,7 +121,7 @@ jobs: - name: Run gson-scenario (7) run: bash test/plugin/run.sh gson-scenario - Feign_Canal: + Feign_Canal_Armeria: runs-on: ubuntu-18.04 timeout-minutes: 90 strategy: @@ -149,8 +149,13 @@ jobs: run: bash test/plugin/run.sh customize-scenario - name: Run canal 1.0.24-1.1.2 (5) run: bash test/plugin/run.sh canal-scenario - - name: Run Feign_Canal_Pulsar 2.2.0-2.4.1 (7) + - name: Run Pulsar 2.2.0-2.4.1 (7) run: bash test/plugin/run.sh pulsar-scenario + - name: Run Armeria 0.63.0-0.95.0 (20) + run: bash test/plugin/run.sh armeria-0.96minus-scenario + - name: Run Armeria 0.96.0-0.97.0 (2) + run: bash test/plugin/run.sh armeria-0.96plus-scenario + Hystrix_SofaRPC_Spring30x: runs-on: ubuntu-18.04 diff --git a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java index 6d1eedfee..8ac179945 100755 --- a/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java +++ b/apm-protocol/apm-network/src/main/java/org/apache/skywalking/apm/network/trace/component/ComponentsDefine.java @@ -147,4 +147,6 @@ public class ComponentsDefine { public static final OfficialComponent REST_HIGH_LEVEL_CLIENT = new OfficialComponent(77, "rest-high-level-client"); public static final OfficialComponent SPRING_TX = new OfficialComponent(78, "spring-tx"); + + public static final OfficialComponent ARMERIA = new OfficialComponent(79, "Armeria"); } diff --git a/apm-sniffer/apm-sdk-plugin/armeria-0.84.x-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/armeria-0.84.x-plugin/pom.xml new file mode 100644 index 000000000..d93305a71 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/armeria-0.84.x-plugin/pom.xml @@ -0,0 +1,42 @@ + + + + + + apm-sdk-plugin + org.apache.skywalking + 6.6.0-SNAPSHOT + + 4.0.0 + + apm-armeria-0.8.x-plugin + armeria-0.8.x-plugin + jar + SkyWalking Agent Plugin for Armeria 0.63.0 ~ 0.84.0 + + + + com.linecorp.armeria + armeria + [0.63.0, 0.84.0] + provided + + + \ No newline at end of file diff --git a/apm-sniffer/apm-sdk-plugin/armeria-0.84.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/Armeria084ClientInterceptor.java b/apm-sniffer/apm-sdk-plugin/armeria-0.84.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/Armeria084ClientInterceptor.java new file mode 100644 index 000000000..c5fd74eef --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/armeria-0.84.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/Armeria084ClientInterceptor.java @@ -0,0 +1,108 @@ +/* + * 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.armeria; + +import com.linecorp.armeria.client.UserClient; +import com.linecorp.armeria.common.HttpHeaders; +import com.linecorp.armeria.common.HttpMethod; +import com.linecorp.armeria.common.HttpRequest; +import io.netty.util.AsciiString; +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 java.lang.reflect.Method; +import java.net.URI; + +/** + * @author kezhenxu94 + */ +@SuppressWarnings("rawtypes") +public class Armeria084ClientInterceptor implements InstanceMethodsAroundInterceptor { + @Override + public void beforeMethod( + final EnhancedInstance objInst, + final Method method, + final Object[] allArguments, + final Class[] argumentsTypes, + final MethodInterceptResult result) throws Throwable { + + final UserClient userClient = (UserClient) objInst; + final URI uri = userClient.uri(); + final HttpMethod httpMethod = (HttpMethod) allArguments[1]; + final String path = (String) allArguments[2]; + final Object req = allArguments[5]; + + if (!(req instanceof HttpRequest)) { + return; + } + + final HttpRequest httpReq = (HttpRequest) req; + + final ContextCarrier contextCarrier = new ContextCarrier(); + final String remotePeer = uri.getHost() + ":" + uri.getPort(); + + final AbstractSpan exitSpan = ContextManager.createExitSpan(path, contextCarrier, remotePeer); + + exitSpan.setComponent(ComponentsDefine.ARMERIA); + exitSpan.setLayer(SpanLayer.HTTP); + Tags.HTTP.METHOD.set(exitSpan, httpMethod.name()); + + HttpHeaders headers = httpReq.headers(); + for (CarrierItem item = contextCarrier.items(); item.hasNext(); ) { + item = item.next(); + headers.add(AsciiString.of(item.getHeadKey()), item.getHeadValue()); + } + } + + @Override + public Object afterMethod( + final EnhancedInstance objInst, + final Method method, + final Object[] allArguments, + final Class[] argumentsTypes, + final Object ret) { + + Object req = allArguments[5]; + + if (req instanceof HttpRequest && ContextManager.isActive()) { + ContextManager.stopSpan(); + } + + return ret; + } + + @Override + public void handleMethodException( + final EnhancedInstance objInst, + final Method method, + final Object[] allArguments, + final Class[] argumentsTypes, + final Throwable t) { + if (ContextManager.isActive()) { + ContextManager.activeSpan().errorOccurred().log(t); + } + } +} diff --git a/apm-sniffer/apm-sdk-plugin/armeria-0.84.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/Armeria084ServerInterceptor.java b/apm-sniffer/apm-sdk-plugin/armeria-0.84.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/Armeria084ServerInterceptor.java new file mode 100644 index 000000000..650bfe531 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/armeria-0.84.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/Armeria084ServerInterceptor.java @@ -0,0 +1,89 @@ +/* + * 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.armeria; + +import com.linecorp.armeria.common.DefaultHttpRequest; +import com.linecorp.armeria.common.HttpHeaders; +import io.netty.util.AsciiString; +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 java.lang.reflect.Method; + +/** + * @author kezhenxu94 + */ +public class Armeria084ServerInterceptor implements InstanceMethodsAroundInterceptor { + @Override + public void beforeMethod( + final EnhancedInstance objInst, + final Method method, + final Object[] allArguments, + final Class[] argumentsTypes, + final MethodInterceptResult result) throws Throwable { + + DefaultHttpRequest httpRequest = (DefaultHttpRequest) allArguments[1]; + HttpHeaders headers = httpRequest.headers(); + + ContextCarrier carrier = new ContextCarrier(); + for (CarrierItem item = carrier.items(); item.hasNext(); ) { + item = item.next(); + item.setHeadValue(headers.get(AsciiString.of(item.getHeadKey()))); + } + + AbstractSpan entrySpan = ContextManager.createEntrySpan(httpRequest.path(), carrier); + entrySpan.setComponent(ComponentsDefine.ARMERIA); + entrySpan.setLayer(SpanLayer.HTTP); + entrySpan.setPeer(httpRequest.authority()); + Tags.URL.set(entrySpan, httpRequest.path()); + Tags.HTTP.METHOD.set(entrySpan, httpRequest.method().name()); + } + + @Override + public Object afterMethod( + final EnhancedInstance objInst, + final Method method, + final Object[] allArguments, + final Class[] argumentsTypes, + final Object ret) { + if (ContextManager.isActive()) { + ContextManager.stopSpan(); + } + return ret; + } + + @Override + public void handleMethodException( + final EnhancedInstance objInst, + final Method method, + final Object[] allArguments, + final Class[] argumentsTypes, + final Throwable t) { + if (ContextManager.isActive()) { + ContextManager.activeSpan().errorOccurred().log(t); + } + } +} diff --git a/apm-sniffer/apm-sdk-plugin/armeria-0.84.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/define/Armeria084ClientInstrumentation.java b/apm-sniffer/apm-sdk-plugin/armeria-0.84.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/define/Armeria084ClientInstrumentation.java new file mode 100644 index 000000000..6f815627d --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/armeria-0.84.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/define/Armeria084ClientInstrumentation.java @@ -0,0 +1,89 @@ +/* + * 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.armeria.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 net.bytebuddy.matcher.ElementMatchers.takesArgument; +import static net.bytebuddy.matcher.ElementMatchers.takesArguments; +import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName; + +/** + * @author kezhenxu94 + */ +public class Armeria084ClientInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + private static final String ENHANCE_CLASS = "com.linecorp.armeria.client.UserClient"; + private static final String INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.armeria.Armeria084ClientInterceptor"; + + @Override + protected ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); + } + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[0]; + } + + @Override + public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[]{ + new InstanceMethodsInterceptPoint() { + @Override + public ElementMatcher getMethodsMatcher() { + return named("execute") + .and(takesArguments(7)) + .and(takesArgument(0, named("io.netty.channel.EventLoop"))) + .and(takesArgument(1, named("com.linecorp.armeria.common.HttpMethod"))) + .and(takesArgument(2, named("java.lang.String"))) + .and(takesArgument(3, named("java.lang.String"))) + .and(takesArgument(4, named("java.lang.String"))); + } + + @Override + public String getMethodsInterceptor() { + return INTERCEPTOR_CLASS; + } + + @Override + public boolean isOverrideArgs() { + return false; + } + } + }; + } + + /** + * Witness classes that are added since 0.63.0 + * + * @return witness classes + */ + @Override + protected String[] witnessClasses() { + return new String[]{ + "com.linecorp.armeria.client.endpoint.dns.DnsEndpointGroup", + "com.linecorp.armeria.common.ImmutableHttpHeaders" + }; + } +} diff --git a/apm-sniffer/apm-sdk-plugin/armeria-0.84.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/define/Armeria084ServerInstrumentation.java b/apm-sniffer/apm-sdk-plugin/armeria-0.84.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/define/Armeria084ServerInstrumentation.java new file mode 100644 index 000000000..63cd3481a --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/armeria-0.84.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/define/Armeria084ServerInstrumentation.java @@ -0,0 +1,84 @@ +/* + * 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.armeria.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 net.bytebuddy.matcher.ElementMatchers.takesArgument; +import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName; + +/** + * @author kezhenxu94 + */ +public class Armeria084ServerInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + private static final String ENHANCE_CLASS = "com.linecorp.armeria.server.HttpServerHandler"; + private static final String INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.armeria.Armeria084ServerInterceptor"; + + @Override + protected ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); + } + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[0]; + } + + @Override + public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[]{ + new InstanceMethodsInterceptPoint() { + @Override + public ElementMatcher getMethodsMatcher() { + return named("handleRequest") + .and(takesArgument(0, named("io.netty.channel.ChannelHandlerContext"))) + .and(takesArgument(1, named("com.linecorp.armeria.server.DecodedHttpRequest"))); + } + + @Override + public String getMethodsInterceptor() { + return INTERCEPTOR_CLASS; + } + + @Override + public boolean isOverrideArgs() { + return false; + } + } + }; + } + + /** + * Witness classes that are added since 0.63.0 and removed since 0.85.0 + * + * @return witness classes + */ + @Override + protected String[] witnessClasses() { + return new String[]{ + "com.linecorp.armeria.client.endpoint.dns.DnsEndpointGroup", + "com.linecorp.armeria.common.ImmutableHttpHeaders" + }; + } +} diff --git a/apm-sniffer/apm-sdk-plugin/armeria-0.84.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/armeria-0.84.x-plugin/src/main/resources/skywalking-plugin.def new file mode 100644 index 000000000..83bd6d321 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/armeria-0.84.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. + +armeria-063-084=org.apache.skywalking.apm.plugin.armeria.define.Armeria084ServerInstrumentation +armeria-063-084=org.apache.skywalking.apm.plugin.armeria.define.Armeria084ClientInstrumentation \ No newline at end of file diff --git a/apm-sniffer/apm-sdk-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/pom.xml index a996129fa..13c6dd7ed 100644 --- a/apm-sniffer/apm-sdk-plugin/pom.xml +++ b/apm-sniffer/apm-sdk-plugin/pom.xml @@ -80,6 +80,7 @@ ehcache-2.x-plugin pulsar-plugin netty-socketio-plugin + armeria-0.84.x-plugin pom diff --git a/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/pom.xml b/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/pom.xml new file mode 100644 index 000000000..692430f1d --- /dev/null +++ b/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/pom.xml @@ -0,0 +1,45 @@ + + + + + + org.apache.skywalking + optional-plugins + 6.6.0-SNAPSHOT + + 4.0.0 + + apm-armeria-0.85.x-plugin + armeria-0.85.x-plugin + jar + SkyWalking Agent Plugin for Armeria 0.85.0 ~ 0.97.0 + + 1.8 + + + + + com.linecorp.armeria + armeria + 0.85.0 + provided + + + \ No newline at end of file diff --git a/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/Armeria085ClientInterceptor.java b/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/Armeria085ClientInterceptor.java new file mode 100644 index 000000000..ab6f47c58 --- /dev/null +++ b/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/Armeria085ClientInterceptor.java @@ -0,0 +1,70 @@ +/* + * 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.armeria; + +import com.linecorp.armeria.client.UserClient; +import com.linecorp.armeria.common.HttpMethod; +import com.linecorp.armeria.common.HttpRequest; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; + +import java.lang.reflect.Method; +import java.net.URI; + +/** + * @author kezhenxu94 + */ +@SuppressWarnings("rawtypes") +public class Armeria085ClientInterceptor extends ArmeriaClientInterceptor { + + @Override + public void beforeMethod( + final EnhancedInstance objInst, + final Method method, + final Object[] allArguments, + final Class[] argumentsTypes, + final MethodInterceptResult result) throws Throwable { + + final UserClient userClient = (UserClient) objInst; + final URI uri = userClient.uri(); + final HttpMethod httpMethod = (HttpMethod) allArguments[1]; + final String path = (String) allArguments[2]; + final Object req = allArguments[5]; + + if (!(req instanceof HttpRequest)) { + return; + } + + beforeMethod(uri, httpMethod, path); + } + + @Override + public Object afterMethod( + final EnhancedInstance objInst, + final Method method, + final Object[] allArguments, + final Class[] argumentsTypes, + final Object ret) { + + Object req = allArguments[5]; + + afterMethod(req); + + return ret; + } +} diff --git a/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/Armeria085ServerInterceptor.java b/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/Armeria085ServerInterceptor.java new file mode 100644 index 000000000..3b6a6ab8b --- /dev/null +++ b/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/Armeria085ServerInterceptor.java @@ -0,0 +1,89 @@ +/* + * 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.armeria; + +import com.linecorp.armeria.common.DefaultHttpRequest; +import com.linecorp.armeria.common.HttpHeaders; +import io.netty.util.AsciiString; +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 java.lang.reflect.Method; + +/** + * @author kezhenxu94 + */ +public class Armeria085ServerInterceptor implements InstanceMethodsAroundInterceptor { + @Override + public void beforeMethod( + final EnhancedInstance objInst, + final Method method, + final Object[] allArguments, + final Class[] argumentsTypes, + final MethodInterceptResult result) throws Throwable { + + DefaultHttpRequest httpRequest = (DefaultHttpRequest) allArguments[1]; + HttpHeaders headers = httpRequest.headers(); + + ContextCarrier carrier = new ContextCarrier(); + for (CarrierItem item = carrier.items(); item.hasNext(); ) { + item = item.next(); + item.setHeadValue(headers.get(AsciiString.of(item.getHeadKey()))); + } + + AbstractSpan entrySpan = ContextManager.createEntrySpan(httpRequest.path(), carrier); + entrySpan.setComponent(ComponentsDefine.ARMERIA); + entrySpan.setLayer(SpanLayer.HTTP); + entrySpan.setPeer(httpRequest.authority()); + Tags.URL.set(entrySpan, httpRequest.path()); + Tags.HTTP.METHOD.set(entrySpan, httpRequest.method().name()); + } + + @Override + public Object afterMethod( + final EnhancedInstance objInst, + final Method method, + final Object[] allArguments, + final Class[] argumentsTypes, + final Object ret) { + if (ContextManager.isActive()) { + ContextManager.stopSpan(); + } + return ret; + } + + @Override + public void handleMethodException( + final EnhancedInstance objInst, + final Method method, + final Object[] allArguments, + final Class[] argumentsTypes, + final Throwable t) { + if (ContextManager.isActive()) { + ContextManager.activeSpan().errorOccurred().log(t); + } + } +} diff --git a/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/Armeria086ClientInterceptor.java b/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/Armeria086ClientInterceptor.java new file mode 100644 index 000000000..464d1dfec --- /dev/null +++ b/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/Armeria086ClientInterceptor.java @@ -0,0 +1,70 @@ +/* + * 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.armeria; + +import java.lang.reflect.Method; +import java.net.URI; + +import com.linecorp.armeria.client.UserClient; +import com.linecorp.armeria.common.HttpMethod; +import com.linecorp.armeria.common.HttpRequest; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult; + +/** + * @author kezhenxu94 + */ +@SuppressWarnings("rawtypes") +public class Armeria086ClientInterceptor extends ArmeriaClientInterceptor { + + @Override + public void beforeMethod( + final EnhancedInstance objInst, + final Method method, + final Object[] allArguments, + final Class[] argumentsTypes, + final MethodInterceptResult result) throws Throwable { + + final UserClient userClient = (UserClient) objInst; + final URI uri = userClient.uri(); + final HttpMethod httpMethod = (HttpMethod) allArguments[2]; + final String path = (String) allArguments[3]; + final Object req = allArguments[6]; + + if (!(req instanceof HttpRequest)) { + return; + } + + beforeMethod(uri, httpMethod, path); + } + + @Override + public Object afterMethod( + final EnhancedInstance objInst, + final Method method, + final Object[] allArguments, + final Class[] argumentsTypes, + final Object ret) { + + Object req = allArguments[6]; + + afterMethod(req); + + return ret; + } +} diff --git a/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/ArmeriaClientInterceptor.java b/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/ArmeriaClientInterceptor.java new file mode 100644 index 000000000..3a7f443e6 --- /dev/null +++ b/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/ArmeriaClientInterceptor.java @@ -0,0 +1,87 @@ +/* + * 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.armeria; + +import java.lang.reflect.Method; +import java.net.URI; + +import com.linecorp.armeria.client.Clients; +import com.linecorp.armeria.common.HttpHeadersBuilder; +import com.linecorp.armeria.common.HttpMethod; +import com.linecorp.armeria.common.HttpRequest; +import com.linecorp.armeria.common.util.SafeCloseable; +import io.netty.util.AsciiString; +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.network.trace.component.ComponentsDefine; + +/** + * @author kezhenxu94 + */ +public abstract class ArmeriaClientInterceptor implements InstanceMethodsAroundInterceptor { + private static final String KEY_SAFE_CLOSEABLE = "SAFE_CLOSEABLE"; + + protected void beforeMethod(final URI uri, final HttpMethod httpMethod, final String path) { + final ContextCarrier contextCarrier = new ContextCarrier(); + final String remotePeer = uri.getHost() + ":" + uri.getPort(); + + final AbstractSpan exitSpan = ContextManager.createExitSpan(path, contextCarrier, remotePeer); + + exitSpan.setComponent(ComponentsDefine.ARMERIA); + exitSpan.setLayer(SpanLayer.HTTP); + Tags.HTTP.METHOD.set(exitSpan, httpMethod.name()); + + ContextManager.getRuntimeContext().put(KEY_SAFE_CLOSEABLE, Clients.withHttpHeaders(headers -> { + HttpHeadersBuilder builder = headers.toBuilder(); + for (CarrierItem item = contextCarrier.items(); item.hasNext(); ) { + item = item.next(); + builder.add(AsciiString.of(item.getHeadKey()), item.getHeadValue()); + } + return builder.build(); + })); + } + + protected void afterMethod(final Object req) { + if (req instanceof HttpRequest && ContextManager.isActive()) { + ContextManager.stopSpan(); + } + + SafeCloseable safeCloseable = ContextManager.getRuntimeContext().get(KEY_SAFE_CLOSEABLE, SafeCloseable.class); + if (safeCloseable != null) { + safeCloseable.close(); + } + } + + @Override + public void handleMethodException( + final EnhancedInstance objInst, + final Method method, + final Object[] allArguments, + final Class[] argumentsTypes, + final Throwable t) { + if (ContextManager.isActive()) { + ContextManager.activeSpan().errorOccurred().log(t); + } + } +} diff --git a/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/define/Armeria085ClientInstrumentation.java b/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/define/Armeria085ClientInstrumentation.java new file mode 100644 index 000000000..73e85cb7b --- /dev/null +++ b/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/define/Armeria085ClientInstrumentation.java @@ -0,0 +1,88 @@ +/* + * 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.armeria.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 net.bytebuddy.matcher.ElementMatchers.takesArgument; +import static net.bytebuddy.matcher.ElementMatchers.takesArguments; +import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName; + +/** + * @author kezhenxu94 + */ +public class Armeria085ClientInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + private static final String ENHANCE_CLASS = "com.linecorp.armeria.client.UserClient"; + private static final String INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.armeria.Armeria085ClientInterceptor"; + + @Override + protected ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); + } + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[0]; + } + + @Override + public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[]{ + new InstanceMethodsInterceptPoint() { + @Override + public ElementMatcher getMethodsMatcher() { + return named("execute") + .and(takesArguments(7)) + .and(takesArgument(0, named("io.netty.channel.EventLoop"))) + .and(takesArgument(1, named("com.linecorp.armeria.common.HttpMethod"))) + .and(takesArgument(2, named("java.lang.String"))) + .and(takesArgument(3, named("java.lang.String"))) + .and(takesArgument(4, named("java.lang.String"))); + } + + @Override + public String getMethodsInterceptor() { + return INTERCEPTOR_CLASS; + } + + @Override + public boolean isOverrideArgs() { + return false; + } + } + }; + } + + /** + * Witness classes that are added since 0.63.0 + * + * @return witness classes + */ + @Override + protected String[] witnessClasses() { + return new String[]{ + "com.linecorp.armeria.common.AbstractHttpHeadersBuilder" + }; + } +} diff --git a/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/define/Armeria085ServerInstrumentation.java b/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/define/Armeria085ServerInstrumentation.java new file mode 100644 index 000000000..62dcceb35 --- /dev/null +++ b/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/define/Armeria085ServerInstrumentation.java @@ -0,0 +1,83 @@ +/* + * 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.armeria.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 net.bytebuddy.matcher.ElementMatchers.takesArgument; +import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName; + +/** + * @author kezhenxu94 + */ +public class Armeria085ServerInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + private static final String ENHANCE_CLASS = "com.linecorp.armeria.server.HttpServerHandler"; + private static final String INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.armeria.Armeria085ServerInterceptor"; + + @Override + protected ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); + } + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[0]; + } + + @Override + public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[]{ + new InstanceMethodsInterceptPoint() { + @Override + public ElementMatcher getMethodsMatcher() { + return named("handleRequest") + .and(takesArgument(0, named("io.netty.channel.ChannelHandlerContext"))) + .and(takesArgument(1, named("com.linecorp.armeria.server.DecodedHttpRequest"))); + } + + @Override + public String getMethodsInterceptor() { + return INTERCEPTOR_CLASS; + } + + @Override + public boolean isOverrideArgs() { + return false; + } + } + }; + } + + /** + * Witness classes that are added since 0.63.0 and removed since 0.85.0 + * + * @return witness classes + */ + @Override + protected String[] witnessClasses() { + return new String[]{ + "com.linecorp.armeria.common.AbstractHttpHeadersBuilder" + }; + } +} diff --git a/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/define/Armeria086ClientInstrumentation.java b/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/define/Armeria086ClientInstrumentation.java new file mode 100644 index 000000000..50a561382 --- /dev/null +++ b/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/armeria/define/Armeria086ClientInstrumentation.java @@ -0,0 +1,89 @@ +/* + * 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.armeria.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 net.bytebuddy.matcher.ElementMatchers.takesArgument; +import static net.bytebuddy.matcher.ElementMatchers.takesArguments; +import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName; + +/** + * @author kezhenxu94 + */ +public class Armeria086ClientInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + private static final String ENHANCE_CLASS = "com.linecorp.armeria.client.UserClient"; + private static final String INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.armeria.Armeria086ClientInterceptor"; + + @Override + protected ClassMatch enhanceClass() { + return byName(ENHANCE_CLASS); + } + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return new ConstructorInterceptPoint[0]; + } + + @Override + public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[]{ + new InstanceMethodsInterceptPoint() { + @Override + public ElementMatcher getMethodsMatcher() { + return named("execute") + .and(takesArguments(8)) + .and(takesArgument(0, named("io.netty.channel.EventLoop"))) + .and(takesArgument(1, named("com.linecorp.armeria.client.Endpoint"))) + .and(takesArgument(2, named("com.linecorp.armeria.common.HttpMethod"))) + .and(takesArgument(3, named("java.lang.String"))) + .and(takesArgument(4, named("java.lang.String"))) + .and(takesArgument(5, named("java.lang.String"))); + } + + @Override + public String getMethodsInterceptor() { + return INTERCEPTOR_CLASS; + } + + @Override + public boolean isOverrideArgs() { + return false; + } + } + }; + } + + /** + * Witness classes that are added since 0.63.0 + * + * @return witness classes + */ + @Override + protected String[] witnessClasses() { + return new String[]{ + "com.linecorp.armeria.common.AbstractHttpHeadersBuilder" + }; + } +} diff --git a/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/resources/skywalking-plugin.def new file mode 100644 index 000000000..2702ca918 --- /dev/null +++ b/apm-sniffer/optional-plugins/armeria-0.85.x-plugin/src/main/resources/skywalking-plugin.def @@ -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. + +armeria-085=org.apache.skywalking.apm.plugin.armeria.define.Armeria085ServerInstrumentation +armeria-085=org.apache.skywalking.apm.plugin.armeria.define.Armeria085ClientInstrumentation +armeria-086=org.apache.skywalking.apm.plugin.armeria.define.Armeria086ClientInstrumentation \ No newline at end of file diff --git a/apm-sniffer/optional-plugins/pom.xml b/apm-sniffer/optional-plugins/pom.xml index 6df7ad0c7..c038cc46b 100644 --- a/apm-sniffer/optional-plugins/pom.xml +++ b/apm-sniffer/optional-plugins/pom.xml @@ -48,6 +48,7 @@ zookeeper-3.4.x-plugin customize-enhance-plugin play-2.x-plugin + armeria-0.85.x-plugin 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 35c9f3f90..19ccd8373 100644 --- a/docs/en/setup/service-agent/java-agent/Supported-list.md +++ b/docs/en/setup/service-agent/java-agent/Supported-list.md @@ -40,6 +40,7 @@ * [gRPC](https://github.com/grpc/grpc-java) 1.x * [Apache ServiceComb Java Chassis](https://github.com/apache/servicecomb-java-chassis) 0.1 -> 0.5,1.0.x * [SOFARPC](https://github.com/alipay/sofa-rpc) 5.4.0 + * [Armeria](https://github.com/line/armeria) 0.63.0 -> 0.97.0 * MQ * [RocketMQ](https://github.com/apache/rocketmq) 4.x * [Kafka](http://kafka.apache.org) 0.11.0.0 -> 1.0 diff --git a/oap-server/server-bootstrap/src/main/resources/component-libraries.yml b/oap-server/server-bootstrap/src/main/resources/component-libraries.yml index 1f8f73d84..90e1d6598 100755 --- a/oap-server/server-bootstrap/src/main/resources/component-libraries.yml +++ b/oap-server/server-bootstrap/src/main/resources/component-libraries.yml @@ -263,6 +263,9 @@ rest-high-level-client: spring-tx: id: 78 languages: Java +Armeria: + id: 79 + languages: Java # .NET/.NET Core components # [3000, 4000) for C#/.NET only diff --git a/oap-server/server-core/src/test/resources/component-libraries.yml b/oap-server/server-core/src/test/resources/component-libraries.yml index fe1aa1f62..b8db4457d 100755 --- a/oap-server/server-core/src/test/resources/component-libraries.yml +++ b/oap-server/server-core/src/test/resources/component-libraries.yml @@ -236,6 +236,9 @@ rest-high-level-client: spring-tx: id: 78 languages: Java +Armeria: + id: 79 + languages: Java # .NET/.NET Core components # [3000, 4000) for C#/.NET only diff --git a/test/plugin/scenarios/armeria-0.96minus-scenario/bin/startup.sh b/test/plugin/scenarios/armeria-0.96minus-scenario/bin/startup.sh new file mode 100644 index 000000000..22aa8dc70 --- /dev/null +++ b/test/plugin/scenarios/armeria-0.96minus-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/armeria-0.96minus-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/armeria-0.96minus-scenario/config/expectedData.yaml b/test/plugin/scenarios/armeria-0.96minus-scenario/config/expectedData.yaml new file mode 100644 index 000000000..bb987fd55 --- /dev/null +++ b/test/plugin/scenarios/armeria-0.96minus-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. + + +registryItems: + applications: + - {'armeria-0.96minus-scenario': 2} + instances: + - {'armeria-0.96minus-scenario': 1} + operationNames: + - 'armeria-0.96minus-scenario': [/greet/skywalking] + heartbeat: [] +segmentItems: + - applicationCode: armeria-0.96minus-scenario + segmentSize: ge 2 + segments: + - segmentId: not null + spans: + - operationName: /greet/skywalking + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 79 + componentName: '' + isError: false + spanType: Entry + peer: 127.0.0.1:8085 + peerId: 0 + tags: + - {key: url, value: /greet/skywalking} + - {key: http.method, value: GET} + refs: + - {parentEndpointId: 0, parentEndpoint: /greet/skywalking, networkAddressId: 0, + entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, + parentServiceInstanceId: 1, networkAddress: '127.0.0.1:8085', entryEndpoint: /greet/skywalking, + entryServiceInstanceId: 1} + - segmentId: not null + spans: + - operationName: /greet/skywalking + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 79 + componentName: '' + isError: false + spanType: Exit + peer: 127.0.0.1:8085 + peerId: 0 + tags: + - {key: http.method, value: GET} + - operationName: /greet/skywalking + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 1 + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/greet/skywalking'} + - {key: http.method, value: GET} \ No newline at end of file diff --git a/test/plugin/scenarios/armeria-0.96minus-scenario/configuration.yml b/test/plugin/scenarios/armeria-0.96minus-scenario/configuration.yml new file mode 100644 index 000000000..052d76942 --- /dev/null +++ b/test/plugin/scenarios/armeria-0.96minus-scenario/configuration.yml @@ -0,0 +1,23 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: jvm +entryService: http://localhost:8080/greet/skywalking +healthCheck: http://localhost:8080/healthCheck +runningMode: with_optional +withPlugins: apm-armeria*.jar +startScript: ./bin/startup.sh +framework: Armeria diff --git a/test/plugin/scenarios/armeria-0.96minus-scenario/pom.xml b/test/plugin/scenarios/armeria-0.96minus-scenario/pom.xml new file mode 100644 index 000000000..b8c6767f2 --- /dev/null +++ b/test/plugin/scenarios/armeria-0.96minus-scenario/pom.xml @@ -0,0 +1,97 @@ + + + + 4.0.0 + + org.apache.skywalking + armeria-0.8.x-scenario + 5.0.0 + + + UTF-8 + 1.8 + 2.1.6.RELEASE + + armeria + 0.90.0 + + + skywalking-armeria-scenario + + + + org.springframework.boot + spring-boot-starter-web + ${spring.boot.version} + + + + com.linecorp.armeria + armeria + ${test.framework.version} + + + + + armeria-0.96minus-scenario + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + + + repackage + + + + + + maven-compiler-plugin + 3.8.1 + + ${compiler.version} + ${compiler.version} + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-assembly-plugin + + + assemble + package + + single + + + + src/main/assembly/assembly.xml + + ./target/ + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/armeria-0.96minus-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/armeria-0.96minus-scenario/src/main/assembly/assembly.xml new file mode 100644 index 000000000..58751569c --- /dev/null +++ b/test/plugin/scenarios/armeria-0.96minus-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ./target/armeria-0.96minus-scenario.jar + ./libs + 0775 + + + \ No newline at end of file diff --git a/test/plugin/scenarios/armeria-0.96minus-scenario/src/main/java/org/apache/skywalking/apm/testcase/armeria/Application.java b/test/plugin/scenarios/armeria-0.96minus-scenario/src/main/java/org/apache/skywalking/apm/testcase/armeria/Application.java new file mode 100644 index 000000000..0dbf7f818 --- /dev/null +++ b/test/plugin/scenarios/armeria-0.96minus-scenario/src/main/java/org/apache/skywalking/apm/testcase/armeria/Application.java @@ -0,0 +1,31 @@ +/* + * 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.armeria; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @author kezhenxu94 + */ +@SpringBootApplication +public class Application { + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/test/plugin/scenarios/armeria-0.96minus-scenario/src/main/java/org/apache/skywalking/apm/testcase/armeria/ClientApplication.java b/test/plugin/scenarios/armeria-0.96minus-scenario/src/main/java/org/apache/skywalking/apm/testcase/armeria/ClientApplication.java new file mode 100644 index 000000000..90b9f89bc --- /dev/null +++ b/test/plugin/scenarios/armeria-0.96minus-scenario/src/main/java/org/apache/skywalking/apm/testcase/armeria/ClientApplication.java @@ -0,0 +1,44 @@ +/* + * 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.armeria; + +import java.nio.charset.StandardCharsets; + +import com.linecorp.armeria.client.HttpClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author kezhenxu94 + */ +@RestController +public class ClientApplication { + + private HttpClient httpClient = HttpClient.of("http://127.0.0.1:8085/"); + + @GetMapping("/healthCheck") + public String healthCheck() { + return httpClient.get("/healthCheck").aggregate().join().content().toString(StandardCharsets.UTF_8); + } + + @GetMapping("/greet/{username}") + public String greet(@PathVariable String username) { + return httpClient.get("/greet/" + username).aggregate().join().content().toString(StandardCharsets.UTF_8); + } +} diff --git a/test/plugin/scenarios/armeria-0.96minus-scenario/src/main/java/org/apache/skywalking/apm/testcase/armeria/ServerApplication.java b/test/plugin/scenarios/armeria-0.96minus-scenario/src/main/java/org/apache/skywalking/apm/testcase/armeria/ServerApplication.java new file mode 100644 index 000000000..2c97c5453 --- /dev/null +++ b/test/plugin/scenarios/armeria-0.96minus-scenario/src/main/java/org/apache/skywalking/apm/testcase/armeria/ServerApplication.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.testcase.armeria; + +import javax.annotation.PostConstruct; +import java.util.concurrent.CompletableFuture; + +import com.linecorp.armeria.common.HttpResponse; +import com.linecorp.armeria.server.Server; +import com.linecorp.armeria.server.ServerBuilder; +import org.springframework.stereotype.Component; + +/** + * @author kezhenxu94 + */ +@Component +public class ServerApplication { + private static final String SUCCESS = "Success"; + + @PostConstruct + public void init() { + ServerBuilder sb = + new ServerBuilder() + .http(8085) + .service("/healthCheck", (ctx, res) -> HttpResponse.of(SUCCESS)) + .service("/greet/{name}", (ctx, res) -> HttpResponse.of("Hello %s~", ctx.pathParam("name"))); + + Server server = sb.build(); + CompletableFuture future = server.start(); + future.join(); + } +} diff --git a/test/plugin/scenarios/armeria-0.96minus-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/armeria-0.96minus-scenario/src/main/resources/application.yaml new file mode 100644 index 000000000..6ff39eb8e --- /dev/null +++ b/test/plugin/scenarios/armeria-0.96minus-scenario/src/main/resources/application.yaml @@ -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. + +server: + port: 8080 + diff --git a/test/plugin/scenarios/armeria-0.96minus-scenario/support-version.list b/test/plugin/scenarios/armeria-0.96minus-scenario/support-version.list new file mode 100644 index 000000000..d7ff782f5 --- /dev/null +++ b/test/plugin/scenarios/armeria-0.96minus-scenario/support-version.list @@ -0,0 +1,36 @@ +# 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. + +0.95.0 +0.94.0 +0.93.0 +0.91.0 +0.90.3 +0.90.2 +0.90.1 +0.90.0 +0.89.1 +0.89.0 +0.88.0 +0.87.0 +0.86.0 +0.85.0 +0.84.0 +0.80.0 +0.79.0 +0.70.0 +0.69.0 +0.63.0 diff --git a/test/plugin/scenarios/armeria-0.96plus-scenario/bin/startup.sh b/test/plugin/scenarios/armeria-0.96plus-scenario/bin/startup.sh new file mode 100644 index 000000000..a1037b41c --- /dev/null +++ b/test/plugin/scenarios/armeria-0.96plus-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/armeria-0.96plus-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/armeria-0.96plus-scenario/config/expectedData.yaml b/test/plugin/scenarios/armeria-0.96plus-scenario/config/expectedData.yaml new file mode 100644 index 000000000..56c7be3bc --- /dev/null +++ b/test/plugin/scenarios/armeria-0.96plus-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. + + +registryItems: + applications: + - {'armeria-0.96plus-scenario': 2} + instances: + - {'armeria-0.96plus-scenario': 1} + operationNames: + - 'armeria-0.96plus-scenario': [/greet/skywalking] + heartbeat: [] +segmentItems: + - applicationCode: armeria-0.96plus-scenario + segmentSize: ge 2 + segments: + - segmentId: not null + spans: + - operationName: /greet/skywalking + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 79 + componentName: '' + isError: false + spanType: Entry + peer: 127.0.0.1:8085 + peerId: 0 + tags: + - {key: url, value: /greet/skywalking} + - {key: http.method, value: GET} + refs: + - {parentEndpointId: 0, parentEndpoint: /greet/skywalking, networkAddressId: 0, + entryEndpointId: 0, refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, + parentServiceInstanceId: 1, networkAddress: '127.0.0.1:8085', entryEndpoint: /greet/skywalking, + entryServiceInstanceId: 1} + - segmentId: not null + spans: + - operationName: /greet/skywalking + operationId: 0 + parentSpanId: 0 + spanId: 1 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 79 + componentName: '' + isError: false + spanType: Exit + peer: 127.0.0.1:8085 + peerId: 0 + tags: + - {key: http.method, value: GET} + - operationName: /greet/skywalking + operationId: 0 + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 1 + componentName: '' + isError: false + spanType: Entry + peer: '' + peerId: 0 + tags: + - {key: url, value: 'http://localhost:8080/greet/skywalking'} + - {key: http.method, value: GET} \ No newline at end of file diff --git a/test/plugin/scenarios/armeria-0.96plus-scenario/configuration.yml b/test/plugin/scenarios/armeria-0.96plus-scenario/configuration.yml new file mode 100644 index 000000000..052d76942 --- /dev/null +++ b/test/plugin/scenarios/armeria-0.96plus-scenario/configuration.yml @@ -0,0 +1,23 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +type: jvm +entryService: http://localhost:8080/greet/skywalking +healthCheck: http://localhost:8080/healthCheck +runningMode: with_optional +withPlugins: apm-armeria*.jar +startScript: ./bin/startup.sh +framework: Armeria diff --git a/test/plugin/scenarios/armeria-0.96plus-scenario/pom.xml b/test/plugin/scenarios/armeria-0.96plus-scenario/pom.xml new file mode 100644 index 000000000..fda6fc132 --- /dev/null +++ b/test/plugin/scenarios/armeria-0.96plus-scenario/pom.xml @@ -0,0 +1,98 @@ + + + + 4.0.0 + + org.apache.skywalking + armeria-0.96.x-scenario + 5.0.0 + Armeria test scenarios 0.96.0+ + + + UTF-8 + 1.8 + 2.1.6.RELEASE + + armeria + 0.96.0 + + + skywalking-armeria-scenario + + + + org.springframework.boot + spring-boot-starter-web + ${spring.boot.version} + + + + com.linecorp.armeria + armeria + ${test.framework.version} + + + + + armeria-0.96plus-scenario + + + org.springframework.boot + spring-boot-maven-plugin + ${spring.boot.version} + + + + repackage + + + + + + maven-compiler-plugin + 3.8.1 + + ${compiler.version} + ${compiler.version} + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-assembly-plugin + + + assemble + package + + single + + + + src/main/assembly/assembly.xml + + ./target/ + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/armeria-0.96plus-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/armeria-0.96plus-scenario/src/main/assembly/assembly.xml new file mode 100644 index 000000000..2d75f7339 --- /dev/null +++ b/test/plugin/scenarios/armeria-0.96plus-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ./target/armeria-0.96plus-scenario.jar + ./libs + 0775 + + + \ No newline at end of file diff --git a/test/plugin/scenarios/armeria-0.96plus-scenario/src/main/java/org/apache/skywalking/apm/testcase/armeria/Application.java b/test/plugin/scenarios/armeria-0.96plus-scenario/src/main/java/org/apache/skywalking/apm/testcase/armeria/Application.java new file mode 100644 index 000000000..0dbf7f818 --- /dev/null +++ b/test/plugin/scenarios/armeria-0.96plus-scenario/src/main/java/org/apache/skywalking/apm/testcase/armeria/Application.java @@ -0,0 +1,31 @@ +/* + * 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.armeria; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @author kezhenxu94 + */ +@SpringBootApplication +public class Application { + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/test/plugin/scenarios/armeria-0.96plus-scenario/src/main/java/org/apache/skywalking/apm/testcase/armeria/ClientApplication.java b/test/plugin/scenarios/armeria-0.96plus-scenario/src/main/java/org/apache/skywalking/apm/testcase/armeria/ClientApplication.java new file mode 100644 index 000000000..a88f3b44a --- /dev/null +++ b/test/plugin/scenarios/armeria-0.96plus-scenario/src/main/java/org/apache/skywalking/apm/testcase/armeria/ClientApplication.java @@ -0,0 +1,44 @@ +/* + * 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.armeria; + +import java.nio.charset.StandardCharsets; + +import com.linecorp.armeria.client.WebClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author kezhenxu94 + */ +@RestController +public class ClientApplication { + + private WebClient httpClient = WebClient.of("http://127.0.0.1:8085/"); + + @GetMapping("/healthCheck") + public String healthCheck() { + return httpClient.get("/healthCheck").aggregate().join().content().toString(StandardCharsets.UTF_8); + } + + @GetMapping("/greet/{username}") + public String greet(@PathVariable String username) { + return httpClient.get("/greet/" + username).aggregate().join().content().toString(StandardCharsets.UTF_8); + } +} diff --git a/test/plugin/scenarios/armeria-0.96plus-scenario/src/main/java/org/apache/skywalking/apm/testcase/armeria/ServerApplication.java b/test/plugin/scenarios/armeria-0.96plus-scenario/src/main/java/org/apache/skywalking/apm/testcase/armeria/ServerApplication.java new file mode 100644 index 000000000..2c97c5453 --- /dev/null +++ b/test/plugin/scenarios/armeria-0.96plus-scenario/src/main/java/org/apache/skywalking/apm/testcase/armeria/ServerApplication.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.testcase.armeria; + +import javax.annotation.PostConstruct; +import java.util.concurrent.CompletableFuture; + +import com.linecorp.armeria.common.HttpResponse; +import com.linecorp.armeria.server.Server; +import com.linecorp.armeria.server.ServerBuilder; +import org.springframework.stereotype.Component; + +/** + * @author kezhenxu94 + */ +@Component +public class ServerApplication { + private static final String SUCCESS = "Success"; + + @PostConstruct + public void init() { + ServerBuilder sb = + new ServerBuilder() + .http(8085) + .service("/healthCheck", (ctx, res) -> HttpResponse.of(SUCCESS)) + .service("/greet/{name}", (ctx, res) -> HttpResponse.of("Hello %s~", ctx.pathParam("name"))); + + Server server = sb.build(); + CompletableFuture future = server.start(); + future.join(); + } +} diff --git a/test/plugin/scenarios/armeria-0.96plus-scenario/src/main/resources/application.yaml b/test/plugin/scenarios/armeria-0.96plus-scenario/src/main/resources/application.yaml new file mode 100644 index 000000000..6ff39eb8e --- /dev/null +++ b/test/plugin/scenarios/armeria-0.96plus-scenario/src/main/resources/application.yaml @@ -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. + +server: + port: 8080 + diff --git a/test/plugin/scenarios/armeria-0.96plus-scenario/support-version.list b/test/plugin/scenarios/armeria-0.96plus-scenario/support-version.list new file mode 100644 index 000000000..e0e06bfc9 --- /dev/null +++ b/test/plugin/scenarios/armeria-0.96plus-scenario/support-version.list @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +0.97.0 +0.96.0 diff --git a/test/plugin/scenarios/dubbo-2.5.x-scenario/bin/startup.sh b/test/plugin/scenarios/dubbo-2.5.x-scenario/bin/startup.sh index 3da844653..214b72d1c 100644 --- a/test/plugin/scenarios/dubbo-2.5.x-scenario/bin/startup.sh +++ b/test/plugin/scenarios/dubbo-2.5.x-scenario/bin/startup.sh @@ -18,4 +18,4 @@ home="$(cd "$(dirname $0)"; pwd)" -java -jar ${agent_opts} "-Dskywalking.agent.service_name=dubbo-2.5.x-scenario" ${home}/../libs/dubbo-2.5.x-scenario.jar & \ No newline at end of file +java -jar ${agent_opts} ${home}/../libs/dubbo-2.5.x-scenario.jar & \ No newline at end of file diff --git a/test/plugin/scenarios/dubbo-2.7.x-scenario/bin/startup.sh b/test/plugin/scenarios/dubbo-2.7.x-scenario/bin/startup.sh index f3940038e..7e8e22eba 100644 --- a/test/plugin/scenarios/dubbo-2.7.x-scenario/bin/startup.sh +++ b/test/plugin/scenarios/dubbo-2.7.x-scenario/bin/startup.sh @@ -18,4 +18,4 @@ home="$(cd "$(dirname $0)"; pwd)" -java -jar ${agent_opts} "-Dskywalking.agent.service_name=dubbo-2.7.x-scenario" ${home}/../libs/dubbo-2.7.x-scenario.jar & \ No newline at end of file +java -jar ${agent_opts} ${home}/../libs/dubbo-2.7.x-scenario.jar & \ No newline at end of file