diff --git a/.github/workflows/plugins-test.3.yaml b/.github/workflows/plugins-test.3.yaml
index a5781788f..e26c10857 100644
--- a/.github/workflows/plugins-test.3.yaml
+++ b/.github/workflows/plugins-test.3.yaml
@@ -63,6 +63,7 @@ jobs:
- spring-4.1.x-scenario
- spring-4.3.x-scenario
- spring-async-scenario
+ - vertx-core-4.x-scenario
- vertx-eventbus-3.x-scenario
- vertx-web-3.54minus-scenario
- vertx-web-3.6plus-scenario
diff --git a/CHANGES.md b/CHANGES.md
index 6e7639cbf..44d13b5f2 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -17,6 +17,7 @@ Release Notes.
* Ignore the synthetic constructor created by the agent in the Spring patch plugin.
* Add witness class for vertx-core-3.x plugin.
* Add witness class for graphql plugin.
+* Add vertx-core-4.x plugin.
#### Documentation
* Add link about java agent injector.
diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/pom.xml b/apm-sniffer/apm-sdk-plugin/vertx-plugins/pom.xml
index 8070ce6ce..8680bf9c4 100644
--- a/apm-sniffer/apm-sdk-plugin/vertx-plugins/pom.xml
+++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/pom.xml
@@ -28,6 +28,7 @@
vertx-plugins
+ vertx-core-4.x-plugin
vertx-core-3.x-plugin
pom
diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-4.x-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-4.x-plugin/pom.xml
new file mode 100644
index 000000000..344330c3f
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-4.x-plugin/pom.xml
@@ -0,0 +1,45 @@
+
+
+
+
+ vertx-plugins
+ org.apache.skywalking
+ 8.10.0-SNAPSHOT
+
+ 4.0.0
+
+ apm-vertx-core-4.x-plugin
+ jar
+
+ vertx-core-4.x-plugin
+ http://maven.apache.org
+
+
+ 4.2.5
+
+
+
+
+ io.vertx
+ vertx-core
+ ${vertx.version}
+ provided
+
+
+
diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx4/ClusteredMessageConstructorInterceptor.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx4/ClusteredMessageConstructorInterceptor.java
new file mode 100644
index 000000000..c9177fe7f
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx4/ClusteredMessageConstructorInterceptor.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.plugin.vertx4;
+
+import io.vertx.core.eventbus.impl.clustered.ClusteredEventBus;
+import io.vertx.core.spi.cluster.NodeInfo;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
+
+import java.lang.reflect.Field;
+
+public class ClusteredMessageConstructorInterceptor implements InstanceConstructorInterceptor {
+
+ @Override
+ public void onConstruct(EnhancedInstance objInst, Object[] allArguments) throws Exception {
+ for (Object arg : allArguments) {
+ if (arg instanceof ClusteredEventBus) {
+ Field nodeInfoField = ClusteredEventBus.class.getDeclaredField("nodeInfo");
+ nodeInfoField.setAccessible(true);
+ NodeInfo nodeInfo = (NodeInfo) nodeInfoField.get(arg);
+
+ objInst.setSkyWalkingDynamicField(nodeInfo.host() + ":" + nodeInfo.port());
+ break;
+ }
+ }
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx4/SWVertxTracer.java b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx4/SWVertxTracer.java
new file mode 100644
index 000000000..aeb782a3e
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/vertx-plugins/vertx-core-4.x-plugin/src/main/java/org/apache/skywalking/apm/plugin/vertx4/SWVertxTracer.java
@@ -0,0 +1,203 @@
+/*
+ * 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.vertx4;
+
+import io.vertx.core.Context;
+import io.vertx.core.eventbus.Message;
+import io.vertx.core.eventbus.impl.clustered.ClusteredMessage;
+import io.vertx.core.impl.ContextInternal;
+import io.vertx.core.spi.observability.HttpRequest;
+import io.vertx.core.spi.observability.HttpResponse;
+import io.vertx.core.spi.tracing.SpanKind;
+import io.vertx.core.spi.tracing.TagExtractor;
+import io.vertx.core.spi.tracing.VertxTracer;
+import io.vertx.core.tracing.TracingPolicy;
+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.ContextSnapshot;
+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.network.trace.component.ComponentsDefine;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.function.BiConsumer;
+
+public class SWVertxTracer implements VertxTracer {
+
+ @Override
+ public AbstractSpan receiveRequest(Context context, SpanKind kind, TracingPolicy policy, R request,
+ String operation, Iterable> headers,
+ TagExtractor tagExtractor) {
+ if (TracingPolicy.IGNORE.equals(policy)) {
+ return null;
+ }
+
+ if (request instanceof HttpRequest) {
+ HttpRequest serverRequest = (HttpRequest) request;
+
+ ContextCarrier contextCarrier = getContextCarrier(headers);
+ AbstractSpan span = toEntrySpan(
+ String.join(":", serverRequest.method().name(), serverRequest.uri()),
+ contextCarrier,
+ context
+ );
+ SpanLayer.asHttp(span);
+ Tags.HTTP.METHOD.set(span, serverRequest.method().toString());
+ Tags.URL.set(span, serverRequest.absoluteURI());
+
+ return toAsyncSpan(context, span, false);
+ } else if (request instanceof Message) {
+ Message serverRequest = (Message) request;
+
+ ContextCarrier contextCarrier = getContextCarrier(headers);
+ AbstractSpan span = toEntrySpan(serverRequest.address(), contextCarrier, context);
+ SpanLayer.asRPCFramework(span);
+
+ return toAsyncSpan(context, span, false);
+ }
+
+ return null;
+ }
+
+ @Override
+ public void sendResponse(Context context, R response, AbstractSpan payload, Throwable failure,
+ TagExtractor tagExtractor) {
+ if (payload != null) {
+ if (failure != null) {
+ payload.log(failure);
+ }
+
+ if (response instanceof HttpResponse) {
+ Tags.HTTP_RESPONSE_STATUS_CODE.set(payload, ((HttpResponse) response).statusCode());
+ }
+ payload.asyncFinish();
+ }
+ }
+
+ @Override
+ public AbstractSpan sendRequest(Context context, SpanKind kind, TracingPolicy policy, R request,
+ String operation, BiConsumer headers,
+ TagExtractor tagExtractor) {
+ if (TracingPolicy.IGNORE.equals(policy) || request == null) {
+ return null;
+ }
+
+ if (request instanceof HttpRequest) {
+ HttpRequest clientRequest = (HttpRequest) request;
+
+ ContextCarrier contextCarrier = new ContextCarrier();
+ AbstractSpan span = toExitSpan(
+ clientRequest.uri(),
+ clientRequest.remoteAddress().host() + ":" + clientRequest.remoteAddress().port(),
+ contextCarrier,
+ context
+ );
+ SpanLayer.asHttp(span);
+ Tags.HTTP.METHOD.set(span, clientRequest.method().name());
+ Tags.URL.set(span, clientRequest.absoluteURI());
+
+ return toExitAsyncSpan(context, headers, contextCarrier, span);
+ } else if (request instanceof Message) {
+ Message clientRequest = (Message) request;
+
+ String remotePeer = "localhost";
+ if (clientRequest instanceof ClusteredMessage) {
+ EnhancedInstance enhancedInstance = (EnhancedInstance) clientRequest;
+ if (enhancedInstance.getSkyWalkingDynamicField() != null) {
+ remotePeer = (String) enhancedInstance.getSkyWalkingDynamicField();
+ }
+ }
+ ContextCarrier contextCarrier = new ContextCarrier();
+ AbstractSpan span = toExitSpan(clientRequest.address(), remotePeer, contextCarrier, context);
+ SpanLayer.asRPCFramework(span);
+
+ return toExitAsyncSpan(context, headers, contextCarrier, span);
+ }
+ return null;
+ }
+
+ @Override
+ public void receiveResponse(Context context, R response, AbstractSpan payload, Throwable failure,
+ TagExtractor tagExtractor) {
+ this.sendResponse(context, response, payload, failure, tagExtractor);
+ }
+
+ private void continueContextIfNecessary(Context context) {
+ //Context.getLocal(String) changes to Context.getLocal(Object) from 4.0.x to 4.1.x, so direct access local map
+ Map