Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
858f057
Merge pull request #1 from apache/async-context
BFergerson Mar 15, 2019
2a46de8
vertx core impl
BFergerson Mar 18, 2019
4dcfc5d
wording
BFergerson Mar 18, 2019
ae1e4af
add exception interceptors
BFergerson Mar 20, 2019
0a6203d
author comment
BFergerson Mar 20, 2019
6677533
moved to vertx-plugins/vert-core
BFergerson Mar 20, 2019
daf7f6b
don't need
BFergerson Mar 20, 2019
4b238bc
add vertx core to supported
BFergerson Mar 20, 2019
10013cd
Merge branch 'master' into master
BFergerson Mar 20, 2019
b971c20
add license
BFergerson Mar 20, 2019
08cba6e
Merge remote-tracking branch 'origin/master'
BFergerson Mar 20, 2019
a2d78ab
Merge branch 'master' into master
BFergerson Mar 22, 2019
b767200
support for clustered event bus
BFergerson Mar 23, 2019
684b125
Merge remote-tracking branch 'origin/master'
BFergerson Mar 23, 2019
8b7319b
close on conditional
BFergerson Mar 23, 2019
77ee5ff
make local spans on local messages
BFergerson Mar 23, 2019
80e0a3d
stored at reply address
BFergerson Mar 23, 2019
1abad75
Merge branch 'master' into master
BFergerson Mar 23, 2019
0c78a52
Merge branch 'master' into master
BFergerson Mar 26, 2019
452d93a
Merge branch 'master' of https://github.com/BFergerson/incubator-skyw…
BFergerson Mar 26, 2019
f4c216c
finish vertx clustered eventbus work
BFergerson Mar 27, 2019
19361c6
forgot to set span layer
BFergerson Mar 27, 2019
14b6ced
set span layer and component
BFergerson Mar 27, 2019
7ab10ed
Merge branch 'master' into master
BFergerson Mar 27, 2019
e8e3b42
continue context after async
BFergerson Mar 27, 2019
0fcf909
Merge remote-tracking branch 'origin/master'
BFergerson Mar 27, 2019
fc85164
testing
BFergerson Mar 27, 2019
1ae279d
Merge branch 'master' into master
BFergerson Mar 28, 2019
d01a16d
Merge remote-tracking branch 'origin/master'
BFergerson Mar 28, 2019
dcccd50
set http method/uri on exit/entry spans
BFergerson Mar 28, 2019
4e48c0c
raw method is null
BFergerson Mar 28, 2019
3033840
seems safer
BFergerson Mar 28, 2019
9331bf7
Merge branch 'master' into master
BFergerson Apr 1, 2019
71d24e3
Merge branch 'master' into master
wu-sheng Apr 4, 2019
ea2b957
Merge branch 'master' into master
wu-sheng Apr 4, 2019
7366e6d
Merge branch 'master' into master
BFergerson Apr 8, 2019
9dd7636
Merge branch 'master' into master
wu-sheng Apr 11, 2019
4fbd337
test
BFergerson Apr 12, 2019
dc4c698
correct
BFergerson Apr 12, 2019
14c22ae
fix
BFergerson Apr 12, 2019
1b1ad17
npe fix
BFergerson Apr 12, 2019
7f55b53
test
BFergerson Apr 12, 2019
953d9d0
test
BFergerson Apr 13, 2019
13798dd
test
BFergerson Apr 13, 2019
d99e83e
Merge pull request #3 from BFergerson/vertx-test
BFergerson Apr 13, 2019
d24a75c
Merge branch 'master' into master
BFergerson Apr 13, 2019
9ecfd18
non-absolute URIs
BFergerson Apr 13, 2019
2905389
Merge pull request #4 from BFergerson/vertx-test
BFergerson Apr 13, 2019
9febb25
witness classes + 3.2 support
BFergerson Apr 14, 2019
3971079
use impl
BFergerson Apr 14, 2019
352c22f
no path() in 3.2
BFergerson Apr 14, 2019
0375d44
correct exit span peer
BFergerson Apr 14, 2019
fbdbee0
use RuntimeContext
BFergerson Apr 14, 2019
f21242c
duh
BFergerson Apr 15, 2019
279b723
duh (cont.)
BFergerson Apr 15, 2019
380ea39
ugh (aka duh)
BFergerson Apr 15, 2019
87402f5
fixes
BFergerson Apr 15, 2019
8a98b9e
rename
BFergerson Apr 15, 2019
682d441
Merge pull request #5 from BFergerson/3.2-test
BFergerson Apr 15, 2019
797ba9b
Merge branch 'master' into master
wu-sheng Apr 15, 2019
5b29ee6
update supported versions
BFergerson Apr 15, 2019
97685eb
Merge branch 'master' into master
wu-sheng Apr 15, 2019
6f666c8
Merge branch 'master' into master
BFergerson Apr 15, 2019
a0e61e1
fix comment
BFergerson Apr 15, 2019
c609e91
Merge remote-tracking branch 'origin/master'
BFergerson Apr 15, 2019
3538534
Merge branch 'master' into master
wu-sheng Apr 15, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ public class ComponentsDefine {

public static final OfficialComponent ZOOKEEPER = new OfficialComponent(58, "Zookeeper");

public static final OfficialComponent VERTX = new OfficialComponent(59, "Vert.x");

private static ComponentsDefine INSTANCE = new ComponentsDefine();

private String[] components;
Expand All @@ -123,7 +125,7 @@ public static ComponentsDefine getInstance() {
}

public ComponentsDefine() {
components = new String[59];
components = new String[60];
addComponent(TOMCAT);
addComponent(HTTPCLIENT);
addComponent(DUBBO);
Expand Down Expand Up @@ -167,6 +169,7 @@ public ComponentsDefine() {
addComponent(REDISSON);
addComponent(LETTUCE);
addComponent(ZOOKEEPER);
addComponent(VERTX);
}

private void addComponent(OfficialComponent component) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public interface AbstractSpan extends AsyncSpan {
AbstractSpan setComponent(Component component);

/**
* Only use this method in explicit instrumentation, like opentracing-skywalking-bridge. It it higher recommend
* don't use this for performance consideration.
* Only use this method in explicit instrumentation, like opentracing-skywalking-bridge. It is highly recommended
* not to use this method for performance reasons.
*
* @param componentName
* @return the span for chaining.
Expand Down Expand Up @@ -127,7 +127,7 @@ public interface AbstractSpan extends AsyncSpan {
*/
void ref(TraceSegmentRef ref);

AbstractSpan start(long starttime);
AbstractSpan start(long startTime);

AbstractSpan setPeer(String remotePeer);
}
1 change: 1 addition & 0 deletions apm-sniffer/apm-sdk-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<module>canal-1.x-plugin</module>
<module>dubbo-2.7.x-plugin</module>
<module>dubbo-2.7.x-conflict-patch</module>
<module>vertx-plugins</module>
</modules>
<packaging>pom</packaging>

Expand Down
43 changes: 43 additions & 0 deletions apm-sniffer/apm-sdk-plugin/vertx-plugins/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?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>

<parent>
<groupId>org.apache.skywalking</groupId>
<artifactId>apm-sdk-plugin</artifactId>
<version>6.1.0-SNAPSHOT</version>
</parent>

<artifactId>vertx-plugins</artifactId>
<modules>
<module>vertx-core-3.x-plugin</module>
</modules>
<packaging>pom</packaging>

<name>vertx-plugins</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<sdk.plugin.related.dir>/..</sdk.plugin.related.dir>
</properties>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<!--
~ 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>vertx-plugins</artifactId>
<groupId>org.apache.skywalking</groupId>
<version>6.1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>apm-vertx-core-3.x-plugin</artifactId>
<packaging>jar</packaging>

<name>vertx-core-3.x-plugin</name>
<url>http://maven.apache.org</url>

<properties>
<vertx.version>3.6.3</vertx.version>
</properties>

<dependencies>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
<version>${vertx.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.skywalking.apm.plugin.vertx3;

import io.vertx.core.eventbus.impl.clustered.ClusteredMessage;
import io.vertx.core.net.impl.ServerID;
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.trace.AbstractSpan;
import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;

import java.lang.reflect.Method;

public class ClusteredEventBusSendRemoteInterceptor implements InstanceMethodsAroundInterceptor {

@Override
@SuppressWarnings("unchecked")
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
ContextManager.getRuntimeContext().remove(VertxContext.STOP_SPAN_NECESSARY + "." + getClass().getName());

ClusteredMessage message = (ClusteredMessage) allArguments[1];
if (VertxContext.hasContext(message.address())) {
VertxContext context = VertxContext.popContext(message.address());
context.getSpan().asyncFinish();
} else {
ServerID sender = (ServerID) allArguments[0];
ContextCarrier contextCarrier = new ContextCarrier();
AbstractSpan span = ContextManager.createExitSpan(message.address(), contextCarrier, sender.toString());
span.setComponent(ComponentsDefine.VERTX);
SpanLayer.asRPCFramework(span);

CarrierItem next = contextCarrier.items();
while (next.hasNext()) {
next = next.next();
message.headers().add(next.getHeadKey(), next.getHeadValue());
}

if (message.replyAddress() != null) {
VertxContext.pushContext(message.replyAddress(),
new VertxContext(ContextManager.capture(), span.prepareForAsync()));
}
ContextManager.getRuntimeContext().put(VertxContext.STOP_SPAN_NECESSARY + "." + getClass().getName(), true);
}
}

@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
Object ret) throws Throwable {
Boolean closeSpan = (Boolean) ContextManager.getRuntimeContext().get(
VertxContext.STOP_SPAN_NECESSARY + "." + getClass().getName());
if (Boolean.TRUE.equals(closeSpan)) {
ContextManager.stopSpan();
}
return ret;
}

@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
Class<?>[] argumentsTypes, Throwable t) {
ContextManager.activeSpan().errorOccurred().log(t);
}
}
Original file line number Diff line number Diff line change
@@ -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.vertx3;

