Skip to content

Commit 30acf2a

Browse files
authored
Merge pull request #3 from newrelic-experimental/updates
Updates
2 parents c7382b3 + a02d31e commit 30acf2a

File tree

10 files changed

+94
-81
lines changed

10 files changed

+94
-81
lines changed

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
rootProject.name = 'java-instrumentation-template'
1+
rootProject.name = 'spring-async-instrumentation'
22
include 'spring-async'
33
include 'spring-web-async'

spring-async/build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ jar {
2323
}
2424

2525
verifyInstrumentation {
26-
passes 'org.springframework:spring-core:[5.0.0.RELEASE,)'
27-
excludeRegex '.*M.*'
28-
26+
passesOnly 'org.springframework:spring-core:[4.0.0.RELEASE,)'
27+
excludeRegex '.*M.*'
28+
excludeRegex '.*RC.*'
29+
2930
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.newrelic.instrumentation.spring.web.async;
1+
package com.newrelic.instrumentation.spring.async;
22

33
import java.util.concurrent.Callable;
44

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.newrelic.instrumentation.spring.web.async;
1+
package com.newrelic.instrumentation.spring.async;
22

33
import com.newrelic.agent.bridge.AgentBridge;
44
import com.newrelic.api.agent.NewRelic;

spring-async/src/main/java/com/newrelic/instrumentation/spring/web/async/Utils.java renamed to spring-async/src/main/java/com/newrelic/instrumentation/spring/async/Utils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.newrelic.instrumentation.spring.web.async;
1+
package com.newrelic.instrumentation.spring.async;
22

33
import java.util.concurrent.Callable;
44

@@ -12,7 +12,7 @@ public static Runnable getWrappedRunnable(Runnable r) {
1212
if(r instanceof NRRunnableWrapper) return null;
1313

1414
String packageName = r.getClass().getPackage().getName();
15-
if(packageName.startsWith("com.newrelic")) return null;
15+
if(packageName.startsWith("com.newrelic") || packageName.startsWith("com.nr")) return null;
1616

1717
Token token = NewRelic.getAgent().getTransaction().getToken();
1818
if(token != null && token.isActive()) {
@@ -29,7 +29,7 @@ public static <V> Callable<V> getWrappedCallable(Callable<V> c) {
2929
if(c instanceof NRCallableWrapper) return null;
3030

3131
String packageName = c.getClass().getPackage().getName();
32-
if(packageName.startsWith("com.newrelic")) return null;
32+
if(packageName.startsWith("com.newrelic") || packageName.startsWith("com.nr")) return null;
3333

3434
Token token = NewRelic.getAgent().getTransaction().getToken();
3535
if(token != null && token.isActive()) {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.springframework.core.task;
2+
3+
import com.newrelic.api.agent.weaver.MatchType;
4+
import com.newrelic.api.agent.weaver.Weave;
5+
import com.newrelic.api.agent.weaver.Weaver;
6+
import com.newrelic.instrumentation.spring.async.Utils;
7+
import org.springframework.util.concurrent.ListenableFuture;
8+
9+
import java.util.concurrent.Callable;
10+
11+
@Weave(originalName = "org.springframework.core.task.AsyncListenableTaskExecutor", type = MatchType.Interface)
12+
public class AsyncListenableTaskExecutor_Instrumentation {
13+
14+
public ListenableFuture<?> submitListenable(Runnable task) {
15+
Runnable wrapper = Utils.getWrappedRunnable(task);
16+
if(wrapper != null) {
17+
task = wrapper;
18+
}
19+
return Weaver.callOriginal();
20+
}
21+
22+
public <T> ListenableFuture<T> submitListenable(Callable<T> task) {
23+
Callable<T> wrapper = Utils.getWrappedCallable(task);
24+
if(wrapper != null) {
25+
task = wrapper;
26+
}
27+
return Weaver.callOriginal();
28+
}
29+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package org.springframework.core.task;
2+
3+
import com.newrelic.api.agent.weaver.MatchType;
4+
import com.newrelic.api.agent.weaver.Weave;
5+
import com.newrelic.api.agent.weaver.Weaver;
6+
import com.newrelic.instrumentation.spring.async.Utils;
7+
8+
import java.util.concurrent.Callable;
9+
import java.util.concurrent.Future;
10+
11+
@Weave(originalName = "org.springframework.core.task.AsyncTaskExecutor", type = MatchType.Interface)
12+
public class AsyncTaskExecutor_Instrumentation {
13+
14+
public void execute(Runnable task, long startTimeout) {
15+
Runnable wrapper = Utils.getWrappedRunnable(task);
16+
if(wrapper != null) {
17+
task = wrapper;
18+
}
19+
Weaver.callOriginal();
20+
}
21+
22+
public Future<?> submit(Runnable task) {
23+
Runnable wrapper = Utils.getWrappedRunnable(task);
24+
if(wrapper != null) {
25+
task = wrapper;
26+
}
27+
return Weaver.callOriginal();
28+
}
29+
30+
public <V> Future<V> submit(Callable<V> task) {
31+
Callable<V> wrapper = Utils.getWrappedCallable(task);
32+
if(wrapper != null) {
33+
task = wrapper;
34+
}
35+
return Weaver.callOriginal();
36+
}
37+
}

spring-async/src/main/java/org/springframework/core/task/SimpleAsyncTaskExecutor.java

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.springframework.core.task;
2+
3+
import com.newrelic.api.agent.weaver.MatchType;
4+
import com.newrelic.api.agent.weaver.Weave;
5+
import com.newrelic.api.agent.weaver.Weaver;
6+
import com.newrelic.instrumentation.spring.async.Utils;
7+
8+
@Weave(originalName = "org.springframework.core.task.TaskExecutor", type = MatchType.Interface)
9+
public class TaskExecutor_Instrumentation {
10+
11+
public void execute(Runnable task) {
12+
Runnable wrapper = Utils.getWrappedRunnable(task);
13+
if(wrapper != null) {
14+
task = wrapper;
15+
}
16+
Weaver.callOriginal();
17+
}
18+
}

spring-async/src/main/java/org/springframework/core/task/support/TaskExecutorAdapter.java

Lines changed: 0 additions & 54 deletions
This file was deleted.

0 commit comments

Comments
 (0)