You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2022/02/10 12:24:43 UTC
[skywalking-java] branch main updated: Add plugin to support google guava EventBus (#107)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-java.git
The following commit(s) were added to refs/heads/main by this push:
new a48a16b Add plugin to support google guava EventBus (#107)
a48a16b is described below
commit a48a16b6d6c890bfbcce3bbd94d6498bb71a7bd2
Author: wallezhang <do...@gmail.com>
AuthorDate: Thu Feb 10 20:24:17 2022 +0800
Add plugin to support google guava EventBus (#107)
* feat: Add Guava EventBus plugin
* refactor: Remove serviceComb 1.0.0 from the test matric to avoid the influence of guava-event-bus plugin on scenario test results.
---
.github/workflows/plugins-test.3.yaml | 1 +
CHANGES.md | 1 +
.../network/trace/component/ComponentsDefine.java | 2 +
.../apm-sdk-plugin/guava-eventbus-plugin/pom.xml | 44 +++++++++
.../eventbus/EventBusDispatchInterceptor.java | 53 ++++++++++
.../EventBusSubscriberConstructorInterceptor.java | 39 ++++++++
.../eventbus/EventBusSubscriberInterceptor.java | 62 ++++++++++++
.../apm/plugin/guava/eventbus/EventWrapper.java | 50 ++++++++++
.../apm/plugin/guava/eventbus/SubscriberInfo.java | 44 +++++++++
.../define/EventBusDispatcherInstrumentation.java | 72 ++++++++++++++
.../define/EventBusSubscriberInstrumentation.java | 89 +++++++++++++++++
.../src/main/resources/skywalking-plugin.def | 6 +-
.../eventbus/EventBusDispatchInterceptorTest.java | 69 +++++++++++++
...entBusSubscriberConstructorInterceptorTest.java | 68 +++++++++++++
.../EventBusSubscriberInterceptorTest.java | 90 +++++++++++++++++
apm-sniffer/apm-sdk-plugin/pom.xml | 1 +
.../setup/service-agent/java-agent/Plugin-list.md | 1 +
.../service-agent/java-agent/Supported-list.md | 2 +
.../bin/startup.sh} | 12 ++-
.../config/expectedData.yaml | 68 +++++++++++++
.../configuration.yml} | 9 +-
.../scenarios/guava-eventbus-scenario/pom.xml | 107 +++++++++++++++++++++
.../src/main/assembly/assembly.xml | 41 ++++++++
.../apm/testcase/guava/eventbus/Application.java | 30 ++++++
.../guava/eventbus/controller/CaseController.java | 60 ++++++++++++
.../guava/eventbus/service/SubscriberService.java | 51 ++++++++++
.../testcase/guava/eventbus/service/TestEvent.java | 43 +++++++++
.../src/main/resources/application.yml | 21 ++++
.../support-version.list | 9 +-
.../servicecomb-1.x-scenario/support-version.list | 1 -
30 files changed, 1129 insertions(+), 17 deletions(-)
diff --git a/.github/workflows/plugins-test.3.yaml b/.github/workflows/plugins-test.3.yaml
index ed00397..a578178 100644
--- a/.github/workflows/plugins-test.3.yaml
+++ b/.github/workflows/plugins-test.3.yaml
@@ -94,6 +94,7 @@ jobs:
- kylin-jdbc-2.6.x-3.x-4.x-scenario
- undertow-worker-thread-pool-scenario
- tomcat-thread-pool-scenario
+ - guava-eventbus-scenario
steps:
- uses: actions/checkout@v2
with:
diff --git a/CHANGES.md b/CHANGES.md
index ea93f63..d0faa98 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -7,6 +7,7 @@ Release Notes.
* Support Undertow thread pool metrics collecting.
* Support Tomcat thread pool metric collect.
* Remove plugin for ServiceComb Java Chassis 0.x
+* Add Guava EventBus plugin.
#### Documentation
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 d23cf2e..75a8b37 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
@@ -218,4 +218,6 @@ public class ComponentsDefine {
public static final OfficialComponent CLICKHOUSE_JDBC_DRIVER = new OfficialComponent(119, "ClickHouse-jdbc-driver");
public static final OfficialComponent APACHE_KYLIN_JDBC_DRIVER = new OfficialComponent(121, "apache-kylin-jdbc-driver");
+
+ public static final OfficialComponent GUAVA_EVENT_BUS = new OfficialComponent(123, "GuavaEventBus");
}
diff --git a/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/pom.xml
new file mode 100644
index 0000000..40e7f8b
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/pom.xml
@@ -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.
+ ~
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>apm-sdk-plugin</artifactId>
+ <groupId>org.apache.skywalking</groupId>
+ <version>8.10.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>apm-guava-eventbus-plugin</artifactId>
+
+ <properties>
+ <guava.version>31.0.1-jre</guava.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>${guava.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
\ No newline at end of file
diff --git a/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/main/java/org/apache/skywalking/apm/plugin/guava/eventbus/EventBusDispatchInterceptor.java b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/main/java/org/apache/skywalking/apm/plugin/guava/eventbus/EventBusDispatchInterceptor.java
new file mode 100644
index 0000000..34ab37a
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/main/java/org/apache/skywalking/apm/plugin/guava/eventbus/EventBusDispatchInterceptor.java
@@ -0,0 +1,53 @@
+/*
+ * 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.guava.eventbus;
+
+import java.lang.reflect.Method;
+import org.apache.skywalking.apm.agent.core.context.ContextManager;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+
+/**
+ * {@link EventBusDispatchInterceptor} will capture context and create a new wrapper to
+ * hold the original event object.
+ */
+public class EventBusDispatchInterceptor implements InstanceMethodsAroundInterceptor {
+
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+ final Object event = allArguments[0];
+ if (event != null) {
+ allArguments[0] = EventWrapper.wrapEvent(event, ContextManager.capture());
+ }
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
+ Object ret) throws Throwable {
+ return null;
+ }
+
+ @Override
+ public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class<?>[] argumentsTypes, Throwable t) {
+
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/main/java/org/apache/skywalking/apm/plugin/guava/eventbus/EventBusSubscriberConstructorInterceptor.java b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/main/java/org/apache/skywalking/apm/plugin/guava/eventbus/EventBusSubscriberConstructorInterceptor.java
new file mode 100644
index 0000000..fdb8428
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/main/java/org/apache/skywalking/apm/plugin/guava/eventbus/EventBusSubscriberConstructorInterceptor.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.plugin.guava.eventbus;
+
+import java.lang.reflect.Method;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
+
+/**
+ * {@link EventBusSubscriberConstructorInterceptor} will set the target object information from constructor arguments.
+ */
+public class EventBusSubscriberConstructorInterceptor implements InstanceConstructorInterceptor {
+
+ @Override
+ public void onConstruct(EnhancedInstance objInst, Object[] allArguments) throws Throwable {
+ final Object targetObject = allArguments[1];
+ final Method method = (Method) allArguments[2];
+ final SubscriberInfo subscriberInfo = new SubscriberInfo();
+ subscriberInfo.setClassName(targetObject.getClass().getName());
+ subscriberInfo.setMethodName(method.getName());
+ objInst.setSkyWalkingDynamicField(subscriberInfo);
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/main/java/org/apache/skywalking/apm/plugin/guava/eventbus/EventBusSubscriberInterceptor.java b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/main/java/org/apache/skywalking/apm/plugin/guava/eventbus/EventBusSubscriberInterceptor.java
new file mode 100644
index 0000000..0e8f1c5
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/main/java/org/apache/skywalking/apm/plugin/guava/eventbus/EventBusSubscriberInterceptor.java
@@ -0,0 +1,62 @@
+/*
+ * 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.guava.eventbus;
+
+import java.lang.reflect.Method;
+import org.apache.skywalking.apm.agent.core.context.ContextManager;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
+
+/**
+ * {@link EventBusSubscriberInterceptor} will restore the context snapshot and original event object.
+ */
+public class EventBusSubscriberInterceptor implements InstanceMethodsAroundInterceptor {
+
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+ SubscriberInfo subscriberInfo = (SubscriberInfo) objInst.getSkyWalkingDynamicField();
+ final AbstractSpan span = ContextManager.createLocalSpan(
+ "Guava/EventBus/" + subscriberInfo.getClassName() + "/" + subscriberInfo.getMethodName());
+ span.setComponent(ComponentsDefine.GUAVA_EVENT_BUS);
+ Object event = allArguments[0];
+ if (event instanceof EventWrapper) {
+ final EventWrapper eventWrapper = (EventWrapper) event;
+ // restore original event object
+ allArguments[0] = eventWrapper.getEvent();
+ ContextManager.continued(eventWrapper.getContextSnapshot());
+ }
+ }
+
+ @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/guava-eventbus-plugin/src/main/java/org/apache/skywalking/apm/plugin/guava/eventbus/EventWrapper.java b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/main/java/org/apache/skywalking/apm/plugin/guava/eventbus/EventWrapper.java
new file mode 100644
index 0000000..441d438
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/main/java/org/apache/skywalking/apm/plugin/guava/eventbus/EventWrapper.java
@@ -0,0 +1,50 @@
+/*
+ * 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.guava.eventbus;
+
+import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
+
+/**
+ * This class hold the original event object and context snapshot
+ */
+public class EventWrapper {
+
+ /**
+ * Original event object
+ */
+ private final Object event;
+ private final ContextSnapshot contextSnapshot;
+
+ private EventWrapper(Object event, ContextSnapshot contextSnapshot) {
+ this.event = event;
+ this.contextSnapshot = contextSnapshot;
+ }
+
+ public static EventWrapper wrapEvent(Object event, ContextSnapshot contextSnapshot) {
+ return new EventWrapper(event, contextSnapshot);
+ }
+
+ public Object getEvent() {
+ return event;
+ }
+
+ public ContextSnapshot getContextSnapshot() {
+ return contextSnapshot;
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/main/java/org/apache/skywalking/apm/plugin/guava/eventbus/SubscriberInfo.java b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/main/java/org/apache/skywalking/apm/plugin/guava/eventbus/SubscriberInfo.java
new file mode 100644
index 0000000..e105bc2
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/main/java/org/apache/skywalking/apm/plugin/guava/eventbus/SubscriberInfo.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.plugin.guava.eventbus;
+
+/**
+ * This class hold the subscriber class name and method name.
+ */
+public class SubscriberInfo {
+
+ private String className;
+ private String methodName;
+
+ public String getClassName() {
+ return className;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public String getMethodName() {
+ return methodName;
+ }
+
+ public void setMethodName(String methodName) {
+ this.methodName = methodName;
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/main/java/org/apache/skywalking/apm/plugin/guava/eventbus/define/EventBusDispatcherInstrumentation.java b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/main/java/org/apache/skywalking/apm/plugin/guava/eventbus/define/EventBusDispatcherInstrumentation.java
new file mode 100644
index 0000000..6c34e88
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/main/java/org/apache/skywalking/apm/plugin/guava/eventbus/define/EventBusDispatcherInstrumentation.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.plugin.guava.eventbus.define;
+
+import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
+
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import net.bytebuddy.matcher.ElementMatchers;
+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;
+
+/**
+ * {@link EventBusDispatcherInstrumentation} defines method interceptor.
+ */
+public class EventBusDispatcherInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+
+ private static final String ENHANCE_CLASS = "com.google.common.eventbus.Dispatcher$LegacyAsyncDispatcher";
+ private static final String DISPATCH_METHOD_NAME = "dispatch";
+ private static final String DISPATCH_METHOD_INTERCEPTOR = "org.apache.skywalking.apm.plugin.guava.eventbus.EventBusDispatchInterceptor";
+
+ @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<MethodDescription> getMethodsMatcher() {
+ return ElementMatchers.named(DISPATCH_METHOD_NAME)
+ .and(ElementMatchers.takesArgument(0, Object.class));
+ }
+
+ @Override
+ public String getMethodsInterceptor() {
+ return DISPATCH_METHOD_INTERCEPTOR;
+ }
+
+ @Override
+ public boolean isOverrideArgs() {
+ return true;
+ }
+ }
+ };
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/main/java/org/apache/skywalking/apm/plugin/guava/eventbus/define/EventBusSubscriberInstrumentation.java b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/main/java/org/apache/skywalking/apm/plugin/guava/eventbus/define/EventBusSubscriberInstrumentation.java
new file mode 100644
index 0000000..78332d7
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/main/java/org/apache/skywalking/apm/plugin/guava/eventbus/define/EventBusSubscriberInstrumentation.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.guava.eventbus.define;
+
+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;
+
+import java.lang.reflect.Method;
+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;
+
+/**
+ * {@link EventBusSubscriberInstrumentation} define com.google.common.eventbus.Subscriber#invokeSubscriberMethod
+ * method interceptor.
+ */
+public class EventBusSubscriberInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+
+ private final static String ENHANCE_CLASS = "com.google.common.eventbus.Subscriber";
+ private final static String INVOKE_METHOD_NAME = "invokeSubscriberMethod";
+ private final static String INVOKE_METHOD_INTERCEPTOR = "org.apache.skywalking.apm.plugin.guava.eventbus.EventBusSubscriberInterceptor";
+ private final static String CONSTRUCTOR_INTERCEPTOR = "org.apache.skywalking.apm.plugin.guava.eventbus.EventBusSubscriberConstructorInterceptor";
+
+ @Override
+ protected ClassMatch enhanceClass() {
+ return byName(ENHANCE_CLASS);
+ }
+
+ @Override
+ public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[] {
+ new ConstructorInterceptPoint() {
+ @Override
+ public ElementMatcher<MethodDescription> getConstructorMatcher() {
+ return takesArgument(0, named("com.google.common.eventbus.EventBus"))
+ .and(takesArgument(1, Object.class))
+ .and(takesArgument(2, Method.class));
+ }
+
+ @Override
+ public String getConstructorInterceptor() {
+ return CONSTRUCTOR_INTERCEPTOR;
+ }
+ }
+ };
+ }
+
+ @Override
+ public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
+ return new InstanceMethodsInterceptPoint[] {
+ new InstanceMethodsInterceptPoint() {
+ @Override
+ public ElementMatcher<MethodDescription> getMethodsMatcher() {
+ return named(INVOKE_METHOD_NAME).and(takesArgument(0, Object.class));
+ }
+
+ @Override
+ public String getMethodsInterceptor() {
+ return INVOKE_METHOD_INTERCEPTOR;
+ }
+
+ @Override
+ public boolean isOverrideArgs() {
+ return true;
+ }
+ }
+ };
+ }
+}
diff --git a/test/plugin/scenarios/servicecomb-1.x-scenario/support-version.list b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/main/resources/skywalking-plugin.def
similarity index 79%
copy from test/plugin/scenarios/servicecomb-1.x-scenario/support-version.list
copy to apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/main/resources/skywalking-plugin.def
index 38ff728..5e3aa0b 100644
--- a/test/plugin/scenarios/servicecomb-1.x-scenario/support-version.list
+++ b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/main/resources/skywalking-plugin.def
@@ -14,7 +14,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-1.0.0
-1.1.0
-1.2.1
-1.3.0
+guava-eventbus=org.apache.skywalking.apm.plugin.guava.eventbus.define.EventBusDispatcherInstrumentation
+guava-eventbus=org.apache.skywalking.apm.plugin.guava.eventbus.define.EventBusSubscriberInstrumentation
diff --git a/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/test/java/org/apache/skywalking/apm/plugin/guava/eventbus/EventBusDispatchInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/test/java/org/apache/skywalking/apm/plugin/guava/eventbus/EventBusDispatchInterceptorTest.java
new file mode 100644
index 0000000..fe891dd
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/test/java/org/apache/skywalking/apm/plugin/guava/eventbus/EventBusDispatchInterceptorTest.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.guava.eventbus;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.powermock.api.mockito.PowerMockito.mockStatic;
+import static org.powermock.api.mockito.PowerMockito.when;
+
+import org.apache.skywalking.apm.agent.core.context.ContextManager;
+import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(ContextManager.class)
+public class EventBusDispatchInterceptorTest {
+
+ private EventBusDispatchInterceptor interceptor;
+ private Object originalEventObj;
+ @Mock
+ private ContextSnapshot contextSnapshot;
+
+ @Before
+ public void setUp() throws Exception {
+ interceptor = new EventBusDispatchInterceptor();
+ originalEventObj = new Object();
+ mockStatic(ContextManager.class);
+ when(ContextManager.capture()).thenReturn(contextSnapshot);
+ }
+
+ @Test
+ public void test() throws Throwable {
+ Object[] arguments = new Object[] {originalEventObj};
+ interceptor.beforeMethod(null, null, arguments, new Class[1], null);
+ assertEquals(EventWrapper.class, arguments[0].getClass());
+ assertEquals(originalEventObj, ((EventWrapper) arguments[0]).getEvent());
+ assertNotNull(((EventWrapper) arguments[0]).getContextSnapshot());
+ }
+
+ @Test
+ public void testNullEventObject() throws Throwable {
+ Object[] arguments = new Object[1];
+ interceptor.beforeMethod(null, null, arguments, new Class[1], null);
+ assertNull(arguments[0]);
+ }
+
+}
\ No newline at end of file
diff --git a/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/test/java/org/apache/skywalking/apm/plugin/guava/eventbus/EventBusSubscriberConstructorInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/test/java/org/apache/skywalking/apm/plugin/guava/eventbus/EventBusSubscriberConstructorInterceptorTest.java
new file mode 100644
index 0000000..2ac63b8
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/test/java/org/apache/skywalking/apm/plugin/guava/eventbus/EventBusSubscriberConstructorInterceptorTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.guava.eventbus;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.lang.reflect.Method;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+public class EventBusSubscriberConstructorInterceptorTest {
+
+ private EventBusSubscriberConstructorInterceptor interceptor;
+ private EnhancedInstance enhancedInstance;
+
+ @Before
+ public void setUp() throws Exception {
+ interceptor = new EventBusSubscriberConstructorInterceptor();
+ enhancedInstance = new EnhancedInstance() {
+ private Object field;
+
+ @Override
+ public Object getSkyWalkingDynamicField() {
+ return field;
+ }
+
+ @Override
+ public void setSkyWalkingDynamicField(Object value) {
+ field = value;
+ }
+ };
+ }
+
+ @Test
+ public void test() throws Throwable {
+ final Method method = this.getClass().getDeclaredMethod("test");
+ Object[] arguments = new Object[] {null, new Object(), method};
+ interceptor.onConstruct(enhancedInstance, arguments);
+
+ final Object dynamicField = enhancedInstance.getSkyWalkingDynamicField();
+ assertNotNull(dynamicField);
+ assertEquals(SubscriberInfo.class, dynamicField.getClass());
+ SubscriberInfo subscriberInfo = (SubscriberInfo) dynamicField;
+ assertEquals("test", subscriberInfo.getMethodName());
+ assertEquals(Object.class.getName(), subscriberInfo.getClassName());
+ }
+}
\ No newline at end of file
diff --git a/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/test/java/org/apache/skywalking/apm/plugin/guava/eventbus/EventBusSubscriberInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/test/java/org/apache/skywalking/apm/plugin/guava/eventbus/EventBusSubscriberInterceptorTest.java
new file mode 100644
index 0000000..1d6a5ea
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/guava-eventbus-plugin/src/test/java/org/apache/skywalking/apm/plugin/guava/eventbus/EventBusSubscriberInterceptorTest.java
@@ -0,0 +1,90 @@
+/*
+ * 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.guava.eventbus;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+import org.apache.skywalking.apm.agent.core.context.MockContextSnapshot;
+import org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan;
+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.helper.SegmentHelper;
+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.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.modules.junit4.PowerMockRunnerDelegate;
+
+@RunWith(PowerMockRunner.class)
+@PowerMockRunnerDelegate(TracingSegmentRunner.class)
+public class EventBusSubscriberInterceptorTest {
+
+ @Rule
+ public AgentServiceRule serviceRule = new AgentServiceRule();
+ private EventBusSubscriberInterceptor interceptor;
+ @SegmentStoragePoint
+ private SegmentStorage segmentStorage;
+ private EventWrapper eventWrapper;
+ private EnhancedInstance enhancedInstance;
+ private SubscriberInfo subscriberInfo;
+
+ @Before
+ public void setUp() throws Exception {
+ interceptor = new EventBusSubscriberInterceptor();
+ eventWrapper = EventWrapper.wrapEvent(new Object(), MockContextSnapshot.INSTANCE.mockContextSnapshot());
+ enhancedInstance = new EnhancedInstance() {
+ private Object value;
+
+ @Override
+ public Object getSkyWalkingDynamicField() {
+ return value;
+ }
+
+ @Override
+ public void setSkyWalkingDynamicField(Object value) {
+ this.value = value;
+ }
+ };
+ subscriberInfo = new SubscriberInfo();
+ subscriberInfo.setMethodName("testMethodName");
+ subscriberInfo.setClassName("testClassName");
+ }
+
+ @Test
+ public void test() throws Throwable {
+ Object[] arguments = new Object[] {eventWrapper};
+ enhancedInstance.setSkyWalkingDynamicField(subscriberInfo);
+ interceptor.beforeMethod(enhancedInstance, null, arguments, new Class[1], null);
+ interceptor.afterMethod(null, null, null, null, null);
+
+ assertThat(segmentStorage.getTraceSegments().size(), is(1));
+ final TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
+ List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
+ assertThat(spans, notNullValue());
+ assertThat(spans.size(), is(1));
+ }
+}
\ 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 0bbb4c6..1a445f4 100644
--- a/apm-sniffer/apm-sdk-plugin/pom.xml
+++ b/apm-sniffer/apm-sdk-plugin/pom.xml
@@ -119,6 +119,7 @@
<module>pulsar-2.8.x-plugin</module>
<module>undertow-worker-thread-pool-plugin</module>
<module>tomcat-thread-pool-plugin</module>
+ <module>guava-eventbus-plugin</module>
</modules>
<packaging>pom</packaging>
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 7f79257..6b535ca 100644
--- a/docs/en/setup/service-agent/java-agent/Plugin-list.md
+++ b/docs/en/setup/service-agent/java-agent/Plugin-list.md
@@ -131,3 +131,4 @@
- pulsar-2.8.x
- undertow-worker-thread-pool
- tomcat-thread-pool
+- guava-eventbus
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 c47085f..98e8edf 100644
--- a/docs/en/setup/service-agent/java-agent/Supported-list.md
+++ b/docs/en/setup/service-agent/java-agent/Supported-list.md
@@ -135,6 +135,8 @@ metrics based on the tracing data.
* [logback](https://github.com/qos-ch/logback) 1.2.x
* ORM
* [MyBatis](https://github.com/mybatis/mybatis-3) 3.4.x -> 3.5.x
+* Event
+ * [GuavaEventBus](https://github.com/google/guava) 19.x -> 31.x-jre
# Meter Plugins
The meter plugin provides the advanced metrics collections, which are not a part of tracing.
diff --git a/test/plugin/scenarios/servicecomb-1.x-scenario/support-version.list b/test/plugin/scenarios/guava-eventbus-scenario/bin/startup.sh
similarity index 86%
copy from test/plugin/scenarios/servicecomb-1.x-scenario/support-version.list
copy to test/plugin/scenarios/guava-eventbus-scenario/bin/startup.sh
index 38ff728..efcab12 100644
--- a/test/plugin/scenarios/servicecomb-1.x-scenario/support-version.list
+++ b/test/plugin/scenarios/guava-eventbus-scenario/bin/startup.sh
@@ -1,3 +1,5 @@
+#!/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
@@ -14,7 +16,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-1.0.0
-1.1.0
-1.2.1
-1.3.0
+home="$(
+ cd "$(dirname $0)"
+ pwd
+)"
+
+java -jar ${agent_opts} ${home}/../libs/guava-eventbus-scenario.jar &
diff --git a/test/plugin/scenarios/guava-eventbus-scenario/config/expectedData.yaml b/test/plugin/scenarios/guava-eventbus-scenario/config/expectedData.yaml
new file mode 100644
index 0000000..f96603f
--- /dev/null
+++ b/test/plugin/scenarios/guava-eventbus-scenario/config/expectedData.yaml
@@ -0,0 +1,68 @@
+# 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: guava-eventbus-scenario
+ segmentSize: ge 2
+ segments:
+ - segmentId: not null
+ spans:
+ - operationName: Guava/EventBus/org.apache.skywalking.apm.testcase.guava.eventbus.service.SubscriberService/consumer
+ operationId: 0
+ parentSpanId: 0
+ spanId: 1
+ spanLayer: Unknown
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 123
+ isError: false
+ spanType: Local
+ peer: ''
+ skipAnalysis: false
+ - operationName: GET:/guava-eventbus-scenario/case/guava-scenario
+ operationId: 0
+ parentSpanId: -1
+ spanId: 0
+ spanLayer: Http
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 1
+ isError: false
+ spanType: Entry
+ peer: ''
+ skipAnalysis: false
+ tags:
+ - {key: url, value: 'http://localhost:8080/guava-eventbus-scenario/case/guava-scenario'}
+ - {key: http.method, value: GET}
+ - segmentId: not null
+ spans:
+ - operationName: Guava/EventBus/org.apache.skywalking.apm.testcase.guava.eventbus.service.SubscriberService/consumer
+ operationId: 0
+ parentSpanId: -1
+ spanId: 0
+ spanLayer: Unknown
+ startTime: nq 0
+ endTime: nq 0
+ componentId: 123
+ isError: false
+ spanType: Local
+ peer: ''
+ skipAnalysis: false
+ refs:
+ - { parentEndpoint: 'GET:/guava-eventbus-scenario/case/guava-scenario', networkAddress: '',
+ refType: CrossThread, parentSpanId: 0, parentTraceSegmentId: not null,
+ parentServiceInstance: not null, parentService: guava-eventbus-scenario,
+ traceId: not null }
+meterItems: []
\ No newline at end of file
diff --git a/test/plugin/scenarios/servicecomb-1.x-scenario/support-version.list b/test/plugin/scenarios/guava-eventbus-scenario/configuration.yml
similarity index 78%
copy from test/plugin/scenarios/servicecomb-1.x-scenario/support-version.list
copy to test/plugin/scenarios/guava-eventbus-scenario/configuration.yml
index 38ff728..67717ee 100644
--- a/test/plugin/scenarios/servicecomb-1.x-scenario/support-version.list
+++ b/test/plugin/scenarios/guava-eventbus-scenario/configuration.yml
@@ -14,7 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-1.0.0
-1.1.0
-1.2.1
-1.3.0
+type: jvm
+entryService: http://localhost:8080/guava-eventbus-scenario/case/guava-scenario
+healthCheck: http://localhost:8080/guava-eventbus-scenario/case/healthCheck
+startScript: ./bin/startup.sh
+environment:
diff --git a/test/plugin/scenarios/guava-eventbus-scenario/pom.xml b/test/plugin/scenarios/guava-eventbus-scenario/pom.xml
new file mode 100644
index 0000000..86a05c2
--- /dev/null
+++ b/test/plugin/scenarios/guava-eventbus-scenario/pom.xml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ ~
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.skywalking.apm.testcase</groupId>
+ <artifactId>guava-eventbus-scenario</artifactId>
+ <version>1.0.0</version>
+ <packaging>jar</packaging>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <compiler.version>1.8</compiler.version>
+ <test.framework>guava</test.framework>
+ <test.framework.version>19.0</test.framework.version>
+ <spring.boot.version>2.5.1</spring.boot.version>
+ </properties>
+
+ <name>skywalking-guava-eventbus-scenario</name>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-dependencies</artifactId>
+ <version>${spring.boot.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>${test.framework.version}</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <finalName>guava-eventbus-scenario</finalName>
+ <plugins>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <version>${spring.boot.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>${compiler.version}</source>
+ <target>${compiler.version}</target>
+ <encoding>${project.build.sourceEncoding}</encoding>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>assemble</id>
+ <phase>package</phase>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <configuration>
+ <descriptors>
+ <descriptor>src/main/assembly/assembly.xml</descriptor>
+ </descriptors>
+ <outputDirectory>./target/</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git a/test/plugin/scenarios/guava-eventbus-scenario/src/main/assembly/assembly.xml b/test/plugin/scenarios/guava-eventbus-scenario/src/main/assembly/assembly.xml
new file mode 100644
index 0000000..a4e9bbc
--- /dev/null
+++ b/test/plugin/scenarios/guava-eventbus-scenario/src/main/assembly/assembly.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ ~
+ -->
+<assembly
+ xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
+ <formats>
+ <format>zip</format>
+ </formats>
+
+ <fileSets>
+ <fileSet>
+ <directory>./bin</directory>
+ <fileMode>0775</fileMode>
+ </fileSet>
+ </fileSets>
+
+ <files>
+ <file>
+ <source>${project.build.directory}/guava-eventbus-scenario.jar</source>
+ <outputDirectory>./libs</outputDirectory>
+ <fileMode>0775</fileMode>
+ </file>
+ </files>
+</assembly>
diff --git a/test/plugin/scenarios/guava-eventbus-scenario/src/main/java/org/apache/skywalking/apm/testcase/guava/eventbus/Application.java b/test/plugin/scenarios/guava-eventbus-scenario/src/main/java/org/apache/skywalking/apm/testcase/guava/eventbus/Application.java
new file mode 100644
index 0000000..822fc03
--- /dev/null
+++ b/test/plugin/scenarios/guava-eventbus-scenario/src/main/java/org/apache/skywalking/apm/testcase/guava/eventbus/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.guava.eventbus;
+
+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/guava-eventbus-scenario/src/main/java/org/apache/skywalking/apm/testcase/guava/eventbus/controller/CaseController.java b/test/plugin/scenarios/guava-eventbus-scenario/src/main/java/org/apache/skywalking/apm/testcase/guava/eventbus/controller/CaseController.java
new file mode 100644
index 0000000..adee578
--- /dev/null
+++ b/test/plugin/scenarios/guava-eventbus-scenario/src/main/java/org/apache/skywalking/apm/testcase/guava/eventbus/controller/CaseController.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.testcase.guava.eventbus.controller;
+
+import com.google.common.eventbus.AsyncEventBus;
+import com.google.common.eventbus.EventBus;
+import java.util.concurrent.Executors;
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import org.apache.skywalking.apm.testcase.guava.eventbus.service.SubscriberService;
+import org.apache.skywalking.apm.testcase.guava.eventbus.service.TestEvent;
+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 {
+
+ public static final String SUCCESS = "Success";
+ private final EventBus eventBus = new EventBus();
+ private final AsyncEventBus asyncEventBus = new AsyncEventBus(Executors.newFixedThreadPool(5));
+ @Resource
+ private SubscriberService subscriberService;
+
+ @RequestMapping("/guava-scenario")
+ @ResponseBody
+ public void testcase(HttpServletRequest request) throws Exception {
+ eventBus.register(subscriberService);
+ asyncEventBus.register(subscriberService);
+ final TestEvent testEvent = new TestEvent();
+ testEvent.setContent("test");
+ eventBus.post(testEvent);
+ testEvent.setAsyncContext(request.startAsync());
+ asyncEventBus.post(testEvent);
+ }
+
+ @RequestMapping("/healthCheck")
+ @ResponseBody
+ public String healthCheck() throws Exception {
+ return SUCCESS;
+ }
+
+}
diff --git a/test/plugin/scenarios/guava-eventbus-scenario/src/main/java/org/apache/skywalking/apm/testcase/guava/eventbus/service/SubscriberService.java b/test/plugin/scenarios/guava-eventbus-scenario/src/main/java/org/apache/skywalking/apm/testcase/guava/eventbus/service/SubscriberService.java
new file mode 100644
index 0000000..74f5024
--- /dev/null
+++ b/test/plugin/scenarios/guava-eventbus-scenario/src/main/java/org/apache/skywalking/apm/testcase/guava/eventbus/service/SubscriberService.java
@@ -0,0 +1,51 @@
+/*
+ * 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.guava.eventbus.service;
+
+import com.google.common.eventbus.Subscribe;
+import java.io.IOException;
+import java.io.PrintWriter;
+import javax.servlet.AsyncContext;
+import org.apache.skywalking.apm.testcase.guava.eventbus.controller.CaseController;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+@Service
+public class SubscriberService {
+
+ private final Logger logger = LoggerFactory.getLogger(SubscriberService.class);
+
+ @Subscribe
+ public void consumer(TestEvent event) {
+ logger.info("Consume event content: {}", event.getContent());
+ final AsyncContext asyncContext = event.getAsyncContext();
+ if (asyncContext != null) {
+ try {
+ final PrintWriter writer = asyncContext.getResponse().getWriter();
+ writer.write(CaseController.SUCCESS);
+ writer.flush();
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ asyncContext.complete();
+ }
+ }
+ }
+}
diff --git a/test/plugin/scenarios/guava-eventbus-scenario/src/main/java/org/apache/skywalking/apm/testcase/guava/eventbus/service/TestEvent.java b/test/plugin/scenarios/guava-eventbus-scenario/src/main/java/org/apache/skywalking/apm/testcase/guava/eventbus/service/TestEvent.java
new file mode 100644
index 0000000..d6ddefc
--- /dev/null
+++ b/test/plugin/scenarios/guava-eventbus-scenario/src/main/java/org/apache/skywalking/apm/testcase/guava/eventbus/service/TestEvent.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.testcase.guava.eventbus.service;
+
+import javax.servlet.AsyncContext;
+
+public class TestEvent {
+
+ private String content;
+ private AsyncContext asyncContext;
+
+ public AsyncContext getAsyncContext() {
+ return asyncContext;
+ }
+
+ public void setAsyncContext(AsyncContext asyncContext) {
+ this.asyncContext = asyncContext;
+ }
+
+ public String getContent() {
+ return content;
+ }
+
+ public void setContent(String content) {
+ this.content = content;
+ }
+}
diff --git a/test/plugin/scenarios/guava-eventbus-scenario/src/main/resources/application.yml b/test/plugin/scenarios/guava-eventbus-scenario/src/main/resources/application.yml
new file mode 100644
index 0000000..4120101
--- /dev/null
+++ b/test/plugin/scenarios/guava-eventbus-scenario/src/main/resources/application.yml
@@ -0,0 +1,21 @@
+#
+# 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: /guava-eventbus-scenario
\ No newline at end of file
diff --git a/test/plugin/scenarios/servicecomb-1.x-scenario/support-version.list b/test/plugin/scenarios/guava-eventbus-scenario/support-version.list
similarity index 95%
copy from test/plugin/scenarios/servicecomb-1.x-scenario/support-version.list
copy to test/plugin/scenarios/guava-eventbus-scenario/support-version.list
index 38ff728..43d53a4 100644
--- a/test/plugin/scenarios/servicecomb-1.x-scenario/support-version.list
+++ b/test/plugin/scenarios/guava-eventbus-scenario/support-version.list
@@ -14,7 +14,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-1.0.0
-1.1.0
-1.2.1
-1.3.0
+19.0
+23.0
+24.0-jre
+27.0-jre
+31.0-jre
\ No newline at end of file
diff --git a/test/plugin/scenarios/servicecomb-1.x-scenario/support-version.list b/test/plugin/scenarios/servicecomb-1.x-scenario/support-version.list
index 38ff728..8ddde05 100644
--- a/test/plugin/scenarios/servicecomb-1.x-scenario/support-version.list
+++ b/test/plugin/scenarios/servicecomb-1.x-scenario/support-version.list
@@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-1.0.0
1.1.0
1.2.1
1.3.0