Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
986db3c
vertx web plugin re-impl attempt
BFergerson Apr 8, 2020
cf36656
added license
BFergerson Apr 9, 2020
cc7ce77
Merge branch 'master' into master
wu-sheng Apr 11, 2020
8d256d1
Merge branch 'master' into master
wu-sheng Apr 12, 2020
cc4e2b5
Merge pull request #1 from apache/master
BFergerson Apr 21, 2020
87d22ab
update test for new plugin structure
BFergerson Apr 22, 2020
85c6ccc
Merge branch 'master' into master
BFergerson Apr 22, 2020
300499b
got rid of registryItems
BFergerson Apr 22, 2020
e5cc6aa
Merge remote-tracking branch 'origin/master'
BFergerson Apr 22, 2020
81acb7f
remove unnecessary dependencies
BFergerson Apr 23, 2020
2fd69d3
re-impl eventbus scenario
BFergerson Apr 23, 2020
959542d
more precise naming
BFergerson Apr 23, 2020
aa0fd16
fix expected data
BFergerson Apr 23, 2020
6e11f68
Merge branch 'master' into master
wu-sheng Apr 23, 2020
db347e9
removed unsupported versions and removed vertx caching (avoids permis…
BFergerson Apr 23, 2020
1483e31
Merge remote-tracking branch 'origin/master'
BFergerson Apr 23, 2020
4a877c0
rewrote to remove copied code
BFergerson Apr 23, 2020
d465dd4
Merge branch 'master' into master
rainbend Apr 23, 2020
21cebc2
Update plugins-test.3.yaml
BFergerson Apr 24, 2020
b4ad628
fixes issue of .vertx files remaining on v3.0.0
BFergerson Apr 24, 2020
d313cb2
Merge remote-tracking branch 'origin/master'
BFergerson Apr 24, 2020
b876173
only present in v3.0.0
BFergerson Apr 24, 2020
d57a3c3
consistency
BFergerson Apr 29, 2020
2b614e9
Merge branch 'master' of https://github.com/BFergerson/skywalking
BFergerson Apr 29, 2020
b0b24b4
add more supported versions
BFergerson Apr 29, 2020
de1ef3c
track status code
BFergerson Apr 29, 2020
ac3d6e1
spelling fix
BFergerson Apr 29, 2020
213f5a6
track status code
BFergerson Apr 29, 2020
1a44db0
more correct naming
BFergerson Apr 29, 2020
41c1ce2
reverts 213f5a69 (status code isn't sent at this point)
BFergerson Apr 29, 2020
ee39431
made HttpServerResponseImplEndInstrumentation more strict based on ve…
BFergerson Apr 29, 2020
b267f86
works 3.0.0,3.7.0
BFergerson Apr 29, 2020
35c71a4
increase compatibility
BFergerson Apr 29, 2020
75f578f
Merge branch 'master' into master
BFergerson Apr 29, 2020
d2c9577
3.9.0 default
BFergerson Apr 29, 2020
cbc36b7
Merge remote-tracking branch 'origin/master'
BFergerson Apr 29, 2020
3edff1d
Merge branch 'master' into master
wu-sheng Apr 30, 2020
288e571
versioned witness classes (advice from wu-sheng)
BFergerson Apr 30, 2020
64232f8
Merge remote-tracking branch 'origin/master'
BFergerson Apr 30, 2020
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
4 changes: 2 additions & 2 deletions .github/workflows/plugins-test.3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ jobs:
- { name: 'spring-4.1.x-scenario', title: 'Spring 4.1.x-4.2.x (20)' }
- { name: 'spring-4.3.x-scenario', title: 'Spring 4.3.x-5.2.x (54)' }
- { name: 'spring-async-scenario', title: 'Spring Async 4.3.x-5.1.x (35)' }
- { name: 'vertx-eventbus-3.x-scenario', title: 'Vert.x EventBus 3.2.x-3.7.x (19)' }
- { name: 'vertx-web-3.x-scenario', title: 'Vert.x Web 3.0.x-3.7.x (21)' }
- { name: 'vertx-eventbus-3.x-scenario', title: 'Vert.x EventBus 3.2.0-3.9.0 (27)' }
- { name: 'vertx-web-3.x-scenario', title: 'Vert.x Web 3.0.0-3.9.0 (29)' }
steps:
- uses: actions/checkout@v2
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public AbstractSpan asyncFinish() {
throw new RuntimeException("Span is not in async mode, please use '#prepareForAsync' to active.");
}
if (isAsyncStopped) {
throw new RuntimeException("Can not do async finish for the span repeately.");
throw new RuntimeException("Can not do async finish for the span repeatedly.");
}
this.endTime = System.currentTimeMillis();
owner.asyncStop(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<url>http://maven.apache.org</url>

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

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,42 @@

import java.lang.reflect.Method;

public class HttpClientRequestImplEndInterceptor implements InstanceMethodsAroundInterceptor, InstanceConstructorInterceptor {
public class HttpClientRequestImplEndInterceptor implements InstanceMethodsAroundInterceptor {

@Override
public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
String host;
int port;
if (allArguments[3] instanceof Integer) {
host = (String) allArguments[2];
port = (Integer) allArguments[3];
} else {
host = (String) allArguments[3];
port = (Integer) allArguments[4];
public static class Version30XTo33XConstructorInterceptor implements InstanceConstructorInterceptor {
@Override
public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
String host = (String) allArguments[2];
int port = (Integer) allArguments[3];
objInst.setSkyWalkingDynamicField(host + ":" + port);
}
}

public static class Version34XTo37XConstructorInterceptor implements InstanceConstructorInterceptor {
@Override
public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
String host = (String) allArguments[3];
int port = (Integer) allArguments[4];
objInst.setSkyWalkingDynamicField(host + ":" + port);
}
}

public static class Version38PlusConstructorInterceptor implements InstanceConstructorInterceptor {
@Override
public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
String host = (String) allArguments[4];
int port = (Integer) allArguments[5];
objInst.setSkyWalkingDynamicField(host + ":" + port);
}
objInst.setSkyWalkingDynamicField(host + ":" + port);
}

@Override
@SuppressWarnings("unchecked")
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
MethodInterceptResult result) {
HttpClientRequest request = (HttpClientRequest) objInst;
ContextCarrier contextCarrier = new ContextCarrier();
AbstractSpan span = ContextManager.createExitSpan(toPath(request.uri()), contextCarrier, (String) objInst.getSkyWalkingDynamicField());
AbstractSpan span = ContextManager.createExitSpan(toPath(request.uri()), contextCarrier,
(String) objInst.getSkyWalkingDynamicField());
span.setComponent(ComponentsDefine.VERTX);
SpanLayer.asHttp(span);
Tags.HTTP.METHOD.set(span, request.method().toString());
Expand All @@ -71,14 +84,14 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr

@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
Object ret) throws Throwable {
Object ret) {
ContextManager.stopSpan();
return ret;
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

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

import io.vertx.core.http.HttpClientResponse;
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;
Expand All @@ -31,10 +33,10 @@
public class HttpClientRequestImplHandleResponseInterceptor implements InstanceMethodsAroundInterceptor {

@Override
@SuppressWarnings("unchecked")
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
VertxContext context = (VertxContext) objInst.getSkyWalkingDynamicField();
Tags.STATUS_CODE.set(context.getSpan(), Integer.toString(((HttpClientResponse) allArguments[0]).statusCode()));
context.getSpan().asyncFinish();

AbstractSpan span = ContextManager.createLocalSpan("#" + context.getSpan().getOperationName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@

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

import io.vertx.core.http.HttpServerResponse;
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.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;
Expand All @@ -28,13 +30,11 @@
public class HttpServerResponseImplEndInterceptor implements InstanceMethodsAroundInterceptor {

@Override
@SuppressWarnings("unchecked")
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
if (allArguments.length == 0) {
VertxContext context = (VertxContext) objInst.getSkyWalkingDynamicField();
context.getSpan().asyncFinish();
}
VertxContext context = (VertxContext) objInst.getSkyWalkingDynamicField();
Tags.STATUS_CODE.set(context.getSpan(), Integer.toString(((HttpServerResponse) objInst).getStatusCode()));
context.getSpan().asyncFinish();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;

import static net.bytebuddy.matcher.ElementMatchers.any;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;

/**
* {@link HttpClientRequestImplEndInstrumentation} enhance the <code>end</code> method in
Expand All @@ -42,40 +42,62 @@ public class HttpClientRequestImplEndInstrumentation extends ClassInstanceMethod

@Override
public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[] {
new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return any();
}
return new ConstructorInterceptPoint[]{
new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return takesArgument(3, int.class);
}

@Override
public String getConstructorInterceptor() {
return INTERCEPT_CLASS + "$Version30XTo33XConstructorInterceptor";
}
},
new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return takesArgument(4, int.class);
}

@Override
public String getConstructorInterceptor() {
return INTERCEPT_CLASS + "$Version34XTo37XConstructorInterceptor";
}
},
new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return takesArgument(5, int.class);
}

@Override
public String getConstructorInterceptor() {
return INTERCEPT_CLASS;
@Override
public String getConstructorInterceptor() {
return INTERCEPT_CLASS + "$Version38PlusConstructorInterceptor";
}
}
}
};
}

@Override
public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
return new InstanceMethodsInterceptPoint[] {
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return named(ENHANCE_METHOD);
}
return new InstanceMethodsInterceptPoint[]{
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return named(ENHANCE_METHOD);
}

@Override
public String getMethodsInterceptor() {
return INTERCEPT_CLASS;
}
@Override
public String getMethodsInterceptor() {
return INTERCEPT_CLASS;
}

@Override
public boolean isOverrideArgs() {
return false;
@Override
public boolean isOverrideArgs() {
return false;
}
}
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;

import static net.bytebuddy.matcher.ElementMatchers.named;
import static org.apache.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;

/**
* {@link HttpServerResponseImplEndInstrumentation} enhance the <code>end</code> method in
Expand All @@ -36,8 +37,7 @@
public class HttpServerResponseImplEndInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {

private static final String ENHANCE_CLASS = "io.vertx.core.http.impl.HttpServerResponseImpl";
private static final String ENHANCE_METHOD = "end";
private static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.vertx3.HttpServerResponseImplEndInterceptor";
private static final String INTERCEPTOR_CLASS = "org.apache.skywalking.apm.plugin.vertx3.HttpServerResponseImplEndInterceptor";

@Override
public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
Expand All @@ -50,12 +50,17 @@ public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return named(ENHANCE_METHOD);
return named("end0") //ver. 3.0.0 - 3.5.4
.or(named("end") //ver. 3.6.0 - 3.7.0
.and(takesArgumentWithType(0, "io.vertx.core.buffer.Buffer")))
.or(named("end") //ver. 3.7.1+
.and(takesArgumentWithType(0, "io.vertx.core.buffer.Buffer"))
.and(takesArgumentWithType(1, "io.netty.channel.ChannelPromise")));
}

@Override
public String getMethodsInterceptor() {
return INTERCEPT_CLASS;
return INTERCEPTOR_CLASS;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,26 @@
# limitations under the License.
segmentItems:
- serviceName: vertx-eventbus-3.x-scenario
segmentSize: 7
segmentSize: 8
segments:
- segmentId: not null
spans:
- operationName: /vertx-eventbus-3-scenario/case/healthCheck
operationId: 0
parentSpanId: -1
spanId: 0
spanLayer: Http
startTime: nq 0
endTime: nq 0
componentId: 59
isError: false
spanType: Entry
peer: ''
skipAnalysis: false
tags:
- {key: http.method, value: HEAD}
- {key: url, value: /vertx-eventbus-3-scenario/case/healthCheck}
- {key: status_code, value: '200'}
- segmentId: not null
spans:
- operationName: local-message-receiver
Expand Down Expand Up @@ -58,6 +76,7 @@ segmentItems:
tags:
- {key: http.method, value: GET}
- {key: url, value: /vertx-eventbus-3-scenario/case/executeTest}
- {key: status_code, value: '200'}
- operationName: /vertx-eventbus-3-scenario/case/eventbus-case
operationId: 0
parentSpanId: -1
Expand All @@ -73,6 +92,7 @@ segmentItems:
tags:
- {key: http.method, value: GET}
- {key: url, value: /vertx-eventbus-3-scenario/case/eventbus-case}
- {key: status_code, value: '200'}
- segmentId: not null
spans:
- operationName: '#/vertx-eventbus-3-scenario/case/executeTest'
Expand Down Expand Up @@ -133,6 +153,7 @@ segmentItems:
tags:
- {key: http.method, value: GET}
- {key: url, value: /vertx-eventbus-3-scenario/case/executeTest}
- {key: status_code, value: '200'}
refs:
- {parentEndpoint: /vertx-eventbus-3-scenario/case/eventbus-case, networkAddress: 'localhost:8080',
refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null,
Expand Down
2 changes: 1 addition & 1 deletion test/plugin/scenarios/vertx-eventbus-3.x-scenario/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<compiler.version>1.8</compiler.version>
<test.framework.version>3.7.0</test.framework.version>
<test.framework.version>3.9.0</test.framework.version>
</properties>

<name>skywalking-vertx-eventbus-3.x-scenario</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class VertxEventbusController extends AbstractVerticle {
@Override
public void start() {
Router router = Router.router(vertx);
router.get("/vertx-eventbus-3-scenario/case/eventbus-case").handler(this::handleCoreCase);
router.get("/vertx-eventbus-3-scenario/case/eventbus-case").handler(this::handleEventbusCase);
router.get("/vertx-eventbus-3-scenario/case/executeTest").handler(this::executeTest);
router.head("/vertx-eventbus-3-scenario/case/healthCheck").handler(this::healthCheck);
vertx.createHttpServer().requestHandler(router::accept).listen(8080);
Expand All @@ -39,7 +39,7 @@ public void start() {
vertx.deployVerticle(LocalReceiver.class.getName());
}

private void handleCoreCase(RoutingContext routingContext) {
private void handleEventbusCase(RoutingContext routingContext) {
vertx.createHttpClient().getNow(8080, "localhost",
"/vertx-eventbus-3-scenario/case/executeTest",
it -> routingContext.response().setStatusCode(it.statusCode()).end());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

3.9.0
3.8.5
3.8.4
3.8.3
3.8.2
3.8.1
3.8.0
3.7.1
3.7.0
3.6.3
3.6.2
Expand Down
Loading