Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package datadog.trace.instrumentation.servlet3;

import static datadog.trace.api.telemetry.LogCollector.EXCLUDE_TELEMETRY;

import datadog.context.Context;
import datadog.trace.api.ClassloaderConfigurationOverrides;
import datadog.trace.bootstrap.instrumentation.api.AgentPropagation;
Expand All @@ -10,6 +12,8 @@
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Servlet3Decorator
extends HttpServerDecorator<
Expand All @@ -21,6 +25,7 @@ public class Servlet3Decorator
UTF8BytesString.create(DECORATE.operationName());
public static final String DD_CONTEXT_PATH_ATTRIBUTE = "datadog.context.path";
public static final String DD_SERVLET_PATH_ATTRIBUTE = "datadog.servlet.path";
private static final Logger LOGGER = LoggerFactory.getLogger(Servlet3Decorator.class);

@Override
protected String[] instrumentationNames() {
Expand Down Expand Up @@ -64,7 +69,15 @@ protected String peerHostIP(final HttpServletRequest httpServletRequest) {

@Override
protected int peerPort(final HttpServletRequest httpServletRequest) {
return httpServletRequest.getRemotePort();
try {
return httpServletRequest.getRemotePort();
} catch (AbstractMethodError e) {
LOGGER.debug(
EXCLUDE_TELEMETRY,
"Method not implemented when trying to get the request remote port",
e);
return 0; // 0 will be handled as `no port` by the caller
}
}

@Override
Expand Down
Loading