-
Notifications
You must be signed in to change notification settings - Fork 144
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
New Spring controller instrumentation modules #1675
Conversation
…c-java-agent into spring-controller-instr
settings.gradle
Outdated
@@ -340,6 +341,8 @@ include 'instrumentation:spring-webflux-6.0.0' | |||
include 'instrumentation:spring-webflux-5.0.0' | |||
include 'instrumentation:spring-webflux-5.1.0' | |||
include 'instrumentation:spring-webflux-5.3.0' | |||
include 'instrumentation:spring-webflux-controller-mappings-5.0.0' | |||
include 'instrumentation:spring-webclient-5.0' |
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.
Looks like you re added this webclient that I had moved as it was not in alphabetical order.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1675 +/- ##
============================================
+ Coverage 70.70% 70.74% +0.03%
+ Complexity 9929 9927 -2
============================================
Files 830 829 -1
Lines 39880 39861 -19
Branches 6030 6033 +3
============================================
+ Hits 28197 28199 +2
+ Misses 8960 8934 -26
- Partials 2723 2728 +5 ☔ View full report in Codecov by Sentry. |
if (NewRelic.getAgent().getLogger().isLoggable(Level.FINEST)) { | ||
NewRelic.getAgent() | ||
.getLogger() | ||
.log(Level.FINEST, "SpringControllerUtility::assignTransactionNameFromControllerAndMethodRoutes (6.0.0): calling transaction.setTransactionName to [{0}] " + |
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.
Was this 6.0.0 supposed to be the module version? This is in the 4.3.0 module.
if (NewRelic.getAgent().getLogger().isLoggable(Level.FINEST)) { | ||
NewRelic.getAgent() | ||
.getLogger() | ||
.log(Level.FINEST, "SpringControllerUtility::assignTransactionNameFromControllerAndMethod (6.0.0): " + |
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.
Same 6.0.0 here.
And ,
on the line below.
NewRelic.getAgent() | ||
.getLogger() | ||
.log(Level.FINEST, "SpringControllerUtility::assignTransactionNameFromControllerAndMethodRoutes (6.0.0): calling transaction.setTransactionName to [{0}] " + | ||
"with FRAMEWORK_HIGH and override false, txn {1}, ", txnName, AgentBridge.getAgent().getTransaction().toString()); |
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.
You already have the transaction here. Any reason to get it again from the API?
The log message is ending with ,
. This gives the impression that there would me more content on this log message. Was there supposed to be?
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'll address this in all 3 modules.
implementation("org.springframework:spring-web:4.3.0.RELEASE") | ||
testImplementation("org.jetbrains.kotlin:kotlin-stdlib:1.8.21") | ||
implementation("org.springframework:spring-webmvc:4.3.0.RELEASE") | ||
implementation('jakarta.servlet:jakarta.servlet-api:4.0.4') | ||
} | ||
|
||
jar { |
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 we still need the weave-violation-filter?
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 was going to create another issue to discuss this later. I don't know if it has any applicability outside of the spring controller stuff or not.
} | ||
|
||
@Test | ||
public void handleInternal_whenNoAnnotationPresent_namesTxnBasedOnControllerClassAndMethod() throws Exception { |
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 this the case of a RouterFunction?
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.
No, this checks the case of a controller method that has no Spring controller annotations at all (like actuator endpoints or error handlers).
|
||
//If this setting is false, attempt to name transactions the way the legacy point cut | ||
//named them | ||
boolean isEnhancedNaming = NewRelic.getAgent().getConfig().getValue("class_transformer.enhanced_spring_transaction_naming", false); |
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 could be a constant in SpringControllerUtility.
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'll address this in all 3 modules.
jar { | ||
manifest { attributes 'Implementation-Title': 'com.newrelic.instrumentation.spring-6.0.0', | ||
'Implementation-Title-Alias': 'spring_annotations', | ||
'Weave-Violation-Filter': 'METHOD_MISSING_REQUIRED_ANNOTATIONS,CLASS_MISSING_REQUIRED_ANNOTATIONS' } |
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.
Same for weave violation filter.
@@ -0,0 +1,193 @@ | |||
package com.nr.agent.instrumentation; |
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.
All tests are missing copyright.
@@ -0,0 +1,275 @@ | |||
/* | |||
* | |||
* * Copyright 2020 New Relic Corporation. All rights reserved. |
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.
Old copyright
@@ -0,0 +1,274 @@ | |||
/* | |||
* | |||
* * Copyright 2020 New Relic Corporation. All rights reserved. |
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.
Old Copyright
Overview
Resolves #1576
These instrumentation modules support proper transaction naming (route + HTTP method) of traditional annotated spring controllers as well as controllers that inherit annotations from interfaces, super classes or custom annotations. Check one of the README files in the PR for a full description.
spring-4.3.0: This module provides instrumentation for Spring Controllers utilizing Spring Web-MVC v4.3.0 up to but not including v6.0.0. (v6.0.0 instrumentation is provided by another module).
spring-6.0.0: Identical to spring-4.3.0 except for javax -> jakarta namespace.
spring-webflux-controller-mappings-5.0.0: Same functionality as the above modules except for Webflux rather than WebMVC.
Note that because the new instrumentation can change transaction names, enabling this "enhanced transaction naming" is gated by a configuration flag
enhanced_spring_transaction_naming
, which isfalse
by default:Testing
The agent includes a suite of tests which should be used to
verify your changes don't break existing functionality. These tests will run with
Github Actions when a pull request is made. More details on running the tests locally can be found
here,
Checks