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
Expand Up @@ -5,12 +5,9 @@
import datadog.trace.bootstrap.instrumentation.api.UTF8BytesString;
import datadog.trace.bootstrap.instrumentation.decorator.BaseDecorator;
import java.net.URI;
import java.net.URISyntaxException;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.HttpJspPage;
import org.apache.jasper.JspCompilationContext;
import org.slf4j.LoggerFactory;

public class JSPDecorator extends BaseDecorator {
public static final CharSequence JSP_COMPILE = UTF8BytesString.create("jsp.compile");
Expand Down Expand Up @@ -68,11 +65,14 @@ public void onRender(final AgentSpan span, final HttpServletRequest req) {
// HttpServletRequest#getRequestURL(),
// normalizing the URL should remove those symbols for readability and consistency
try {
span.setTag(
"jsp.requestURL", (new URI(req.getRequestURL().toString())).normalize().toString());
} catch (final URISyntaxException uriSE) {
LoggerFactory.getLogger(HttpJspPage.class)
.debug("Failed to get and normalize request URL: {}", uriSE.getMessage());
// note: getRequestURL is supposed to always be nonnull - however servlet wrapping can happen
// and we never know if ever this can happen
final StringBuffer requestURL = req.getRequestURL();
if (requestURL != null && requestURL.length() > 0) {
span.setTag("jsp.requestURL", (new URI(requestURL.toString())).normalize().toString());
}
} catch (final Throwable ignored) {
// logging here will be too verbose
}
}
}