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

Tomcat server handlers #1902

Merged
merged 12 commits into from
Dec 16, 2020
Merged

Tomcat server handlers #1902

merged 12 commits into from
Dec 16, 2020

Conversation

vovencij
Copy link
Contributor

@vovencij vovencij commented Dec 14, 2020

This is a Tomcat version of a server handler, as described and discussed in #1886

Some notable findings:

  • Server instrumentation needs uncaught exceptions from outermost servlets/filters. These are passed via AppServerBridge.THROWABLE_CONTEXT_KEY context attribute. Outermost servlets/filters set their unhandled exceptions with the current span.
  • Exception handling in tomcat is done in a way, where a request passes the servlet stack two times – first pass is the initial request and the second pass is when tomcat tries to render an error page mapped in web.xml. Server span name should be updated only when doing a first pass. Thus the AppServerBridge context attribute and not the intuitive callDepth counter.

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @vovencij! do you think this will resolve #894?

@vovencij
Copy link
Contributor Author

do you think this will resolve #894?

I think so. This is the trace I get from the demo case in that ticket in my branch:
image

And there is also an unhandled servlet exception reported in the trace:
image

Copy link
Contributor

@iNikem iNikem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like AppServerBridge at all. I have no better suggestions right now, but I will think about it...

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@iNikem iNikem merged commit 135ba34 into open-telemetry:master Dec 16, 2020
@vovencij vovencij deleted the tomcat-handlers branch December 16, 2020 15:02
bhautikpip pushed a commit to bhautikpip/opentelemetry-java-instrumentation that referenced this pull request Dec 18, 2020
* Tomcat server handler with passing integration and smoke tests.

* Update server span name from the servlet integration instead of trying to mimic it from the server handler.

* Cleanup and more javadocs.

* Use Java8BytecodeBridge in advice code.

* Use Java8BytecodeBridge in advice code.

* Use earliest version for compilation and muzzling.

* Use consistent instrumentation name.

* Record throwables only if the context is managed by something else.

* Getting scope handling right. Moved server span renaming logic via AppServerBridge to the ServletHttpServerTracer.

* codenarc

* more PR comments addressed

* Pass Method to startServerSpan
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.

None yet

5 participants