- Notifications
You must be signed in to change notification settings - Fork 327
Simple bypass for servlet spec < 3.x #1077
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
Simple bypass for servlet spec < 3.x #1077
Conversation
...ervlet-plugin/src/main/java/co/elastic/apm/agent/servlet/AbstractServletInstrumentation.java Outdated Show resolved Hide resolved
...ervlet-plugin/src/main/java/co/elastic/apm/agent/servlet/AbstractServletInstrumentation.java Outdated Show resolved Hide resolved
…apm/agent/servlet/AbstractServletInstrumentation.java Co-Authored-By: eyalkoren <41850454+eyalkoren@users.noreply.github.com>
Maybe we can couple this with logging |
| Seems like tests fail on Payara |
| I've added a quick check on |
felixbarny left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments on the ServletInitInstrumentation but we can also merge the PR without this instrumentation.
...pm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/ServletInitInstrumentation.java Outdated Show resolved Hide resolved
...pm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/ServletInitInstrumentation.java Outdated Show resolved Hide resolved
...pm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/ServletInitInstrumentation.java Outdated Show resolved Hide resolved
...pm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/ServletInitInstrumentation.java Outdated Show resolved Hide resolved
...pm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/ServletInitInstrumentation.java Outdated Show resolved Hide resolved
| @Advice.OnMethodEnter(suppress = Throwable.class) | ||
| @SuppressWarnings("Duplicates") // duplication is fine here as it allows to inline code | ||
| private static void onEnter(@Advice.This Servlet servlet) { | ||
| if (!doLogAndWarn.getAndSet(false)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid a CAS on every invocation
| if (!doLogAndWarn.getAndSet(false)) { | |
| if (!doLogAndWarn.get() || !doLogAndWarn.getAndSet(false)) { |
maybe rename doLogAndWarn to alreadyLogged to get rid of the negations which are a bit harder to parse?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
definitely agree on having less negations, however doing a double check here seems a bit overkill. I think it's fine to replace this AtomicBoolean with a simple volatile boolean as AtomicBoolean.get does makes a volatile read, thus it won't be more efficient.
What does this PR do?
This pull-request modifies Servlet plugin instrumentation to make it gracefully ignore Servlet implementations before Servlet API 3.0.
Without this change, users get spammed in application server logs with similar exception (Here on Tomcat 6.x):
While this change avoids spamming the server logs, there is no explicit warning message from this agent when an unsupported version is being used. Thus from user's perspective it will just make the agent not monitor any HTTP transaction (but JMX metrics will still be properly working as expected).
Checklist
I have made corresponding changes to the documentationI have added tests that prove my fix is effective or that my feature works(tested manually)I have updated supported-technologies.asciidoc(no change required, previous versions were not supported).Author's Checklist
Related issues