1package dev.rafex.ether.glowroot.jetty12;
4import java.util.concurrent.TimeUnit;
6import org.glowroot.agent.api.Glowroot;
34import dev.rafex.ether.http.core.HttpHandler;
35import dev.rafex.ether.http.core.Middleware;
61public final class GlowrootHealthExclusionMiddleware
implements Middleware {
64 public static final Set<String>
DEFAULT_PATHS = Set.of(
"/health",
"/ready",
"/live",
"/metrics");
66 private final Set<String> excludedPaths;
68 private GlowrootHealthExclusionMiddleware(
final Set<String> excludedPaths) {
69 this.excludedPaths = Set.copyOf(excludedPaths);
78 public static GlowrootHealthExclusionMiddleware
of(
final String... paths) {
79 return new GlowrootHealthExclusionMiddleware(Set.of(paths));
83 public static GlowrootHealthExclusionMiddleware
defaults() {
90 final var path = exchange.path();
91 if (path !=
null && excludedPaths.contains(path)) {
93 Glowroot.setTransactionSlowThreshold(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
94 }
catch (
final Throwable ignore) {
98 return next.
handle(exchange);
HttpHandler wrap(final HttpHandler next)
static final Set< String > DEFAULT_PATHS
Paths used by defaults().
static GlowrootHealthExclusionMiddleware of(final String... paths)
Creates an instance with the given exact paths.
static GlowrootHealthExclusionMiddleware defaults()
Creates an instance excluding DEFAULT_PATHS.
boolean handle(HttpExchange exchange)