-
Notifications
You must be signed in to change notification settings - Fork 300
Extend DD_TRACE_METHODS to support wildcarded method argument #2171
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
Conversation
...src/main/java/datadog/trace/instrumentation/trace_annotation/TraceConfigInstrumentation.java
Outdated
Show resolved
Hide resolved
@@ -2,7 +2,7 @@ | |||
|
|||
import static datadog.trace.agent.tooling.ClassLoaderMatcher.hasClassesNamed; | |||
import static datadog.trace.agent.tooling.bytebuddy.matcher.DDElementMatchers.safeHasSuperType; | |||
import static net.bytebuddy.matcher.ElementMatchers.named; | |||
import static net.bytebuddy.matcher.ElementMatchers.*; |
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 thought spotless check should fail on star imports ...
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's a limitation of spotless, but you can add a custom rule for this: diffplug/spotless#240 (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.
@ziquanmiao could you change this wildcard import to explicit imports of the used types?
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.
ill fix and explicitly import the ones I use
@@ -32,8 +32,9 @@ | |||
@AutoService(Instrumenter.class) | |||
public class TraceConfigInstrumentation implements Instrumenter { | |||
|
|||
static final String PACKAGE_CLASS_NAME_REGEX = "[\\w.\\$]+"; | |||
private static final String METHOD_LIST_REGEX = "\\s*(?:\\w+\\s*,)*\\s*(?:\\w+\\s*,?)\\s*"; | |||
static final String PACKAGE_CLASS_NAME_REGEX = "[\\w .\\$]+"; |
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.
This now accepts spaces in package/class names which doesn't sound right
.or(isEquals()) | ||
.or(isToString()) | ||
.or(isConstructor()) | ||
.or(isSynthetic())); |
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'd also add isFinalizer
because I've seen issues intercepting that in the past on other AOP systems
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.
and test that calls each of these method types and no span is created
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.
LGTM
void setName(String newName){ | ||
name = newName | ||
} | ||
void setHeight(int newHeight){ |
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.
Do getters suppose to be instrumented under '*' pattern or no ?
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 chatted with tyler about this --
if i didnt ignore getters/setters, then in the implementation would instrument custom groovy classes as well, so it was a question whether to write accommodations for groovy or ignore getters/setters and defer customers to our profiling product if they were interested in those methods
.or(isEquals()) | ||
.or(isToString()) | ||
.or(isConstructor()) | ||
.or(isSynthetic())); |
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.
and test that calls each of these method types and no span is created
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.
👍
Hey, @ziquanmiao since your PR is made up of many small commits, several which don't pass all the checks by themselves, would you mind either squashing them all before you merge the PR, or use the "Squash and merge" button? We are trying to ensure that every commit is a working commit, so things like git bisect
can be used to find regressions.
PR to extend support of DD_TRACE_METHODS configuration to support wildcards in method calls
EX:
ClassName[*]