-
Notifications
You must be signed in to change notification settings - Fork 886
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
Servlet 5 API, reorganize servlet modules #2609
Conversation
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 lot of good stuff, thx for tackling it!
...a/io/opentelemetry/javaagent/instrumentation/servlet/v2_2/Servlet2InstrumentationModule.java
Show resolved
Hide resolved
instrumentation/servlet/servlet-2.2/library/servlet-2.2-library.gradle
Outdated
Show resolved
Hide resolved
...ry/src/main/java/io/opentelemetry/instrumentation/servlet/v2_2/Servlet2HttpServerTracer.java
Outdated
Show resolved
Hide resolved
instrumentation/servlet/servlet-3.0/library/servlet-3.0-library.gradle
Outdated
Show resolved
Hide resolved
...ry/src/main/java/io/opentelemetry/instrumentation/servlet/v3_0/Servlet3HttpServerTracer.java
Outdated
Show resolved
Hide resolved
...pentelemetry/javaagent/instrumentation/servlet/javax/dispatcher/RequestDispatcherTracer.java
Outdated
Show resolved
Hide resolved
...pentelemetry/javaagent/instrumentation/servlet/dispatcher/RequestDispatcherAdviceHelper.java
Outdated
Show resolved
Hide resolved
...ava/io/opentelemetry/javaagent/instrumentation/servlet/javax/JavaxCommonServletAccessor.java
Outdated
Show resolved
Hide resolved
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.
btw, thx for the detailed PR summary, and the updated servlet/README.md
, made reviewing much easier ❤️
...opentelemetry/javaagent/instrumentation/servlet/v5_0/dispatcher/RequestDispatcherTracer.java
Outdated
Show resolved
Hide resolved
...pentelemetry/javaagent/instrumentation/servlet/javax/dispatcher/RequestDispatcherTracer.java
Outdated
Show resolved
Hide resolved
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.
Great work, thank you!
...t-common/library/src/main/java/io/opentelemetry/instrumentation/servlet/ServletAccessor.java
Show resolved
Hide resolved
...lemetry/javaagent/instrumentation/servlet/v5_0/response/HttpServletResponseAdviceHelper.java
Outdated
Show resolved
Hide resolved
...etry/javaagent/instrumentation/servlet/v5_0/dispatcher/RequestDispatcherInstrumentation.java
Outdated
Show resolved
Hide resolved
...lemetry/javaagent/instrumentation/servlet/v5_0/dispatcher/RequestDispatcherAdviceHelper.java
Outdated
Show resolved
Hide resolved
...lemetry/javaagent/instrumentation/servlet/v5_0/dispatcher/RequestDispatcherAdviceHelper.java
Outdated
Show resolved
Hide resolved
instrumentation/servlet/servlet-javax-common/javaagent/servlet-javax-common-javaagent.gradle
Show resolved
Hide resolved
...n/java/io/opentelemetry/javaagent/instrumentation/servlet/javax/response/ResponseTracer.java
Show resolved
Hide resolved
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.
Just small comments, thanks!
private String getSpanName( | ||
Object servletOrFilter, HttpServletRequest request, boolean allowNull) { | ||
String spanName = getSpanName(servletOrFilter, request); | ||
if (spanName == null && !allowNull) { |
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.
I think I only see this called twice, one with allowNull and one without. Can we move the logic for !allowNull to the caller to reduce conditionals?
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.
It's good to have as a separate method since return
keyword is convenient here and the method name still fits. However, made the caller of true
call the inner method instead to still get rid of this extra parameter, and renamed the inner method to getSpanNameFromPath
.
pass { | ||
group = "jakarta.servlet" | ||
module = 'jakarta.servlet-api' | ||
versions = "[5.0.0,)" |
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.
Can we assertInverse
? Since package name changed assuming it's safe so good to verify.
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.
Done.
The following changes are made in this PR:
servlet-common
is split up intoservlet-common
andservlet-javax-common
where the former does not directly use servlet classes, but defines an interfaceServletAccessor<REQUEST, RESPONSE>
which is used to access request and response objects, and the latter applies instrumentations previously found inservlet-common
.:instrumentation-core:servlet-2.2
is migrated to:instrumentation:servlet:servlet-common:library
servlet-2.2:javaagent
andservlet-3.0:javaagent
are split intojavaagent
andlibrary
modules where the tracer moves to library.TypeInstrumentation
classes moved toservlet-common:javaagent
and they take base package (eitherjavax.servlet
orjakarta.servlet
) and advice class name as constructor parametersservlet-jakarta
which applies instrumentations tojakarta.servlet
classes (the ones which are done byservlet-javax-common
andservlet-3.0
forjavax.servlet
packages)servlet-jakarta
which is Servlet API 5.0 equivalent of the test war project. Added Jetty 11 test images which use the new war file. Manually tested that Jetty tests that do not require thejetty-8.0
module pass with those images.To get a general overview of the structure of
instrumentation/servlet
directory, read the updated readme in there.Most of the changes to existing servlet modules were made to reduce code duplication, but some code is still duplicated for the following cases:
servlet-3.0
andservlet-jakarta
. As they modify local variables injected into instrumented methods, extracting common methods would require some additional allocations and complexity.Servlet3HttpServerTracer
andJakartaServletHttpServerTracer
, as it uses too many different Servlet API classes to reasonably cover with generics.