Skip to content

Commit 066e0bd

Browse files
committed
added support for mt version
1 parent a311dd1 commit 066e0bd

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

Kotlin-Coroutines_1.9/src/main/java/com/newrelic/instrumentation/kotlin/coroutines_19/NRRunnable.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@
77
import kotlin.coroutines.Continuation;
88
import kotlinx.coroutines.DispatchedTask;
99

10+
import java.util.logging.Level;
11+
1012
public class NRRunnable implements Runnable {
1113

1214
private Runnable delegate = null;
1315
private Token token = null;
1416
private static boolean isTransformed = false;
1517

1618
public NRRunnable(Runnable r,Token t) {
19+
NewRelic.getAgent().getLogger().log(Level.FINER, new Exception("Constructing NRRunnable"), "NRRunnable {0}", r.toString());
1720
if(!isTransformed) {
1821
AgentBridge.instrumentation.retransformUninstrumentedClass(getClass());
1922
isTransformed = true;

Kotlin-Coroutines_1.9/src/main/java/kotlinx/coroutines/BuildersKt_Instrumentation.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import kotlin.coroutines.jvm.internal.SuspendFunction;
1515
import kotlin.jvm.functions.Function2;
1616

17+
import java.util.logging.Level;
18+
1719
@SuppressWarnings({ "unchecked", "rawtypes" })
1820
@Weave(originalName = "kotlinx.coroutines.BuildersKt")
1921
public class BuildersKt_Instrumentation {
@@ -64,7 +66,7 @@ public static <T> Deferred<T> async(CoroutineScope scope, CoroutineContext conte
6466
}
6567

6668
@Trace(dispatcher = true)
67-
public static <T> Object invoke(CoroutineDispatcher_Instrumentation dispatcher,
69+
public static <T> Object invoke(CoroutineDispatcher dispatcher,
6870
Function2<? super CoroutineScope, ? super Continuation<? super T>, ?> block, Continuation<? super T> cont) {
6971

7072
NewRelic.getAgent().getTracedMethod().addCustomAttribute("Continuation", cont.toString());
@@ -94,6 +96,7 @@ public static kotlinx.coroutines.Job launch(CoroutineScope scope, CoroutineConte
9496
name = Utils.getCoroutineName(scope.getCoroutineContext());
9597
}
9698
if (name != null) {
99+
NewRelic.getAgent().getLogger().log(Level.FINE, new Exception("Call to BuildersKt.launch"), "Call to start {0}", name);
97100
NewRelic.getAgent().getTracedMethod().setMetricName("Custom", "Builders", "launch", name);
98101
NewRelic.getAgent().getTracedMethod().addCustomAttribute("CoroutineName", name);
99102
} else {

Kotlin-Coroutines_1.9/src/main/java/kotlinx/coroutines/CoroutineDispatcher_Instrumentation.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.newrelic.instrumentation.kotlin.coroutines_19.Utils;
88

99
import kotlin.coroutines.CoroutineContext;
10+
import kotlinx.coroutines.internal.LimitedDispatcher;
1011

1112
/*
1213
* Dispatchers are used to dispatch tasks to another thread. By wrapping the Runable
@@ -16,11 +17,15 @@
1617
public abstract class CoroutineDispatcher_Instrumentation {
1718

1819
public void dispatch(CoroutineContext ctx, Runnable r) {
19-
NRRunnable wrapper = Utils.getRunnableWrapper(r);
20-
if(wrapper != null) {
21-
r = wrapper;
20+
String classname = getClass().getName();
21+
22+
if(!classname.contains("LimitedDispatcher")) {
23+
NRRunnable wrapper = Utils.getRunnableWrapper(r);
24+
if(wrapper != null) {
25+
r = wrapper;
26+
}
2227
}
23-
28+
2429
Weaver.callOriginal();
2530
}
2631
}

Kotlin-Coroutines_1.9/src/main/java/kotlinx/coroutines/ResumeUndispatchedRunnable_Instrumentation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ abstract class ResumeUndispatchedRunnable_Instrumentation {
1313
@NewField
1414
private Token token = null;
1515

16-
public ResumeUndispatchedRunnable_Instrumentation(CoroutineDispatcher_Instrumentation dispatcher, CancellableContinuation<? super kotlin.Unit> cont) {
16+
public ResumeUndispatchedRunnable_Instrumentation(CoroutineDispatcher dispatcher, CancellableContinuation<? super kotlin.Unit> cont) {
1717
Token t = NewRelic.getAgent().getTransaction().getToken();
1818
if(t != null && t.isActive()) {
1919
token = t;

0 commit comments

Comments
 (0)