1package dev.rafex.ether.glowroot.jetty12;
3import java.util.Objects;
4import java.util.function.Function;
6import org.glowroot.agent.api.Glowroot;
34import dev.rafex.ether.http.core.HttpExchange;
35import dev.rafex.ether.http.core.HttpHandler;
36import dev.rafex.ether.http.core.Middleware;
37import dev.rafex.ether.observability.core.request.RequestIdGenerator;
61 private final Function<HttpExchange, String> idExtractor;
65 final boolean generateIfAbsent) {
71 this.idExtractor = Objects.requireNonNull(idExtractor,
"idExtractor must not be null");
72 this.requestIdGenerator = requestIdGenerator;
79 String requestId = idExtractor.apply(exchange);
80 if ((requestId ==
null || requestId.isBlank()) && requestIdGenerator !=
null) {
81 requestId = requestIdGenerator.nextId();
83 if (requestId !=
null && !requestId.isBlank()) {
84 Glowroot.addTransactionAttribute(
"request.id", requestId);
86 }
catch (
final Throwable ignore) {
89 return next.
handle(exchange);
RequestIdGenerator bridge that records generated request IDs into Glowroot transaction attributes.
GlowrootRequestIdMiddleware(final Function< HttpExchange, String > idExtractor, final RequestIdGenerator requestIdGenerator)
HttpHandler wrap(final HttpHandler next)
GlowrootRequestIdMiddleware(final Function< HttpExchange, String > idExtractor, final boolean generateIfAbsent)
boolean handle(HttpExchange exchange)
Generador de IDs de petición.