Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Success Rate is Incorrect with Vert.x #662

Merged
merged 1 commit into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Release Notes.
* fix forkjoinpool plugin in JDK11。
* Support for tracing spring-cloud-gateway 4.x in gateway-4.x-plugin.
* Fix re-transform bug when plugin enhanced class proxy parent method.
* Fix error HTTP status codes not recording as SLA failures in Vert.x plugins.

#### Documentation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr
HttpClientRequestContext requestContext = (HttpClientRequestContext) objInst.getSkyWalkingDynamicField();
if (!requestContext.usingWebClient) {
VertxContext context = requestContext.vertxContext;
Tags.HTTP_RESPONSE_STATUS_CODE.set(context.getSpan(), ((HttpClientResponse) allArguments[0]).statusCode());
int statusCode = ((HttpClientResponse) allArguments[0]).statusCode();
Tags.HTTP_RESPONSE_STATUS_CODE.set(context.getSpan(), statusCode);
if (statusCode >= 400) {
context.getSpan().errorOccurred();
}
context.getSpan().asyncFinish();

AbstractSpan span = ContextManager.createLocalSpan("#" + context.getSpan().getOperationName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr
HttpClientRequest clientRequest = httpContext.clientRequest();
VertxContext context = ((HttpClientRequestContext) ((EnhancedInstance) clientRequest)
.getSkyWalkingDynamicField()).vertxContext;
Tags.HTTP_RESPONSE_STATUS_CODE.set(context.getSpan(), httpContext.clientResponse().statusCode());
int statusCode = httpContext.clientResponse().statusCode();
Tags.HTTP_RESPONSE_STATUS_CODE.set(context.getSpan(), statusCode);
if (statusCode >= 400) {
context.getSpan().errorOccurred();
}
context.getSpan().asyncFinish();

AbstractSpan span = ContextManager.createLocalSpan("#" + context.getSpan().getOperationName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allAr
if (VertxContext.VERTX_VERSION < 36 && allArguments[0] instanceof ByteBuf
|| VertxContext.VERTX_VERSION >= 36 && VertxContext.VERTX_VERSION <= 37 || allArguments.length == 2) {
VertxContext context = (VertxContext) objInst.getSkyWalkingDynamicField();
Tags.HTTP_RESPONSE_STATUS_CODE.set(context.getSpan(), ((HttpServerResponse) objInst).getStatusCode());
int statusCode = ((HttpServerResponse) objInst).getStatusCode();
Tags.HTTP_RESPONSE_STATUS_CODE.set(context.getSpan(), statusCode);
if (statusCode >= 400) {
context.getSpan().errorOccurred();
}
context.getSpan().asyncFinish();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ public <R> void sendResponse(Context context, R response, AbstractSpan payload,
}

if (response instanceof HttpResponse) {
Tags.HTTP_RESPONSE_STATUS_CODE.set(payload, ((HttpResponse) response).statusCode());
int statusCode = ((HttpResponse) response).statusCode();
Tags.HTTP_RESPONSE_STATUS_CODE.set(payload, statusCode);
if (statusCode >= 400) {
payload.errorOccurred();
}
}
payload.asyncFinish();
}
Expand Down
Loading