import io.vertx.core.eventbus.Message;
import io.vertx.core.eventbus.impl.clustered.ClusteredMessage;
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.context.trace.SpanLayer;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;

import java.lang.reflect.Method;

/**
* @author brandon.fergerson
*/
public class EventBusImplDeliverToHandlerInterceptor implements InstanceMethodsAroundInterceptor {

@Override
@SuppressWarnings("unchecked")
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
ContextManager.getRuntimeContext().remove(VertxContext.STOP_SPAN_NECESSARY + "." + getClass().getName());

Message message = (Message) allArguments[0];
boolean isFromWire = message instanceof ClusteredMessage && ((ClusteredMessage) message).isFromWire();
if (!isFromWire && VertxContext.hasContext(message.address())) {
VertxContext context = VertxContext.popContext(message.address());
context.getSpan().asyncFinish();
} else if (!isFromWire) {
AbstractSpan span;
if (VertxContext.hasContext(message.replyAddress())) {
VertxContext context = VertxContext.peekContext(message.replyAddress());
span = ContextManager.createLocalSpan(context.getContextSnapshot().getParentOperationName());
ContextManager.continued(context.getContextSnapshot());
} else {
span = ContextManager.createLocalSpan(message.address());
}
span.setComponent(ComponentsDefine.VERTX);
SpanLayer.asRPCFramework(span);

if (message.replyAddress() != null) {
VertxContext.pushContext(message.replyAddress(),
new VertxContext(ContextManager.capture(), span.prepareForAsync()));
}
ContextManager.getRuntimeContext().put(VertxContext.STOP_SPAN_NECESSARY + "." + getClass().getName(), true);
}
}

@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
Object ret) throws Throwable {
Boolean closeSpan = (Boolean) ContextManager.getRuntimeContext().get(
VertxContext.STOP_SPAN_NECESSARY + "." + getClass().getName());
if (Boolean.TRUE.equals(closeSpan)) {
ContextManager.stopSpan();
}
return ret;
}

@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
Class<?>[] argumentsTypes, Throwable t) {
ContextManager.activeSpan().errorOccurred().log(t);
}
}
Loading