-
Notifications
You must be signed in to change notification settings - Fork 235
[Bugfix] Fix JMX merging logic to append multiple jvm configurations #1870
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
base: main
Are you sure you want to change the base?
Conversation
@@ -34,6 +34,9 @@ func mergeMap(sourceMap map[string]interface{}, resultMap map[string]interface{} | |||
for key, value := range sourceMap { | |||
if rule, ok := mergeRuleMap[key]; ok { | |||
rule.Merge(sourceMap, resultMap) | |||
} else if key == "jmx" { |
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.
Can we make this more general? Can we verify if we're looking at a list and then attempt to merge the list instead of specifying "jmx"
specifically?
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.
But then how would the append-config look when objects are used instead of an 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.
I think we can have two cases: 1) two arrays and 2) an array and an object. We could set up two conditions that check for each case and we can implement logic to merge an array and an object together (if we don't have that.)
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.
added an allowlist, not sure the best way to detect the case where we are merging two jmx objects and turn it into an array.
Right now I have it so that we have multiple different cases:
- Merging two jvm sections which are maps, if both are identical we only have a single configuration
- Merge two jvm sections which are maps, they are not identical -> have an array with two jvm objects
- Merge one jvm section that is an array with a map that are not identical -> two jvm objects in an array
- Merge two jvm sections which are arrays, they are not identical -> two jvm objects in array
- Merge two jvm sections which are arrays, they are identical -> an array with a single object
Description of the issue
Currently if you try to use the "append-config" action on two configurations that have separate JVM configurations, it will fail.
Kafka Config:
Tomcat config:
I expect this to merge the jvm configurations to this valid config:
Description of changes
Modify the
mergeMap
function in the translator to add a conditional if we see a "jmx" configuration, then merge the incoming jmx config into the list.License
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Tests
Added unit test and manual testing. I appended 4 jmx configurations and see the otel receivers populated:
Requirements
Before commiting your code, please do the following steps.
make fmt
andmake fmt-sh
make lint
Integration Tests
To run integration tests against this PR, add the
ready for testing
label.