-
Notifications
You must be signed in to change notification settings - Fork 867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JMX Metric Insight #6573
JMX Metric Insight #6573
Conversation
Solving open-telemetry#6131 (JMX Support).
Correcting a typo in a comment.
Using the latest version of snakeyaml. Version 1.30 had this vulnerability https://nvd.nist.gov/vuln/detail/CVE-2022-25857.
5dbb684
to
5f29c94
Compare
instrumentation/runtime-metrics/library/src/main/resources/jmx/rules/kafka-consumer.yaml
Outdated
Show resolved
Hide resolved
.../java/io/opentelemetry/instrumentation/javaagent/runtimemetrics/RuntimeMetricsInstaller.java
Outdated
Show resolved
Hide resolved
...library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/jmx/MetricService.java
Outdated
Show resolved
Hide resolved
...library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/jmx/MetricService.java
Outdated
Show resolved
Hide resolved
...c/main/java/io/opentelemetry/instrumentation/runtimemetrics/jmx/AttributeValueExtractor.java
Outdated
Show resolved
Hide resolved
...c/main/java/io/opentelemetry/instrumentation/runtimemetrics/jmx/AttributeValueExtractor.java
Outdated
Show resolved
Hide resolved
...cs/library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/jmx/BeanFinder.java
Outdated
Show resolved
Hide resolved
...cs/library/src/main/java/io/opentelemetry/instrumentation/runtimemetrics/jmx/BeanFinder.java
Outdated
Show resolved
Hide resolved
Thank you @jack-berg for the review and your comments! |
…strative purposes.
Thank you, @trask, for the review. I'm working on an update for the PR, I should have it ready later this week. |
…upported platforms. Introducing system property to control time interval between MBean discovery attempts. Code refactoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PeterF778 thanks for your patience with the slow reviews
...brary/src/main/java/io/opentelemetry/instrumentation/jmx/engine/AttributeValueExtractor.java
Outdated
Show resolved
Hide resolved
Renaming module 'jmx' to 'jmx-metrics'. Changing the syntax of the metric attributes retrieved from Mbean attributes. Editing docs and comments for better readability.
…ttribute'. Just within the README file.
My last commit changes the documentation for the YAML syntax, replacing |
I played around with a few possible changes to the yaml structure, with questionable results. 1. Changing
|
Thank you @trask for your experiments and suggestions. They all have merits, and I'll address them in the increasing order of my subjective agreement with them. Re: 3 Changing mapping from a map to a list It looks good, and is readable, but it does not allow a shortcut notations as demonstrated in the section Making shortcuts, with simplified one-line mapping from MBean attributes to metrics. I believe many users would appreciate such simplicity, even if only for experimenting with the available MBeans. Re: 1. Changing mapping to metric I think the key to understanding the essence of the proposed yaml schema for the metric rules is the realization that they provide a mapping from MBean attributes to OTEL metrics. Looking at
one does not necessarily see that this is a mapping. It looks like On the other hand, the originally proposed schema does not say that the anonymous key is an MBean attribute, but I thought it was an acceptable sacrifice to achieve that one-line mappings mentioned above. It did say Re: 4 Change attribute from a map to a list Modeling metric attributes as a list is a common mental shortcut, but they are not really a list of pairs (name, value), but a mapping from names to values. A nuance for some, I know ... BTW, point 3 has the same minor flaw. Also I believe that in most cases there will be just one element in such a metric attribute list. Many of the metrics we encountered in our metric modeling so far follow a pattern in which a rule has one metric attribute defined globally (for all MBean attributes) and one specific to each metric. Re: 2 Change attribute to metricAttribute It is longer than I would like. We went from Please let me know your thoughts on the above. Thanks! |
👍 and I think eliminates 3. Changing mapping from a map to a list as well I think that just leaves the One additional thought about the current Interestingly, I find the The top-level
any other thoughts for making this part clearer? |
…()" instead of "attr()", and "const(STRING)" instead of "STRING".
.../src/main/java/io/opentelemetry/instrumentation/javaagent/jmx/JmxMetricInsightInstaller.java
Outdated
Show resolved
Hide resolved
.../src/main/java/io/opentelemetry/instrumentation/javaagent/jmx/JmxMetricInsightInstaller.java
Outdated
Show resolved
Hide resolved
.../src/main/java/io/opentelemetry/instrumentation/javaagent/jmx/JmxMetricInsightInstaller.java
Outdated
Show resolved
Hide resolved
.../src/main/java/io/opentelemetry/instrumentation/javaagent/jmx/JmxMetricInsightInstaller.java
Outdated
Show resolved
Hide resolved
...n/jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/yaml/JmxConfig.java
Outdated
Show resolved
Hide resolved
...-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/MetricBanner.java
Outdated
Show resolved
Hide resolved
* | ||
* <p>Objects of this class are immutable. | ||
*/ | ||
public class MetricBanner { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not following the association with the word Banner?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The class encapsulates metric properties which help identify/explain it to end users via a hypothetical UI, before looking at the metric values or other technical details. They represent the facet of the metric which will most likely be looked at first when browsing a list of metrics. Other possible names considered were MetricTitle
or MetricManifest
. What name would you propose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe MetricInfo
?
...jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/MetricDef.java
Outdated
Show resolved
Hide resolved
.../jmx-metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/BeanPack.java
Outdated
Show resolved
Hide resolved
...trics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/MetricAttribute.java
Outdated
Show resolved
Hide resolved
...rary/src/main/java/io/opentelemetry/instrumentation/jmx/engine/MetricAttributeExtractor.java
Outdated
Show resolved
Hide resolved
private final BeanPack beans; | ||
|
||
// Describes how to get the metric values and their attributes, and how to report them | ||
private final MetricExtractor[] metricExtractors; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we typically use List<> over array unless its super perf sensitive, or dealing with an inherently array-based underlying api
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constructors for MetricDef
and a number of other classes take varargs which are translated directly to arrays. And the varargs are there to make the direct access to those classes easier when attempting to hard-code some JMX rules - with the examples of that missing from the first PR.
private final BeanAttributeExtractor attributeExtractor; | ||
|
||
// Defines the Measurement attributes to be used when reporting the metric value. | ||
private final MetricAttribute[] attributes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar for List over array
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the same case - the constructor uses varargs, so internal representation as array is a natural fit.
...metrics/library/src/main/java/io/opentelemetry/instrumentation/jmx/engine/AttributeInfo.java
Outdated
Show resolved
Hide resolved
...ibrary/src/test/java/io/opentelemetry/instrumentation/jmx/engine/AttributeExtractorTest.java
Outdated
Show resolved
Hide resolved
* | ||
* <p>Objects of this class are immutable. | ||
*/ | ||
public class MetricBanner { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe MetricInfo
?
committed by mistake This reverts commit 0c93fe5.
2ae7eda
to
c509c8b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @PeterF778, this is a great addition!
Wow! Amazing to see this merged, thank you @PeterF778 & @trask ! |
@PeterF778 I assume that thread/memory metrics aren't given a "target" is because they're already covered in runtime-metrics. I suggest mentioning this in the readme to make it more clear. |
Yes, several JVM metrics (threads/memory/GC) as well as other types of metrics are covered independently by the agent. Where in the readme file would you suggest putting a note about it? |
|
||
To control the time interval between MBean detection attempts, one can use the `otel.jmx.discovery.delay` property, which defines the number of milliseconds to elapse between the first and the next detection cycle. JMX Metric Insight may dynamically adjust the time interval between further attempts, but it guarantees that the MBean discovery will run perpetually. | ||
|
||
## Predefined metrics |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PeterF778 this section is where I would suggest adding a reference/link to the runtime metrics, otherwise it seems like an oversight for people that are looking for jmx memory metrics but don't know that runtime metrics are separate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I see your point. Could you please create an issue (https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues) for this so it gets tracked?
Solving #6131 (JMX Support).