-
Notifications
You must be signed in to change notification settings - Fork 349
Restrict freemarker ObjectWrapper instrumentation to 2.3.24+ #12117
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: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| package datadog.trace.instrumentation.freemarker24; | ||
|
|
||
| import static datadog.trace.agent.tooling.bytebuddy.matcher.ClassLoaderMatchers.hasClassNamed; | ||
| import static datadog.trace.agent.tooling.bytebuddy.matcher.HierarchyMatchers.implementsInterface; | ||
| import static datadog.trace.agent.tooling.bytebuddy.matcher.NameMatchers.named; | ||
| import static net.bytebuddy.matcher.ElementMatchers.returns; | ||
|
|
@@ -29,6 +30,14 @@ public ObjectWrapperInstrumentation() { | |
| super("freemarker"); | ||
| } | ||
|
|
||
| static final ElementMatcher.Junction<ClassLoader> VERSION_POST_2_3_24 = | ||
| hasClassNamed("freemarker.cache.ByteArrayTemplateLoader"); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a custom Useful? React with 👍 / 👎. |
||
|
|
||
| @Override | ||
| public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() { | ||
| return VERSION_POST_2_3_24; | ||
| } | ||
|
|
||
| @Override | ||
| public String hierarchyMarkerType() { | ||
| return "freemarker.template.ObjectWrapper"; | ||
|
|
||
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.
When this instrumentation is registered,
classLoaderMatcher()is invoked only once, so caching its result inVERSION_POST_2_3_24adds static state and constant-pool bloat without reuse.docs/instrumentation_design_guidelines.mdexplicitly requires one-shot matcher values to be constructed and returned directly; inlinehasClassNamed(...)inclassLoaderMatcher()instead.AGENTS.md reference: AGENTS.md:L40-L44
Useful? React with 👍 / 👎.