112 public boolean handle(
final Request request,
final Response response,
final Callback callback)
throws Exception {
113 final var method = request.getMethod();
114 final var path = request.getHttpURI() !=
null ? request.getHttpURI().getPath() :
null;
115 final var normalized = PathNormalizer.normalize(path);
119 Glowroot.setTransactionType(
"Web");
120 Glowroot.setTransactionName(method +
" " + normalized);
121 Glowroot.addTransactionAttribute(
"http.method", method);
122 Glowroot.addTransactionAttribute(
"http.path", path ==
null ?
"unknown" : path);
123 Glowroot.addTransactionAttribute(
"http.normalized_path", normalized);
124 }
catch (
final Throwable ignore) {
128 if (path !=
null && healthPaths.contains(path)) {
130 Glowroot.setTransactionSlowThreshold(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
131 }
catch (
final Throwable ignore) {
134 final var threshold = thresholdByNormalizedPath.getOrDefault(normalized, defaultThresholdMs);
137 Glowroot.setTransactionSlowThreshold(threshold, TimeUnit.MILLISECONDS);
138 }
catch (
final Throwable ignore) {
144 if (requestIdHeader !=
null) {
146 var reqId = request.getHeaders().get(requestIdHeader);
147 if ((reqId ==
null || reqId.isBlank()) && requestIdGenerator !=
null) {
148 reqId = requestIdGenerator.nextId();
150 if (reqId !=
null && !reqId.isBlank()) {
151 Glowroot.addTransactionAttribute(
"request.id", reqId);
153 }
catch (
final Throwable ignore) {
159 final var result = super.handle(request, response, callback);
163 final var status = response.getStatus();
165 Glowroot.addTransactionAttribute(
"http.status", String.valueOf(status));
166 Glowroot.addTransactionAttribute(
"http.status_class", status / 100 +
"xx");
168 }
catch (
final Throwable ignore) {
172 if (userExtractor !=
null) {
176 final var user = userExtractor.apply(ctx);
177 if (user !=
null && !user.isBlank()) {
178 Glowroot.setTransactionUser(user);
179 Glowroot.addTransactionAttribute(
"auth.user", user);
182 }
catch (
final Throwable ignore) {
188 }
catch (
final Throwable t) {
191 Glowroot.addTransactionAttribute(
"error", t.getClass().getName());
192 Glowroot.addTransactionAttribute(
"error.message", t.getMessage() ==
null ?
"" : t.getMessage());
193 }
catch (
final Throwable ignore) {