Skip to content

Commit f698159

Browse files
committed
Log participant in GenericFailureHandler
1 parent b0072ab commit f698159

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/main/java/com/uid2/operator/vertx/GenericFailureHandler.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.uid2.operator.vertx;
22

3+
import com.uid2.shared.auth.IAuthorizable;
4+
import com.uid2.shared.auth.OperatorKey;
5+
import com.uid2.shared.middleware.AuthMiddleware;
36
import io.vertx.core.Handler;
47
import io.vertx.core.http.HttpClosedException;
58
import io.vertx.core.http.HttpServerResponse;
@@ -19,16 +22,23 @@ public void handle(RoutingContext ctx) {
1922
String url = ctx.normalizedPath();
2023
Throwable t = ctx.failure();
2124

25+
final IAuthorizable profile = AuthMiddleware.getAuthClient(ctx);
26+
final OperatorKey operatorKey = profile instanceof OperatorKey ? (OperatorKey) profile : null;
27+
String participant = "unknown";
28+
if (operatorKey != null) {
29+
participant = operatorKey.getName();
30+
}
31+
2232
if (t != null) {
2333
// Because Vert.x swallows stack traces so cannot log stack trace
2434
// And we want to ignore HttpClosedException errors as it is (usually) caused by users and no impact
2535
if (t instanceof HttpClosedException) {
26-
LOGGER.warn("Ignoring exception - URL: [{}] - Error:", url, t);
36+
LOGGER.warn("Ignoring exception - URL: [{}], Participant: [{}] - Error:", url, participant, t);
2737
response.end();
2838
} else if (statusCode >= 500 && statusCode < 600) { // 5xx is server error, so error
29-
LOGGER.error("URL: [{}] - Error response code: [{}] - Error:", url, statusCode, t);
39+
LOGGER.error("URL: [{}], Participant: [{}] - Error response code: [{}] - Error:", url, participant, statusCode, t);
3040
} else if (statusCode >= 400 && statusCode < 500) { // 4xx is user error, so just warn
31-
LOGGER.warn("URL: [{}] - Error response code: [{}] - Error:", url, statusCode, t);
41+
LOGGER.warn("URL: [{}], Participant: [{}] - Error response code: [{}] - Error:", url, participant, statusCode, t);
3242
}
3343
}
3444

0 commit comments

Comments
 (0)