Skip to content

Conversation

@sijuv
Copy link
Contributor

@sijuv sijuv commented Jan 21, 2020

There could be need to further customize the default shouldFilter implementation, ex you want to exclude traffic based on user agent as in case of bots.

@geoand
Copy link
Collaborator

geoand commented Jan 21, 2020

Thanks for the contribution.

Can you show a concrete example where you would need this?

Thanks

@sijuv
Copy link
Contributor Author

sijuv commented Jan 21, 2020

we have a use case where certain bots hit our production services. These are identified by their user-agent header. We dont want such calls to be traced.
A sample code would look like this:

if (Option.ofNullable(request.getHeaders().getFirst(HttpHeaders.USER_AGENT))
    .map(s -> userAgentSkipPattern.matcher(s.toLowerCase()).matches()).orElse(false)) {
  if (LOG.isTraceEnabled()) {
    LOG.trace(
        "Not tracing request " + request + " because it matches user agen skip pattern: " + userAgentSkipPattern);
  }
  return false;
}

To implement this I would extend the open tracing provided TracingWebFIlter and override the shouldBeTracedMethod.

@geoand
Copy link
Collaborator

geoand commented Jan 22, 2020

That makes sense, thanks

@geoand geoand merged commit 255337b into opentracing-contrib:master Jan 22, 2020
@geoand
Copy link
Collaborator

geoand commented Jan 22, 2020

I merged and launched a release of 3.0.1 which should contain the fix if the release goes well

zouyx pushed a commit to zouyx/java-spring-web that referenced this pull request Dec 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants