Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search for skipPattern in servletcontext if none is defined by Builder #97

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,12 @@
@Priority(Priorities.HEADER_DECORATOR)
public class ServerTracingFilter implements ContainerRequestFilter, ContainerResponseFilter {
private static final Logger log = Logger.getLogger(ServerTracingFilter.class.getName());


/**
* Use as a key of {@link ServletContext#setAttribute(String, Object)} to skip pattern
*/
public static final String SKIP_PATTERN = ServerTracingFilter.class.getName() + ".skipPattern";

private Tracer tracer;
private List<ServerSpanDecorator> spanDecorators;
private String operationName;
Expand Down Expand Up @@ -128,6 +133,13 @@ public void filter(ContainerRequestContext requestContext,
private boolean matchesSkipPattern(ContainerRequestContext requestContext) {
// skip URLs matching skip pattern
// e.g. pattern is defined as '/health|/status' then URL 'http://localhost:5000/context/health' won't be traced
if (skipPattern == null && httpServletRequest != null && httpServletRequest.getServletContext() != null) {
Object contextAttribute = httpServletRequest.getServletContext().getAttribute(SKIP_PATTERN);
if (contextAttribute instanceof Pattern) {
skipPattern = (Pattern) contextAttribute;
}
}

if (skipPattern != null) {
String path = requestContext.getUriInfo().getPath();
if (path.charAt(0) != '/') {
Expand Down