Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.newrelic.agent.instrumentation.pointcuts.frameworks.cxf.CXFInvokerPointCut;
import com.newrelic.agent.instrumentation.pointcuts.frameworks.cxf.CXFPointCut;
import com.newrelic.agent.instrumentation.pointcuts.frameworks.cxf.ClientProxyPointCut;
import com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.HandlerMethodInvokerPointCut;
import com.newrelic.agent.instrumentation.pointcuts.frameworks.spring.SpringPointCut;
import com.newrelic.agent.service.ServiceFactory;
import org.junit.Assert;
Expand Down Expand Up @@ -48,7 +47,6 @@ public void test() {
// Spring
new SpringPointCut(classTransformer),
// new SpringWildcardPathPointCut(classTransformer),
new HandlerMethodInvokerPointCut(classTransformer),
// CXF
new CXFPointCut(classTransformer),
new CXFInvokerPointCut(classTransformer),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ dependencies {
}

jar {
manifest { attributes 'Implementation-Title': 'com.newrelic.instrumentation.spring-handler-method-invoker-3.0.0'}
manifest { attributes 'Implementation-Title': 'com.newrelic.instrumentation.spring-handler-method-invoker-2.5.2'}
}

verifyInstrumentation {
passesOnly('org.springframework:spring-web:[3.0.0.RELEASE,5.0.0.RELEASE)') {
passesOnly('org.springframework:spring-web:[2.5.2,5.0.0.RELEASE)') {
implementation("org.springframework:spring-webmvc:3.0.0.RELEASE")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import com.newrelic.agent.bridge.AgentBridge;
import com.newrelic.agent.bridge.Transaction;
import com.newrelic.agent.bridge.TransactionNamePriority;
import com.newrelic.api.agent.Trace;
import com.newrelic.api.agent.weaver.MatchType;
import com.newrelic.api.agent.weaver.Weave;
Expand All @@ -33,6 +34,8 @@ public Object invokeHandlerMethod(Method handlerMethod, Object handler,
}

transaction.getTracedMethod().setMetricName("Spring", "Java", controllerName, methodName);
transaction.setTransactionName(TransactionNamePriority.FRAMEWORK, true,
"SpringController", "/" + controllerName + "/" + methodName);
}

return Weaver.callOriginal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.newrelic.agent.bridge.AgentBridge;
import com.newrelic.agent.bridge.TracedMethod;
import com.newrelic.agent.bridge.Transaction;
import com.newrelic.agent.bridge.TransactionNamePriority;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -53,6 +54,36 @@ public void invokeHandlerMethod_setsMetricName() throws Exception {
"handleRequest");
}

@Test
public void invokeHandlerMethod_setsTransactionName() throws Exception {
when(mockAgent.getTransaction(false)).thenReturn(mockTransaction);
when(mockTransaction.getTracedMethod()).thenReturn(mockTracedMethod);

HandlerMethodInvoker_Instrumentation invoker = new HandlerMethodInvoker_Instrumentation();
Method method = TestController.class.getMethod("handleRequest");

invoker.invokeHandlerMethod(method, new TestController(), null, null);

verify(mockTransaction).setTransactionName(TransactionNamePriority.FRAMEWORK, true,
"SpringController",
"/org.springframework.web.bind.annotation.support.HandlerMethodInvokerInstrumentationTest$TestController/handleRequest");
}

@Test
public void invokeHandlerMethod_stripsProxyClassSuffix() throws Exception {
when(mockAgent.getTransaction(false)).thenReturn(mockTransaction);
when(mockTransaction.getTracedMethod()).thenReturn(mockTracedMethod);

HandlerMethodInvoker_Instrumentation invoker = new HandlerMethodInvoker_Instrumentation();
Method method = TestController.class.getMethod("handleRequest");

invoker.invokeHandlerMethod(method, new TestController$$EnhancerBySpringCGLIB(), null, null);

verify(mockTransaction).setTransactionName(TransactionNamePriority.FRAMEWORK, true,
"SpringController",
"/org.springframework.web.bind.annotation.support.HandlerMethodInvokerInstrumentationTest$TestController/handleRequest");
}

@Test
public void invokeHandlerMethod_noTransaction_doesNotCrash() throws Exception {
when(mockAgent.getTransaction(false)).thenReturn(null);
Expand All @@ -70,4 +101,7 @@ public String handleRequest() {
return "response";
}
}

public static class TestController$$EnhancerBySpringCGLIB extends TestController {
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ protected void doFinish(int opcode, Object modelView) {

private String getControllerName(Class<?> controller) {
String controllerName = controller.getName();
int indexOf = controllerName.indexOf(MethodInvokerPointCut.TO_REMOVE);
int indexOf = controllerName.indexOf("$$EnhancerBy");
if (indexOf > 0) {
controllerName = controllerName.substring(0, indexOf);
}
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ include 'instrumentation:spring-batch-4.0.0'
include 'instrumentation:spring-batch-5.0.0'
include 'instrumentation:spring-boot-actuator-3.0.0'
include 'instrumentation:spring-cache-3.1.0'
include 'instrumentation:spring-handler-method-invoker-3.0.0'
include 'instrumentation:spring-handler-method-invoker-2.5.2'
include 'instrumentation:spring-jms-2'
include 'instrumentation:spring-jms-3'
include 'instrumentation:spring-kafka-2.2.0'
Expand Down
Loading