Skip to content

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

Merged
merged 17 commits into from
Dec 14, 2020

Conversation

ziquanmiao
Copy link
Contributor

PR to extend support of DD_TRACE_METHODS configuration to support wildcards in method calls

EX: ClassName[*]

@ziquanmiao ziquanmiao requested a review from a team as a code owner December 7, 2020 20:40
@ziquanmiao ziquanmiao changed the title Ziquan/ddtrace methods Extend DD_TRACE_METHODS to support wildcarded method argument Dec 9, 2020
@@ -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.*;
Copy link
Contributor

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 ...

Copy link
Contributor

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)

Copy link
Contributor

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?

Copy link
Contributor Author

@ziquanmiao ziquanmiao Dec 10, 2020

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 .\\$]+";
Copy link
Contributor

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()));
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor

@mcculls mcculls left a 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){
Copy link
Contributor

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 ?

Copy link
Contributor Author

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()));
Copy link
Contributor

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

@ziquanmiao ziquanmiao requested a review from lpriima December 11, 2020 21:22
Copy link
Contributor

@bantonsson bantonsson left a 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.

@ziquanmiao ziquanmiao merged commit feed497 into master Dec 14, 2020
@ziquanmiao ziquanmiao deleted the ziquan/ddtrace_methods branch December 14, 2020 20:35
@github-actions github-actions bot added this to the 0.70.0 milestone Dec 14, 2020
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.

5 participants