-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Simplify instrumenter and tests #118493
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
Simplify instrumenter and tests #118493
Conversation
This commit simplifies the entitlements instrumentation service and instrumenter a bit. It especially removes some repetition in the instrumenter tests.
|
Pinging @elastic/es-core-infra (Team:Core/Infra) |
| var classesToTransform = checkMethods.keySet().stream().map(MethodKey::className).collect(Collectors.toSet()); | ||
|
|
||
| inst.addTransformer(new Transformer(INSTRUMENTER_FACTORY.newInstrumenter(checkMethods), classesToTransform), true); | ||
| Instrumenter instrumenter = INSTRUMENTER_FACTORY.newInstrumenter(EntitlementChecker.class, checkMethods); |
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.
Is there no need to reference Java23EntitlementChecker anymore?
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.
Oof, looks like we already lost this. I'll fix in a followup, but I think we can still use the Class object here, we will want to do Class.forName anyways
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.
Note that we were already doing Class.forName inside the instrumenter. We are just making it more explicit here.
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.
OK, but still, I do not see a way to load Java23EntitlementChecker in the new code. And I wonder if referencing a class directly (instead by name) could be an issue here (for JDK 22, for example).
I agree, using the Class object is nicer, but does it work?
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.
In a followup I will change this back to using a helper method. In the case of Java 23, it will use Class.forName to get the Class object, from a string. In the default case it will use the .class as it does here. In either case, we will pass in the Class object. That's what InstrumentationService was doing internally anyways.
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.
Sounds like a good plan, thank you for clarifying.
ldematte
left a comment
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.
Changes looks good, thanks for the cleanup!
💚 Backport successful
|
This commit simplifies the entitlements instrumentation service and instrumenter a bit. It especially removes some repetition in the instrumenter tests.
This commit simplifies the entitlements instrumentation service and instrumenter a bit. It especially removes some repetition in the instrumenter tests.