Remove spring DispatcherServlet from transactions

Hi,

I have APM setup on a local server, and my agents are installed on some applications that are springboot. Because of this when I look at the transactions page for my app I only see 2 transactions;

DispatcherServlet#doGet
DispatcherServlet#doPost

And all of the relevent methods that I want to see on the transactions page is nested underneath those.

What I would like is to not show this top level DispatcherServlet on the transactions page, but instead the method that comes after that.

Any help is appreciated,
Thanks!

Hi and welcome to the forum :tada:

Please provide this additional info:

  1. What Spring MVC version are you using?
  2. If possible, some sample code of your controllers
  3. Agent setup and configuration you use
  4. Set log_level to DEBUG and upload the log

Thanks,
Eyal

Thanks for your response, here are the details

Spring version in use

		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.0.4.RELEASE</version>

My agent setup is as follows, have been trying different configs to try and get the result I want, but currently have got it set to something basic

java -javaagent:C:\Users\me\Desktop\Elastic\javaagents\my-app-elastic-apm-agent-1.6.1.jar -Delastic.apm.application_packages=com.my.Services.myService -Delastic.apm.server_urls=http://localhost:8200 -Delastic.apm.trace_methods=com.my.Services.myService#* -Delastic.apm.log_level=DEBUG -jar myService-1.0.jar

I've put the debug of the agent startup here

....

Can you provide a code sample of you controllers? Which annotations do you use within them?

Also, the log you uploaded is very partial- covers less than 4 seconds

Here's an example of one of our controllers

Thanks. Can you upload a full debug log?

Hi,

Sorry yes, I've added debug from agent/server startup and going through to a few minutes after startup

...

Thanks.
What are the non-sprint annotations?
If possible, please add your AbstractResource as well (and further superclasses if any)- I want to see if there's any inheritance related.

The abstract class look largely the same

So far I fail to reproduce. In addition, I don't see a reason why it shouldn't work in logs- I see the SpringTransactionNameInstrumentation being applied as expected.

So, few more questions:

  1. Does the Abstract resource have class annotations as well?
  2. Can you explain what the TagResource inherits from the AbstractResource?
  3. What is the Spring MVC version you are using (ie the version from the spring-mvc-<version> jar)?

@ethranes Are you using Spring WebFlux?

One option is that the transaction name is set by a different thread than the one creating it.
Please try out this snapshot diagnostic build. Set log_level=TRACE, make sure it is fully started and make a few requests to reproduce the problem.

I hope this helps finding the issue.
Thanks.

abstract methods have the same annotations as the tag class. the tagresource class inherits more simple request mapping from the abstract class such as

@RequestMapping(value = ""
@RequestMapping(value = "/{id}"

the reason being that multiple classes will use these more common requestmapping, so their shared between a number of resources.

I wasn't able to download that build that you linked, it's linking to a webpage and saying not found.

Please try this one then.

Regarding inheritance- so TagResource's methods inherit @RequestMapping settings from the AbstractResource class? From AbstartResource's methods it overrides? From both?

TagResources methods will only be used if they are not first found in the AbstractResource.

I tried the updated java agent, but it doesn't change much, I still have the issue,

only dispatcherservlet is visible on the transactions page

elas1

and then it's only in the drilldown that I see the methods that should be at the transaction level

The agent I provided is not for fixing the problem, it is for analysing it.
Set log_level=TRACE, make sure your app is fully started and make a few requests to reproduce the problem. Then upload the log.

In addition, please describe how you installed the agent and provide the exact configuration you used for it (ie the relevant part of the script or the command line).

Lastly, please answer- are you using Spring WebFlux or any other component worth mentioning?

Here's the elastic log using trace level with the javaagent that you supplied, I only gave the first 10000 lines.

...

My agent installation is done via the following command at the moment, have tried a number of variations but this is what I have right now

java -javaagent:C:\Users\my\Desktop\Elastic\javaagents\elastic-apm-agent-1.7.1-SNAPSHOT-app.jar -Delastic.apm.service_name=my-App -Delastic.apm.log_level=TRACE -Delastic.apm.log_file=AGENT_HOME/logs/elastic-apm.log -Delastic.apm.application_packages=com.my -Delastic.apm.server_urls=http://localhost:8200 -Delastic.apm.trace_methods=com.my.services.# -jar myService-1.0.jar

Not using anything like Spring Webflux

Just for closure on this, I was able to get a resolution to my issue. I had been trying to use the following flag for disabling instrumentation;

disable_instrumentations=dispatcher-servlet

as it seemed the most relevent

However after playing with different combinations of properties for a while, I was able to unmask my methods from the dispatcher servlet by using this property instead;

disable_instrumentations=servlet-api

Unsure of the differences between them, but am happy that I'm able to move on to other elastic setup after spending a while on this.

Thanks for all your help.

Sorry for not following up on this, got slipped...
So, did you eventually get transaction named something like ControllerName#methodName?

Yeah pretty much, we also have trace methods on, so we're now getting className#methodName