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

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 ?

Hi and thanks for using the Java agent :slight_smile:

Which http client are you using for that? We currently support these: Supported technologies | APM Java Agent Reference [1.x] | Elastic

The next version will also support OkHttp and HttpUrlConnection.

Best,
Felix

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.

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

Yes Felix , its Spring web MVC 4.3.5

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?

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.*

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

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 .

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

See Here for valid matchers: Core configuration options | APM Java Agent Reference [1.x] | Elastic

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.

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