Spring Boot instrumentation only discovers @Controller classes

Hi all,

We are evaluating Elastic APM as the APM solution for a newly built project at a customer. The experience so far has been great, with a small nuance.

We are using Spring Boot with a three-tier approach: @Controller, @Service and @Repository annotated classes. To my surprise, only the rest endpoints (@Controller) get discovered. To add additional spans, we need to add them manually via the API (tested, works great). We've tried to configure the flag elastic.apm.trace_methods to monitor all methods of all classes of the base package but does not seem to work.

Are we doing something wrong or is this the expected behaviour?

Kibana version: 7.0.0

Elasticsearch version: 7.0.0

APM Server version: 7.0.0

APM Agent language and version: Java 1.6.0

Original install method (e.g. download page, yum, deb, from source, etc.) and version: Docker running on Kubernetes

Fresh install or upgraded from other version?: Fresh install

Hi and thanks for evaluating Elastic APM :slight_smile:

Yes, this is expected. There are no spans created for @Service or @Repository methods by default. So trace_methods should be the way to go for you.

Could you send me the debug logs of the startup up until the first request is completed?

Thanks,
Felix

Hi Felix,

Thank you so much for such a speedy reply. When I enabled it it shows some more data that I will have to anonymise. Will prepare a sandboxed application that will be easier to debug this on and share the logs with you as soon as I can. Thanks again!

Sounds like a plan. In the meantime, could you send me your configuration for trace_methods? Maybe I can spot something obvious there.

We've temporarily worked around this by setting the following trace_methods, but we would also prefer a way to specify all @Service's public methods similar to how @Controller methods are automatically captured.

-Delastic.apm.trace_methods="public com.myorg.*ServiceImpl#*"

I thought of building an solution with AOP to target the methods, but couldn't wrap my head around the approach.

Hi,

Sorry for the delay to your such quick note Felix.

We are using something like this:

-Delastic.apm.trace_methods=com.example.*

Question: does the wildcard match sub packages? We are using our base package here, but then we have .service, .repository, etc. This could potentially be the issue if we're trying to use something that does not work the way we are assuming.

Yes, sub-packages are matched with a wildcard as well. See also https://www.elastic.co/guide/en/apm/agent/java/current/config-core.html#config-trace-methods

Hi all,

Sorry for the late reply once again, but many other topics came in. I think we might have done something wrong in our initial service, because on this second that I built for debugging purposes the trace_methods work!

Thanks for your help! (We're happy :slight_smile:)

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.