Skip to content

Conversation

@laurit
Copy link
Contributor

@laurit laurit commented Nov 27, 2025

Supersedes #15188

@@ -0,0 +1,43 @@
plugins {
Copy link
Contributor Author

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(
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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.

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.

1 participant