Skip to content
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

Class annotation to trace lambda methods #274

Merged
merged 9 commits into from
Apr 29, 2021

Conversation

GDownes
Copy link
Contributor

@GDownes GDownes commented Apr 13, 2021

Overview

New class annotation TraceLambda. Marking a class with the TraceLambda annotation will instruct the New Relic agent to automatically annotate lambda methods within the marked class with a Trace annotation.

Testing

Added unit tests to cover TraceLambda usage scenarios.
Deploy updated agent locally and reviewed traces in New Relic One.

Checks

[x] Are your contributions backwards compatible with relevant frameworks and APIs? Yes
[x] Does your code contain any breaking changes? Please describe. No
[x] Does your code introduce any new dependencies? Please describe. No

@GDownes GDownes changed the title Lambda trace Class annotation to trace lambda methods Apr 13, 2021
@GDownes GDownes closed this Apr 29, 2021
@GDownes GDownes reopened this Apr 29, 2021
@GDownes GDownes changed the base branch from main to java8-tests April 29, 2021 09:54
@GDownes GDownes changed the base branch from java8-tests to main April 29, 2021 09:55
Assert.assertEquals(metricName, traceAnnotation.getValue().metricName());
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my local testing, I tried a poorly named method called notlambda$doingWork$1(). It's plain method, no lambdas.

As expected, this did not match 😄 Would there be value in a test that we don't match on just lambda?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Xi,
The default behaviour is to run the following regex "^\$?(lambda|anonfun)\$(?.*)" against the names of all the static methods in the marked class. Only static methods with names matching the pattern will match. The default pattern aims to cover Java and Scala lambda expressions as they are compiled to static methods.

Copy link
Contributor

@XiXiaPdx XiXiaPdx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GDownes LGTM! I had one curiosity regarding the tests and I provided a comment for it.

@XiXiaPdx
Copy link
Contributor

Running AITs internally, hold please

@XiXiaPdx
Copy link
Contributor

Internal AITs look good, merging - https://javaagent-build.pdx.vm.datanerd.us/job/JavaAgent_PR_AIT/68/

@XiXiaPdx XiXiaPdx merged commit 859bbad into newrelic:main Apr 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants