Request spanning across multiple packages are not consolidated into a single transaction - Java agent

#1

APM Server version: 6.5.0

APM Agent language and version: Java Agent 1.3.0

Ours is a application with multiple modules residing in different packages ,we use web services where each HTTP request spans across different packages to get the desired data.

I have included the java agent and everything works fine when i include a single package in Trace method , but while including multiple packages to drill down to the actual performance bottle neck , the request that spans across multiple packages are not consolidated into a single transaction , but are sensed as independent custom methods .How can i consolidate the methods across different packages into a single request transaction ?

(Felix Barnsteiner) #2

Hi and thanks for using the Java agent :slight_smile:

Which http client are you using for that? We currently support these: https://www.elastic.co/guide/en/apm/agent/java/current/supported-technologies-details.html#supported-networking-frameworks

The next version will also support OkHttp and HttpUrlConnection.

Best,
Felix

#3

Hi Felix ,

        Thanks a lot for the quick reply :)  we are using Apache Http Client - 4.5.2 , which is supported by the java agent . As i mentioned i am able to get the correct readings and spans when the request spans within a single package (the spans are consolidated into single request) . The spans are not consolidated into single request only when the http request spans across multiple packages as a part of cross module communication.Please let me know if more detailed information is required.
(Felix Barnsteiner) #4

Which web framework are you using to handle the HTTP requests? Is that one of the supported ones?

#5

Yes Felix , its Spring web MVC 4.3.5

(Stephen Brown) #6

Hi and thanks too for using the Java Agent

Are

"the request that spans across multiple packages "

spanning multiple controllers?

Could you provide your agent configuration parameters including the trace_methods parameter?

Could you also provide the package names that you are trying to trace?

#7

Hi Stephen ,

          Thanks for the reply . Initially to set the context , our package structure is something that looks like this ,

com
	abc
		proj
			core
				user
					bo
						UserBO.java
						Impl
							UserImpl.java
					dao
						userDao.java
						Impl	
							UserDaoImpl.java
						Mapper
							UserMapper.java
						Entity
							UserEntity.java
					service
						UserService.java
					web
						UserController.java
				role
					bo
						RoleBO.java
						Impl	
							RoleBOImpl.java
					dao
						RoleDao.java
						Impl
							RoleDaoImpl.java
						Mapper
							RoleMapper.java
						Entity
							RoleEntity.java
					service
						RoleService.java
					web
						RoleController.java
			common
				work
					bo
						WorkBO.java
						Impl
							WorkBOImpl.java
					dao
						WorkDao.java
						Impl
							WorkDaoImpl.java
						Mapper
							WorkMapper.java
						Entity
							WorkEnity.java
					service
						WorkService.java
					web
						WorkController.java

Implying - com.abc.proj.core.user.bo.impl.UserBOImpl.java
                   com.abc.proj.core.user.web.UserController.java
                   com.abc.proj.common.work.service.WorkService.java

I would like to get the span for all the java files involved in a request . A request can invoke the java files in multiple package (ie user , role, work ).The spans are not consolidated into a single transaction when the request invokes java files from multiple packages (ie user and role or user and work).The consolidation happens correctly when the request invokes java classes from a single package say user.My trace method and application package parameters are given below ,

trace_methods=com.abc.proj.core.user.*#*,com.abc.proj.core.role.*#*,com.abc.proj.common.work.*#*

application_packages= com.abc.proj.*

(Stephen Brown) #8

A couple more questions / suggestion.

I am still unclear if the request spans multiple controllers or just a single controller?

If you take trace_methods completely out are the spans consolidated?

can you try trace_methods="com.abc.proj.*#*"

It should recurse ...note the quotes

How are you setting on the command line?... from a startup script, you may need to escape the \#?

And if you look at the apm-server logs on start up you should see an error if does not parse the trace_methods correctly

#9

Hi Stephen ,

           Replies to the queries and suggestions .

I am still unclear if the request spans multiple controllers or just a single controller?

The request spans just a single controller ,because cross-package invocation happens at service layer and not through the controller.

And if you look at the apm-server logs on start up you should see an error if does not parse the trace_methods correctly

Not getting any errors on log with the following trace methods
trace_methods=com.abc.proj.core.user.#,com.abc.proj.core.role.#,com.abc.proj.common.work.#

can you try trace_methods="com.abc.proj.*#*"

Throws an error stating invalid trace methods.

If you take trace_methods completely out are the spans consolidated?

No Stephen , its not happening.

How are you setting on the command line?... from a startup script, you may need to escape the \# ?

Sorry dint get this .

(Stephen Brown) #10

Huh it should not.... that is a valid matcher. You can take out the quotes.

See Here for valid matchers: https://www.elastic.co/guide/en/apm/agent/java/current/config-core.html#config-trace-methods

your supplied matchers do not look correct to me see the document they should require *#* not just a #
trace_methods=com.abc.proj.core.user.#,com.abc.proj.core.role.#,com.abc.proj.common.work.#

If you upgrade to 1.4 you can try

trace_methods=com.abc.proj.*

My question at the end was how are you starting the application? From the command line? if so you may need to escape the # or quote it.

(system) closed #11

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