Skip to content

Commit 10ee220

Browse files
authored
Use JSP path name as transaction name (#751)
rather than the name of the generated servlet closes #429
1 parent 9515ec7 commit 10ee220

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

apm-agent-plugins/apm-servlet-plugin/src/main/java/co/elastic/apm/agent/servlet/ServletTransactionHelper.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public class ServletTransactionHelper {
6363
@VisibleForAdvice
6464
public static final String ASYNC_ATTRIBUTE = ServletApiAdvice.class.getName() + ".async";
6565
private static final String CONTENT_TYPE_FROM_URLENCODED = "application/x-www-form-urlencoded";
66+
public static final WildcardMatcher ENDS_WITH_JSP = WildcardMatcher.valueOf("*.jsp");
6667

6768
private final Logger logger = LoggerFactory.getLogger(ServletTransactionHelper.class);
6869

@@ -197,7 +198,8 @@ private void doOnAfter(Transaction transaction, @Nullable Throwable exception, b
197198
}
198199

199200
void applyDefaultTransactionName(String method, String servletPath, @Nullable String pathInfo, Transaction transaction) {
200-
if (webConfiguration.isUsePathAsName()) {
201+
// JSPs don't contain path params and the name is more telling than the generated servlet class
202+
if (webConfiguration.isUsePathAsName() || ENDS_WITH_JSP.matches(servletPath, pathInfo)) {
201203
// should override ServletName#doGet
202204
StringBuilder transactionName = transaction.getAndOverrideName(PRIO_LOW_LEVEL_FRAMEWORK + 1);
203205
if (transactionName != null) {

0 commit comments

Comments
 (0)