-
Notifications
You must be signed in to change notification settings - Fork 1k
Add library instrumentation for servlet #15473
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
base: main
Are you sure you want to change the base?
Conversation
| @@ -0,0 +1,43 @@ | |||
| plugins { | |||
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 renamed testing to javaagent-testing for some reason this file didn't register as being moved :(
|
|
||
| /** Sets the status extractor for server spans. */ | ||
| @CanIgnoreReturnValue | ||
| public ServletTelemetryBuilder setStatusExtractor( |
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.
Currently ServletRequestContext is in internal package we have to either move it out of the internal or alternatively we could change the signature to UnaryOperator<SpanStatusExtractor<HttpServletRequest, HttpServletResponse>>. The wrappers are there mostly so we could share code between servlet 3 & 5 instrumentations. ServletResponseContext has some fields but ServletRequestContext doesn't have any and is probably there only for symmetry. If we don't use the wrappers in the signature then the downside is that conversion will be needed
builder.setStatusExtractor(
inputExtractor -> {
SpanStatusExtractor<HttpServletRequest, HttpServletResponse> outputExtractor =
statusExtractor.apply(
(spanStatusBuilder, request, response, error) ->
inputExtractor.extract(
spanStatusBuilder,
new ServletRequestContext<>(request),
response == null ? null : new ServletResponseContext<>(response),
error));
return (spanStatusBuilder, requestContext, responseContext, error) ->
outputExtractor.extract(
spanStatusBuilder,
requestContext.request(),
responseContext == null ? null : responseContext.response(),
error);
});@trask which way would you prefer?
| jvmArgs("-XX:+IgnoreUnrecognizedVMOptions") | ||
| } | ||
|
|
||
| if (findProperty("testLatestDeps") as Boolean) { |
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.
not using otelJava because that would apply to the main source too which would break the instrumentation for libraries that only work with java 8 when tests are run with -PtestLatestDeps=true. The same approach could be used to get rid of the javaagent-testing module and move the tests back to javaagent.
Supersedes #15188