Rest Template Span - no parent Transaction

Kibana/Elasticsearch version:
Stack 7.17.0

APM Agent language and version:
1.28.4 java

Original install method (e.g. download page, yum, deb, from source, etc.) and version:
Download page and local setup

Is there anything special in your setup?

We use third-party software components

Description of problem


I have problem that REST calls by Spring template are not captured by APM Agent in our application.
This application use third-party software component for messaging. This part of code is not Instrumented by java APM Agent. In some places this messaging system make REST calls by RestTemplate. Instrumentation in apm-spring-resttemplate is executed, but Span is not created because, previously no parent Transaction was created.

What I want to achieve is that Transaction will be created only when REST call is executed.

Question is what I can do to fix this ?

I think about own plugin that will Instrumented this custom messaging library. Problem is that Transaction will be created for all messages, it does not matter if there is REST call or not (we want track only REST calls).

Other idea is create own plugin that will Instrument co.elastic.apm.agent.resttemplate.SpringRestTemplateAdvice and create Transaction before Advice will be lunched. I can create Transacion before SpringRestTemplateAdvice.beforeExecute() is executed but I don know how to deactivate created Transaction after SpringRestTemplateAdvice.afterExecute(). To handle "SpringRestTemplateAdvice.beforeExecute()" to create and active Transaction and "SpringRestTemplateAdvice.afterExecute()" to deactivate Transaction I need 2 different Advice class and I don't know how to transfer created Transaction between them. Maybe you can suggest something ?

Thank you for help!

If you instrument the custom messaging, why can't you identify whether the message is a REST call during the instrumentation and then only create a transaction in those cases?

When instrument messaging component, Im not able to know if REST will be used or not.

Messaging component handle many different queue. Some of them use SOAP, Kafka , DB, REST call etc. To handel only REST I need to create seperated plugin for specyfic queue. Any new queue will require new plugin.

I'm sorry, I don't really understand the setup. Somewhere at some point the message is defined as a REST component? At that point you can complete a transaction?

Regardless, for the second part, I think you're looking for something like we do here apm-agent-java/ at 3f21b03f8bb90312292397d54b58f517e27ae61b · elastic/apm-agent-java · GitHub - using a map to hop across asynchronous executions

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