Skip to content
Merged
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
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
rootProject.name = 'java-instrumentation-template'
rootProject.name = 'spring-async-instrumentation'
include 'spring-async'
include 'spring-web-async'
7 changes: 4 additions & 3 deletions spring-async/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ jar {
}

verifyInstrumentation {
passes 'org.springframework:spring-core:[5.0.0.RELEASE,)'
excludeRegex '.*M.*'

passesOnly 'org.springframework:spring-core:[4.0.0.RELEASE,)'
excludeRegex '.*M.*'
excludeRegex '.*RC.*'

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.newrelic.instrumentation.spring.web.async;
package com.newrelic.instrumentation.spring.async;

import java.util.concurrent.Callable;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.newrelic.instrumentation.spring.web.async;
package com.newrelic.instrumentation.spring.async;

import com.newrelic.agent.bridge.AgentBridge;
import com.newrelic.api.agent.NewRelic;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.newrelic.instrumentation.spring.web.async;
package com.newrelic.instrumentation.spring.async;

import java.util.concurrent.Callable;

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

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

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

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

Token token = NewRelic.getAgent().getTransaction().getToken();
if(token != null && token.isActive()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.springframework.core.task;

import com.newrelic.api.agent.weaver.MatchType;
import com.newrelic.api.agent.weaver.Weave;
import com.newrelic.api.agent.weaver.Weaver;
import com.newrelic.instrumentation.spring.async.Utils;
import org.springframework.util.concurrent.ListenableFuture;

import java.util.concurrent.Callable;

@Weave(originalName = "org.springframework.core.task.AsyncListenableTaskExecutor", type = MatchType.Interface)
public class AsyncListenableTaskExecutor_Instrumentation {

public ListenableFuture<?> submitListenable(Runnable task) {
Runnable wrapper = Utils.getWrappedRunnable(task);
if(wrapper != null) {
task = wrapper;
}
return Weaver.callOriginal();
}

public <T> ListenableFuture<T> submitListenable(Callable<T> task) {
Callable<T> wrapper = Utils.getWrappedCallable(task);
if(wrapper != null) {
task = wrapper;
}
return Weaver.callOriginal();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.springframework.core.task;

import com.newrelic.api.agent.weaver.MatchType;
import com.newrelic.api.agent.weaver.Weave;
import com.newrelic.api.agent.weaver.Weaver;
import com.newrelic.instrumentation.spring.async.Utils;

import java.util.concurrent.Callable;
import java.util.concurrent.Future;

@Weave(originalName = "org.springframework.core.task.AsyncTaskExecutor", type = MatchType.Interface)
public class AsyncTaskExecutor_Instrumentation {

public void execute(Runnable task, long startTimeout) {
Runnable wrapper = Utils.getWrappedRunnable(task);
if(wrapper != null) {
task = wrapper;
}
Weaver.callOriginal();
}

public Future<?> submit(Runnable task) {
Runnable wrapper = Utils.getWrappedRunnable(task);
if(wrapper != null) {
task = wrapper;
}
return Weaver.callOriginal();
}

public <V> Future<V> submit(Callable<V> task) {
Callable<V> wrapper = Utils.getWrappedCallable(task);
if(wrapper != null) {
task = wrapper;
}
return Weaver.callOriginal();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.springframework.core.task;

import com.newrelic.api.agent.weaver.MatchType;
import com.newrelic.api.agent.weaver.Weave;
import com.newrelic.api.agent.weaver.Weaver;
import com.newrelic.instrumentation.spring.async.Utils;

@Weave(originalName = "org.springframework.core.task.TaskExecutor", type = MatchType.Interface)
public class TaskExecutor_Instrumentation {

public void execute(Runnable task) {
Runnable wrapper = Utils.getWrappedRunnable(task);
if(wrapper != null) {
task = wrapper;
}
Weaver.callOriginal();
}
}

This file was deleted.