diff --git a/.github/workflows/plugins-jdk17-test.0.yaml b/.github/workflows/plugins-jdk17-test.0.yaml index 092fa2daae..6052ee5566 100644 --- a/.github/workflows/plugins-jdk17-test.0.yaml +++ b/.github/workflows/plugins-jdk17-test.0.yaml @@ -80,6 +80,7 @@ jobs: - jetty-11.x-scenario - jetty-10.x-scenario - spring-ai-1.x-scenario + - spring-rabbitmq-3.x-4.x-scenario steps: - uses: actions/checkout@v2 with: diff --git a/.github/workflows/plugins-test.3.yaml b/.github/workflows/plugins-test.3.yaml index 3d5880fd9f..b365fb56c6 100644 --- a/.github/workflows/plugins-test.3.yaml +++ b/.github/workflows/plugins-test.3.yaml @@ -96,6 +96,7 @@ jobs: - spring-kafka-1.3.x-scenario - spring-kafka-2.2.x-scenario - spring-kafka-2.3.x-scenario + - spring-rabbitmq-2.x-scenario - spring-scheduled-3.x-5.x-scenario - elasticjob-2.x-scenario - quartz-scheduler-2.x-scenario diff --git a/CHANGES.md b/CHANGES.md index 27e5c01fde..87fb6e5362 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ Release Notes. * Added support for Lettuce reactive Redis commands. * Add Spring AI 1.x plugin and GenAI layer. +* Add Spring RabbitMQ plugin. All issues and pull requests are [here](https://github.com/apache/skywalking/milestone/249?closed=1) diff --git a/apm-sniffer/apm-sdk-plugin/rabbitmq-plugin/src/main/java/org/apache/skywalking/apm/plugin/rabbitmq/RabbitMQConsumerInterceptor.java b/apm-sniffer/apm-sdk-plugin/rabbitmq-plugin/src/main/java/org/apache/skywalking/apm/plugin/rabbitmq/RabbitMQConsumerInterceptor.java index 50240c9729..e80a0dfd1b 100644 --- a/apm-sniffer/apm-sdk-plugin/rabbitmq-plugin/src/main/java/org/apache/skywalking/apm/plugin/rabbitmq/RabbitMQConsumerInterceptor.java +++ b/apm-sniffer/apm-sdk-plugin/rabbitmq-plugin/src/main/java/org/apache/skywalking/apm/plugin/rabbitmq/RabbitMQConsumerInterceptor.java @@ -29,6 +29,9 @@ public class RabbitMQConsumerInterceptor implements InstanceMethodsAroundInterce @Override public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, MethodInterceptResult result) throws Throwable { + if (Thread.currentThread().getName().toLowerCase().contains("springframework")) { + return; + } Consumer consumer = (Consumer) allArguments[6]; allArguments[6] = new TracerConsumer(consumer, (String) objInst.getSkyWalkingDynamicField()); } diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml b/apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml index 5a307810b3..4326ec7354 100644 --- a/apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml @@ -46,10 +46,11 @@ spring-webflux-6.x-webclient-plugin resttemplate-commons spring-ai-1.x-plugin + spring-rabbitmq-plugin pom - apm-sdk-plugin + spring-plugins http://maven.apache.org diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-rabbitmq-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-rabbitmq-plugin/pom.xml new file mode 100644 index 0000000000..452fc79893 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-rabbitmq-plugin/pom.xml @@ -0,0 +1,46 @@ + + + + 4.0.0 + + + org.apache.skywalking + spring-plugins + 9.7.0-SNAPSHOT + + + apm-spring-rabbitmq-plugin + apm-spring-rabbitmq-plugin + jar + + + 2.2.1.RELEASE + + + + + org.springframework.amqp + spring-rabbit + ${spring-rabbit.version} + provided + + + \ No newline at end of file diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-rabbitmq-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/rabbitmq/SpringRabbitMQConsumerInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-rabbitmq-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/rabbitmq/SpringRabbitMQConsumerInterceptor.java new file mode 100644 index 0000000000..0333ee554c --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-rabbitmq-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/rabbitmq/SpringRabbitMQConsumerInterceptor.java @@ -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. + * + */ + +package org.apache.skywalking.apm.plugin.spring.rabbitmq; + +import java.lang.reflect.Method; +import java.util.Map; + +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.springframework.amqp.core.Message; +import org.springframework.amqp.core.MessageProperties; + +import com.rabbitmq.client.Channel; +import com.rabbitmq.client.Connection; + +public class SpringRabbitMQConsumerInterceptor implements InstanceMethodsAroundInterceptor { + public static final String OPERATE_NAME_PREFIX = "RabbitMQ/"; + public static final String CONSUMER_OPERATE_NAME_SUFFIX = "/Consumer"; + + @Override + public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class[] argumentsTypes, + MethodInterceptResult result) throws Throwable { + Channel channel = (Channel) allArguments[0]; + Message message = (Message) allArguments[1]; + MessageProperties messageProperties = message.getMessageProperties(); + Map headers = messageProperties.getHeaders(); + ContextCarrier contextCarrier = new ContextCarrier(); + CarrierItem next = contextCarrier.items(); + while (next.hasNext()) { + next = next.next(); + Object value = headers.get(next.getHeadKey()); + if (value != null) { + next.setHeadValue(value.toString()); + } + } + String operationName = OPERATE_NAME_PREFIX + "Topic/" + messageProperties.getReceivedExchange() + + "Queue/" + messageProperties.getReceivedRoutingKey() + CONSUMER_OPERATE_NAME_SUFFIX; + AbstractSpan activeSpan = ContextManager.createEntrySpan(operationName, contextCarrier); + Connection connection = channel.getConnection(); + String serverUrl = connection.getAddress().getHostAddress() + ":" + connection.getPort(); + Tags.MQ_BROKER.set(activeSpan, serverUrl); + Tags.MQ_TOPIC.set(activeSpan, messageProperties.getReceivedExchange()); + Tags.MQ_QUEUE.set(activeSpan, messageProperties.getReceivedRoutingKey()); + activeSpan.setComponent(ComponentsDefine.RABBITMQ_CONSUMER); + activeSpan.setPeer(serverUrl); + SpanLayer.asMQ(activeSpan); + } + + @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); + } +} diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-rabbitmq-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/rabbitmq/define/SpringRabbitMQConsumerInstrumentation.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-rabbitmq-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/rabbitmq/define/SpringRabbitMQConsumerInstrumentation.java new file mode 100644 index 0000000000..d01c8cf328 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-rabbitmq-plugin/src/main/java/org/apache/skywalking/apm/plugin/spring/rabbitmq/define/SpringRabbitMQConsumerInstrumentation.java @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.plugin.spring.rabbitmq.define; + +import static net.bytebuddy.matcher.ElementMatchers.named; + +import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.DeclaredInstanceMethodsInterceptPoint; +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 net.bytebuddy.description.method.MethodDescription; +import net.bytebuddy.matcher.ElementMatcher; + +public class SpringRabbitMQConsumerInstrumentation extends ClassInstanceMethodsEnhancePluginDefine { + public static final String ENHANCE_CLASS = "org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer"; + public static final String ENHANCE_METHOD = "executeListener"; + public static final String INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.spring.rabbitmq.SpringRabbitMQConsumerInterceptor"; + + @Override + public ConstructorInterceptPoint[] getConstructorsInterceptPoints() { + return null; + } + + @Override + public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() { + return new InstanceMethodsInterceptPoint[] { + new DeclaredInstanceMethodsInterceptPoint() { + @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/spring-plugins/spring-rabbitmq-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-rabbitmq-plugin/src/main/resources/skywalking-plugin.def new file mode 100644 index 0000000000..94d87de414 --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-rabbitmq-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. + +spring-rabbitmq=org.apache.skywalking.apm.plugin.spring.rabbitmq.define.SpringRabbitMQConsumerInstrumentation \ No newline at end of file diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-rabbitmq-plugin/src/test/java/org/apache/skywalking/apm/plugin/spring/rabbitmq/RabbitMQSpringConsumerInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-rabbitmq-plugin/src/test/java/org/apache/skywalking/apm/plugin/spring/rabbitmq/RabbitMQSpringConsumerInterceptorTest.java new file mode 100644 index 0000000000..308f97f54f --- /dev/null +++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/spring-rabbitmq-plugin/src/test/java/org/apache/skywalking/apm/plugin/spring/rabbitmq/RabbitMQSpringConsumerInterceptorTest.java @@ -0,0 +1,111 @@ +/* + * 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.spring.rabbitmq; + +import static org.hamcrest.CoreMatchers.is; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.net.InetAddress; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.skywalking.apm.agent.core.context.SW8CarrierItem; +import org.apache.skywalking.apm.agent.core.context.trace.TraceSegment; +import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance; +import org.apache.skywalking.apm.agent.test.tools.AgentServiceRule; +import org.apache.skywalking.apm.agent.test.tools.SegmentStorage; +import org.apache.skywalking.apm.agent.test.tools.SegmentStoragePoint; +import org.apache.skywalking.apm.agent.test.tools.TracingSegmentRunner; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.springframework.amqp.core.Message; +import org.springframework.amqp.core.MessageProperties; + +import com.rabbitmq.client.Channel; +import com.rabbitmq.client.Connection; + +@RunWith(TracingSegmentRunner.class) +public class RabbitMQSpringConsumerInterceptorTest { + + @SegmentStoragePoint + private SegmentStorage segmentStorage; + + private SpringRabbitMQConsumerInterceptor rabbitMQConsumerInterceptor; + + @Mock + private EnhancedInstance enhancedInstance; + + @Rule + public AgentServiceRule serviceRule = new AgentServiceRule(); + + @Before + public void setUp() throws Exception { + rabbitMQConsumerInterceptor = new SpringRabbitMQConsumerInterceptor(); + } + + @Test + public void testRabbitMQConsumerInterceptorWithNilHeaders() throws Throwable { + Object[] args = prepareMockData(false); + rabbitMQConsumerInterceptor.beforeMethod(enhancedInstance, null, args, new Class[0], null); + rabbitMQConsumerInterceptor.afterMethod(enhancedInstance, null, args, new Class[0], null); + List traceSegments = segmentStorage.getTraceSegments(); + Assert.assertThat(traceSegments.size(), is(1)); + } + + @Test + public void testRabbitMQConsumerInterceptor() throws Throwable { + Object[] args = prepareMockData(true); + rabbitMQConsumerInterceptor.beforeMethod(enhancedInstance, null, args, new Class[0], null); + rabbitMQConsumerInterceptor.afterMethod(enhancedInstance, null, args, new Class[0], null); + List traceSegments = segmentStorage.getTraceSegments(); + Assert.assertThat(traceSegments.size(), is(1)); + } + + private Object[] prepareMockData(boolean withHeaders) throws Exception { + Channel channel = mock(Channel.class); + Connection connection = mock(Connection.class); + InetAddress address = mock(InetAddress.class); + Message message = mock(Message.class); + MessageProperties messageProperties = mock(MessageProperties.class); + + when(channel.getConnection()).thenReturn(connection); + when(connection.getAddress()).thenReturn(address); + when(address.getHostAddress()).thenReturn("127.0.0.1"); + when(connection.getPort()).thenReturn(5672); + when(message.getMessageProperties()).thenReturn(messageProperties); + when(messageProperties.getReceivedExchange()).thenReturn("test-exchange"); + when(messageProperties.getReceivedRoutingKey()).thenReturn("test-routing-key"); + + if (withHeaders) { + Map headers = new HashMap<>(); + headers.put(SW8CarrierItem.HEADER_NAME, + "1-My40LjU=-MS4yLjM=-3-c2VydmljZQ==-aW5zdGFuY2U=-L2FwcA==-MTI3LjAuMC4xOjgwODA="); + when(messageProperties.getHeader(SW8CarrierItem.HEADER_NAME)) + .thenReturn(headers.get(SW8CarrierItem.HEADER_NAME)); + } + + return new Object[] {channel, message}; + } +} 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 49d1cb9c8e..3764ae9716 100644 --- a/docs/en/setup/service-agent/java-agent/Plugin-list.md +++ b/docs/en/setup/service-agent/java-agent/Plugin-list.md @@ -114,6 +114,7 @@ - spring-core-patch - spring-kafka-1.x - spring-kafka-2.x +- spring-rabbitmq - spring-mvc-annotation - spring-mvc-annotation-3.x - spring-mvc-annotation-4.x diff --git a/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/bin/startup.sh b/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/bin/startup.sh new file mode 100644 index 0000000000..5a75b66754 --- /dev/null +++ b/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/bin/startup.sh @@ -0,0 +1,20 @@ +#!/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 -Dspring.rabbitmq.host=${RABBITMQ_HOST:-rabbitmq-server} -jar ${agent_opts} ${home}/../libs/spring-rabbitmq-2.x-scenario.jar & diff --git a/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/config/expectedData.yaml new file mode 100644 index 0000000000..fee535115f --- /dev/null +++ b/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/config/expectedData.yaml @@ -0,0 +1,73 @@ +# 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: spring-rabbitmq-2.x-scenario + segmentSize: gt 2 + segments: + - segmentId: not null + spans: + - operationName: GET:/spring-rabbitmq-2.x-scenario/case/rabbitmq + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 1 + isError: false + spanType: Entry + peer: '' + tags: + - {key: url, value: 'http://localhost:8080/spring-rabbitmq-2.x-scenario/case/rabbitmq'} + - {key: http.method, value: GET} + - {key: http.status_code, value: '200'} + skipAnalysis: 'false' + - operationName: RabbitMQ/Topic/Queue/test/Producer + parentSpanId: 0 + spanId: 1 + spanLayer: MQ + startTime: nq 0 + endTime: nq 0 + componentId: 52 + isError: false + spanType: Exit + peer: not blank + tags: + - {key: mq.broker, value: not blank} + - {key: mq.queue, value: test} + - {key: mq.topic, value: ''} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: RabbitMQ/Topic/Queue/test/Consumer + parentSpanId: -1 + spanId: 0 + spanLayer: MQ + startTime: nq 0 + endTime: nq 0 + componentId: 53 + isError: false + spanType: Entry + peer: not blank + tags: + - {key: transmission.latency, value: ge 0} + - {key: mq.broker, value: not blank} + - {key: mq.topic, value: ''} + - {key: mq.queue, value: test} + refs: + - {parentEndpoint: GET:/spring-rabbitmq-2.x-scenario/case/rabbitmq, networkAddress: not null, + refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: spring-rabbitmq-2.x-scenario, traceId: not null} + skipAnalysis: 'false' diff --git a/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/configuration.yml b/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/configuration.yml new file mode 100644 index 0000000000..a14199f3c3 --- /dev/null +++ b/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/configuration.yml @@ -0,0 +1,33 @@ +# 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/spring-rabbitmq-2.x-scenario/case/rabbitmq +healthCheck: http://localhost:8080/spring-rabbitmq-2.x-scenario/case/healthcheck +startScript: ./bin/startup.sh +environment: + - RABBITMQ_HOST=rabbitmq-server +depends_on: + - rabbitmq-server +dependencies: + rabbitmq-server: + image: rabbitmq:3.8.18 + hostname: rabbitmq-server + expose: + - 5672 + - 15672 + environment: + - RABBITMQ_DEFAULT_PASS=admin + - RABBITMQ_DEFAULT_USER=admin + - RABBITMQ_DEFAULT_VHOST=/ diff --git a/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/pom.xml b/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/pom.xml new file mode 100644 index 0000000000..1e2c7e913b --- /dev/null +++ b/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/pom.xml @@ -0,0 +1,117 @@ + + + + 4.0.0 + + org.apache.skywalking + spring-rabbitmq-2.x-scenario + 1.0-SNAPSHOT + + + UTF-8 + 1.8 + 3.8.1 + 1.5.0.RELEASE + ${test.framework.version} + 2.8.1 + + + + + org.springframework.boot + spring-boot-starter-amqp + ${test.framework.version} + + + + org.springframework.boot + spring-boot-starter + ${test.framework.version} + + + spring-boot-starter-logging + org.springframework.boot + + + + + org.springframework.boot + spring-boot-starter-web + ${test.framework.version} + + + org.apache.logging.log4j + log4j-api + ${log4j.version} + + + org.apache.logging.log4j + log4j-core + ${log4j.version} + + + + + spring-rabbitmq-2.x-scenario + + + org.springframework.boot + spring-boot-maven-plugin + ${test.framework.version} + + + + repackage + + + + + + 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 + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/src/main/assembly/assembly.xml new file mode 100644 index 0000000000..a4e443d949 --- /dev/null +++ b/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/spring-rabbitmq-2.x-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/rabbitmq/Application.java b/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/rabbitmq/Application.java new file mode 100644 index 0000000000..9001ed22a9 --- /dev/null +++ b/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/rabbitmq/Application.java @@ -0,0 +1,30 @@ +/* + * 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.spring.rabbitmq; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/rabbitmq/config/RabbitMqConfig.java b/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/rabbitmq/config/RabbitMqConfig.java new file mode 100644 index 0000000000..74c401f9e2 --- /dev/null +++ b/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/rabbitmq/config/RabbitMqConfig.java @@ -0,0 +1,32 @@ +/* + * 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.spring.rabbitmq.config; + +import org.springframework.amqp.core.Queue; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class RabbitMqConfig { + + @Bean + public Queue testQueue() { + return new Queue("test", false); + } +} diff --git a/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/rabbitmq/controller/CaseController.java b/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/rabbitmq/controller/CaseController.java new file mode 100644 index 0000000000..ca2a9d800d --- /dev/null +++ b/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/rabbitmq/controller/CaseController.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.spring.rabbitmq.controller; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.amqp.rabbit.annotation.RabbitListener; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/case") +public class CaseController { + + private static final Logger LOGGER = LogManager.getLogger(CaseController.class); + + private static final String QUEUE_NAME = "test"; + + private static final String MESSAGE = "rabbitmq-testcase"; + + @Autowired + private RabbitTemplate rabbitTemplate; + + @RequestMapping("/rabbitmq") + @ResponseBody + public String send() { + LOGGER.info("Message being published -------------->" + MESSAGE); + rabbitTemplate.convertAndSend(QUEUE_NAME, MESSAGE); + LOGGER.info("Message has been published-------------->" + MESSAGE); + return "Success"; + } + + @RabbitListener(queues = QUEUE_NAME) + public void consumer(String message) { + LOGGER.info("Message Consumer received-------------->" + message); + } + + @RequestMapping("/healthcheck") + public String healthCheck() throws Exception { + return "Success"; + } +} diff --git a/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/src/main/resources/application.yml b/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/src/main/resources/application.yml new file mode 100644 index 0000000000..7310f8a17e --- /dev/null +++ b/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/src/main/resources/application.yml @@ -0,0 +1,29 @@ +# +# 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 + servlet: + context-path: /spring-rabbitmq-2.x-scenario + +spring: + rabbitmq: + host: ${RABBITMQ_HOST:127.0.0.1} + port: 5672 + username: admin + password: admin + virtual-host: / diff --git a/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..565fda00e0 --- /dev/null +++ b/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + diff --git a/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/support-version.list b/test/plugin/scenarios/spring-rabbitmq-2.x-scenario/support-version.list new file mode 100644 index 0000000000..5d08d9eb7e --- /dev/null +++ b/test/plugin/scenarios/spring-rabbitmq-2.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. + +2.0.0.RELEASE +2.1.0.RELEASE +2.2.0.RELEASE +2.4.0 \ No newline at end of file diff --git a/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/bin/startup.sh b/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/bin/startup.sh new file mode 100644 index 0000000000..f48486c177 --- /dev/null +++ b/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/bin/startup.sh @@ -0,0 +1,20 @@ +#!/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 -Dspring.rabbitmq.host=${RABBITMQ_HOST:-rabbitmq-server} -jar ${agent_opts} ${home}/../libs/spring-rabbitmq-3.x-4.x-scenario.jar & diff --git a/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/config/expectedData.yaml b/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/config/expectedData.yaml new file mode 100644 index 0000000000..901e8f3d6f --- /dev/null +++ b/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/config/expectedData.yaml @@ -0,0 +1,73 @@ +# 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: spring-rabbitmq-3.x-4.x-scenario + segmentSize: gt 2 + segments: + - segmentId: not null + spans: + - operationName: GET:/spring-rabbitmq-3.x-4.x-scenario/case/rabbitmq + parentSpanId: -1 + spanId: 0 + spanLayer: Http + startTime: nq 0 + endTime: nq 0 + componentId: 1 + isError: false + spanType: Entry + peer: '' + tags: + - {key: url, value: 'http://localhost:8080/spring-rabbitmq-3.x-4.x-scenario/case/rabbitmq'} + - {key: http.method, value: GET} + - {key: http.status_code, value: '200'} + skipAnalysis: 'false' + - operationName: RabbitMQ/Topic/Queue/test/Producer + parentSpanId: 0 + spanId: 1 + spanLayer: MQ + startTime: nq 0 + endTime: nq 0 + componentId: 52 + isError: false + spanType: Exit + peer: not blank + tags: + - {key: mq.broker, value: not blank} + - {key: mq.queue, value: test} + - {key: mq.topic, value: ''} + skipAnalysis: 'false' + - segmentId: not null + spans: + - operationName: RabbitMQ/Topic/Queue/test/Consumer + parentSpanId: -1 + spanId: 0 + spanLayer: MQ + startTime: nq 0 + endTime: nq 0 + componentId: 53 + isError: false + spanType: Entry + peer: not blank + tags: + - {key: transmission.latency, value: ge 0} + - {key: mq.broker, value: not blank} + - {key: mq.topic, value: ''} + - {key: mq.queue, value: test} + refs: + - {parentEndpoint: GET:/spring-rabbitmq-3.x-4.x-scenario/case/rabbitmq, networkAddress: not null, + refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null, parentServiceInstance: not + null, parentService: spring-rabbitmq-3.x-4.x-scenario, traceId: not null} + skipAnalysis: 'false' diff --git a/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/configuration.yml b/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/configuration.yml new file mode 100644 index 0000000000..e19c7a64b5 --- /dev/null +++ b/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/configuration.yml @@ -0,0 +1,33 @@ +# 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/spring-rabbitmq-3.x-4.x-scenario/case/rabbitmq +healthCheck: http://localhost:8080/spring-rabbitmq-3.x-4.x-scenario/case/healthcheck +startScript: ./bin/startup.sh +environment: + - RABBITMQ_HOST=rabbitmq-server +depends_on: + - rabbitmq-server +dependencies: + rabbitmq-server: + image: rabbitmq:3.8.18 + hostname: rabbitmq-server + expose: + - 5672 + - 15672 + environment: + - RABBITMQ_DEFAULT_PASS=admin + - RABBITMQ_DEFAULT_USER=admin + - RABBITMQ_DEFAULT_VHOST=/ diff --git a/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/pom.xml b/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/pom.xml new file mode 100644 index 0000000000..c301b0ada3 --- /dev/null +++ b/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/pom.xml @@ -0,0 +1,117 @@ + + + + 4.0.0 + + org.apache.skywalking + spring-rabbitmq-3.x-4.x-scenario + 1.0-SNAPSHOT + + + UTF-8 + 17 + 3.8.1 + 3.0.0 + ${test.framework.version} + 2.19.0 + + + + + org.springframework.boot + spring-boot-starter-amqp + ${test.framework.version} + + + + org.springframework.boot + spring-boot-starter + ${test.framework.version} + + + spring-boot-starter-logging + org.springframework.boot + + + + + org.springframework.boot + spring-boot-starter-web + ${test.framework.version} + + + org.apache.logging.log4j + log4j-api + ${log4j.version} + + + org.apache.logging.log4j + log4j-core + ${log4j.version} + + + + + spring-rabbitmq-3.x-4.x-scenario + + + org.springframework.boot + spring-boot-maven-plugin + ${test.framework.version} + + + + repackage + + + + + + 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 + + + + + + + + + \ No newline at end of file diff --git a/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/src/main/assembly/assembly.xml new file mode 100644 index 0000000000..e7c504dc07 --- /dev/null +++ b/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/src/main/assembly/assembly.xml @@ -0,0 +1,41 @@ + + + + + zip + + + + + ./bin + 0775 + + + + + + ${project.build.directory}/spring-rabbitmq-3.x-4.x-scenario.jar + ./libs + 0775 + + + diff --git a/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/rabbitmq/Application.java b/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/rabbitmq/Application.java new file mode 100644 index 0000000000..9001ed22a9 --- /dev/null +++ b/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/rabbitmq/Application.java @@ -0,0 +1,30 @@ +/* + * 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.spring.rabbitmq; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } +} diff --git a/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/rabbitmq/config/RabbitMqConfig.java b/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/rabbitmq/config/RabbitMqConfig.java new file mode 100644 index 0000000000..74c401f9e2 --- /dev/null +++ b/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/rabbitmq/config/RabbitMqConfig.java @@ -0,0 +1,32 @@ +/* + * 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.spring.rabbitmq.config; + +import org.springframework.amqp.core.Queue; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class RabbitMqConfig { + + @Bean + public Queue testQueue() { + return new Queue("test", false); + } +} diff --git a/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/rabbitmq/controller/CaseController.java b/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/rabbitmq/controller/CaseController.java new file mode 100644 index 0000000000..ca2a9d800d --- /dev/null +++ b/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/src/main/java/org/apache/skywalking/apm/testcase/spring/rabbitmq/controller/CaseController.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.skywalking.apm.testcase.spring.rabbitmq.controller; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.amqp.rabbit.annotation.RabbitListener; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/case") +public class CaseController { + + private static final Logger LOGGER = LogManager.getLogger(CaseController.class); + + private static final String QUEUE_NAME = "test"; + + private static final String MESSAGE = "rabbitmq-testcase"; + + @Autowired + private RabbitTemplate rabbitTemplate; + + @RequestMapping("/rabbitmq") + @ResponseBody + public String send() { + LOGGER.info("Message being published -------------->" + MESSAGE); + rabbitTemplate.convertAndSend(QUEUE_NAME, MESSAGE); + LOGGER.info("Message has been published-------------->" + MESSAGE); + return "Success"; + } + + @RabbitListener(queues = QUEUE_NAME) + public void consumer(String message) { + LOGGER.info("Message Consumer received-------------->" + message); + } + + @RequestMapping("/healthcheck") + public String healthCheck() throws Exception { + return "Success"; + } +} diff --git a/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/src/main/resources/application.yml b/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/src/main/resources/application.yml new file mode 100644 index 0000000000..95dabedad1 --- /dev/null +++ b/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/src/main/resources/application.yml @@ -0,0 +1,29 @@ +# +# 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 + servlet: + context-path: /spring-rabbitmq-3.x-4.x-scenario + +spring: + rabbitmq: + host: ${RABBITMQ_HOST:127.0.0.1} + port: 5672 + username: admin + password: admin + virtual-host: / diff --git a/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/src/main/resources/log4j2.xml b/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..565fda00e0 --- /dev/null +++ b/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/src/main/resources/log4j2.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + diff --git a/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/support-version.list b/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-scenario/support-version.list new file mode 100644 index 0000000000..8c67d6f4a8 --- /dev/null +++ b/test/plugin/scenarios/spring-rabbitmq-3.x-4.x-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. + +3.0.0 +4.0.0 \ No newline at end of file