fix: Vertx plugin, 400+ status codes should cause SLA fail (#662)

This commit is contained in:
Brandon Fergerson 2024-01-03 18:56:31 -06:00 committed by GitHub
parent 4f2f81e181
commit 9c7f1316d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 4 deletions

View File

@ -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

View File

@ -40,7 +40,11 @@ public class HttpClientRequestImplHandleResponseInterceptor implements InstanceM
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());

View File

@ -42,7 +42,11 @@ public class HttpContextHandleDispatchResponseInterceptor implements InstanceMet
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());

View File

@ -43,7 +43,11 @@ public class HttpServerResponseImplInterceptor implements InstanceMethodsAroundI
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();
}
}

View File

@ -88,7 +88,11 @@ public class SWVertxTracer implements VertxTracer<AbstractSpan, AbstractSpan> {
}
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();
}