I have some legacy servlet code. The APM agent creates transactions with names like MyClass#myMethod. I would like a more descriptive name. I would prefer not to change the servlet code, but I'm ok with adding a filter.
I've tried the onIncomingRequest technique in a servlet filter but I end up with two transactions: one that I create manually and one that's created automatically by the APM agent. The transactions don't seem to be linked in any way, even though one occurs in the context of the other.
This is my code:
Transaction transaction = ElasticApm.startTransactionWithRemoteParent(request::getHeader, null);
try (final Scope scope = transaction.activate()) {
transaction.setName(request.getHeader("myheader"));
transaction.setType(Transaction.TYPE_REQUEST);
chain.doFilter(request, response);
} catch (Exception e) {
transaction.captureException(e);
throw e;
} finally {
transaction.end();
}
Instead, I would like to skip the txn created by the APM agent, or at least make it a span of the one I create. I've tried excluding the package the servlet is in but it doesn't seem to make a difference.
How can I handle a situation like this?
thanks