JMX metrics for Tomcat with 'Tomcat' JMX domain #10115
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When using the JMX Insights feature with a spring-boot application, I noticed that the JMX metrics were not captured when setting
OTEL_JMX_TARGET_SYSTEM=tomcat
.The problem is that the JMX MBeans are registered with
Tomcat
domain instead ofCatalina
, and thus the rules do not match.With standalone tomcat servers (tested latest 8.5, 9.0.x and 10.x), the JMX domain is always
Catalina
. I am not an expert in Tomcat internals but this comes from the implementation oforg.apache.catalina.util.LifecycleMBeanBase#getDomain
that returns any sub-class implementation oforg.apache.catalina.util.LifecycleMBeanBase#getDomainInternal
and falls back toCatalina
.Searching for the
Tomcat:
string in the Tomcat codebase seems to indicate that this is quite a common value, for example here in tests.While we could use a wildcard in the rules for the JMX domain, for example
*:type=GlobalRequestProcessor,name=*
in place ofCatalina:type=GlobalRequestProcessor,name=*
, that might also introduce false-positives if other application servers also have similar named MBeans, thus duplication sounds the best compromize here.