Skip to content
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

Integration test activemq #1497

Merged
merged 26 commits into from
Oct 18, 2024

Conversation

robsunday
Copy link
Contributor

@robsunday robsunday commented Oct 15, 2024

Primary goal of this PR is to use JMX Metric Insight to gather ActiveMQ JMX properties while preserving compatibility with JMX Gatherer.

At the moment there are two lines of ActiveMQ product:

  • Classic
  • Artemis

This test covers Classic line. Artemis line have different set of JMX attributes, so it should have separate yaml and test (nice summary of differences is here: https://www.datadoghq.com/blog/activemq-architecture-and-metrics/). Artemis support may be included in the future.

Assertions in the ActiveMQ integration test are copied from opentelemetry-java/contrib/jmx-metrics while activemq.yaml is taken from opentelemetry-java-instrumentation/jmx-metrics (JMX Metric Insight)
Minor changes were appiled to both of them. These changes are described as comments in the files.

"activemq.consumer.count",
"The number of consumers currently reading from the broker.",
"consumers",
/* isMonotonic= */ false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[for reviewer] isMonotonic=false was added due to updatedDefinition of asserSumWithAttributes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all of the 3 metrics that are non-monotonic here I think it was probably a bug in the original test of the groovy version. The fact that they all have current in their description means that they should represent a value that can go up or down, and thus can't be monotonic.

"activemq.producer.count",
"The number of producers currently attached to the broker.",
"producers",
/* isMonotonic= */ false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[for reviewer] isMonotonic=false was added due to updatedDefinition of asserSumWithAttributes.

"activemq.connection.count",
"The total number of current connections.",
"connections",
/* isMonotonic= */ false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[for reviewer] isMonotonic=false was added due to updatedDefinition of asserSumWithAttributes.

@@ -58,6 +77,9 @@ public static void main(String[] args) {
} catch (IOException e) {
System.err.println("Unable to connect " + e.getMessage());
System.exit(2);
} catch (RuntimeException e) {
e.printStackTrace(System.err);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple printing Exception message is not enough here. We lose a lot of information regarding the issue. Stacktrace is better

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once we merge it will be good to update resources folder structure. I did not want to do too much in this PR.

return new GenericContainer<>(
new ImageFromDockerfile()
.withDockerfileFromBuilder(
builder -> builder.from("apache/activemq-classic:5.18.6").build()))
Copy link
Contributor Author

@robsunday robsunday Oct 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[for reviewer] Updated activemq docker image to the most recent ActiveMQ Classic version (from rmohr/activemq:5.15.9 used in JMX Metric Gatherer)

}

@SafeVarargs
static void assertSumWithAttributes(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[for reviewer] This override method is added to support 'monotonic' flag and metric attributes at he same time.

@robsunday robsunday marked this pull request as ready for review October 17, 2024 09:20
@robsunday robsunday requested a review from a team as a code owner October 17, 2024 09:20
@trask
Copy link
Member

trask commented Oct 17, 2024

@robsunday @SylvainJuge all good to merge here? thanks

@SylvainJuge
Copy link
Contributor

@trask yes, given there is no user of this yet there can't be any regression :-).

@trask
Copy link
Member

trask commented Oct 17, 2024

thanks, @robsunday mentioned on slack that he may push one more update, will wait for his confirmation

Comment on lines 28 to 29
.withCopyFileToContainer(
MountableFile.forClasspathResource("activemq/env"), "/opt/apache-activemq/bin/env")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a comment why we need to customize activemq/env? thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finally I got rid of this file at all

Co-authored-by: SylvainJuge <763082+SylvainJuge@users.noreply.github.com>
@github-actions github-actions bot requested a review from SylvainJuge October 18, 2024 07:24
@robsunday robsunday requested a review from trask October 18, 2024 08:25
@@ -10,11 +10,15 @@ rules:
mapping:
ProducerCount:
metric: producer.count
# Unit name inherited from activemq.groovy file.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor] for those adding a TODO to make sure we don't forget about this could be nice (we are more likely to look for TODOs than read current definitions YAML files).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually we are going to use original *.yaml files from JMX Insights, right? I think we may not need to update this file and added these comments for informational purposes only. But if you have different opinion then I can add TODOs :-), not a problem.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, those are likely to remain "as is", and regarding their location having them in a dedicated folder might also make sense when we reorganize but it's another topic.

I'm just trying to not to forget about this, but a TODO here is probably not the best choice, it's probably better to add this to the issue where we listed all the supported systems for feature parity: open-telemetry/opentelemetry-java-instrumentation#12158 so I've updated it to ensure we don't forget about it.

Comment on lines 29 to 30
// Overwrite default ActiveMQ configuration in order to let ActiveMQ use JMX options
// stored in $ACTIVEMQ_JMX_OPTS env variable defined below
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not for this PR, but do you know if there is a way to avoid adding the whole env file as an alternative ? For example could an env variable be used instead ? Or maybe as we are in a containers the JAVA_TOOL_OPTIONS might work as well.

Ideally if we don't have extra files to manage for those containers, the easier it gets to maintain them, even if I agree that this one does not seem very complicated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually a very good point. Replacing file with JAVA_TOOL_OPTIONS was trivial and worked. '''env''' file was used in jmx-metrics and ported here, but really was not needed.
Great suggestion!

Removed env file and use JAVA_TOOL_OPTIONS instead to pass JMX options to ActiveMQ
@github-actions github-actions bot requested a review from SylvainJuge October 18, 2024 09:37
@@ -30,7 +30,6 @@ protected GenericContainer<?> createTargetContainer(int jmxPort) {
"https://tomcat.apache.org/tomcat-9.0-doc/appdev/sample/sample.war",
"/usr/local/tomcat/webapps/ROOT.war")
.build()))
.withEnv("LOCAL_JMX", "no")
Copy link
Contributor Author

@robsunday robsunday Oct 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed for Tomcat.

@trask trask merged commit f8c7cb4 into open-telemetry:main Oct 18, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants