diff --git a/instrumentation/kotlin-coroutines-1.4/src/main/java/com/newrelic/instrumentation/kotlin/coroutines_14/NRDelayCancellableContinuation.java b/instrumentation/kotlin-coroutines-1.4/src/main/java/com/newrelic/instrumentation/kotlin/coroutines_14/NRDelayCancellableContinuation.java deleted file mode 100644 index 45dbabca05..0000000000 --- a/instrumentation/kotlin-coroutines-1.4/src/main/java/com/newrelic/instrumentation/kotlin/coroutines_14/NRDelayCancellableContinuation.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.newrelic.instrumentation.kotlin.coroutines_14; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Segment; -import kotlin.Unit; -import kotlin.coroutines.CoroutineContext; -import kotlin.jvm.functions.Function1; -import kotlinx.coroutines.CancellableContinuation; -import kotlinx.coroutines.CoroutineDispatcher; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/* - * Used to wrap the tracking of a call to the Coroutine delay function if tracking is enabled - * Will report the delay as a segment - */ -public class NRDelayCancellableContinuation implements CancellableContinuation { - - private final CancellableContinuation delegate; - private Segment segment; - - public NRDelayCancellableContinuation(CancellableContinuation delegate, String type) { - this.delegate = delegate; - String name = Utils.getContinuationString(delegate); - segment = NewRelic.getAgent().getTransaction().startSegment(type); - segment.addCustomAttribute("CancellableContinuation", name); - } - - @Override - public void resumeWith(@NotNull Object o) { - if(segment != null) { - segment.end(); - segment = null; - } - if(delegate != null) { - delegate.resumeWith(o); - } - } - - @Override - public @NotNull CoroutineContext getContext() { - return delegate.getContext(); - } - - @Override - public boolean isActive() { - return delegate.isActive(); - } - - @Override - public boolean isCompleted() { - return delegate.isCompleted(); - } - - @Override - public boolean isCancelled() { - return delegate.isCancelled(); - } - - @Override - public @Nullable Object tryResume(T t, @Nullable Object o) { - if(segment != null) { - segment.end(); - segment = null; - } - return delegate.tryResume(t,o); - } - - @Override - public @Nullable Object tryResume(T t, @Nullable Object o, @Nullable Function1 function1) { - if(segment != null) { - segment.end(); - segment = null; - } - return delegate.tryResume(t,o, function1); - } - - @Override - public @Nullable Object tryResumeWithException(@NotNull Throwable throwable) { - NewRelic.noticeError(throwable); - if(segment != null) { - segment.end(); - segment = null; - } - return delegate.tryResumeWithException(throwable); - } - - @Override - public void completeResume(@NotNull Object o) { - if(segment != null) { - segment.end(); - segment = null; - } - delegate.completeResume(o); - } - - @Override - public void initCancellability() { - delegate.initCancellability(); - } - - @Override - public boolean cancel(@Nullable Throwable throwable) { - if(segment != null) { - segment.end(); - segment = null; - } - return delegate.cancel(throwable); - } - - @Override - public void invokeOnCancellation(@NotNull Function1 function1) { - if(segment != null) { - segment.end(); - segment = null; - } - delegate.invokeOnCancellation(function1); - } - - @Override - public void resumeUndispatched(@NotNull CoroutineDispatcher coroutineDispatcher, T t) { - if(segment != null) { - segment.end(); - segment = null; - } - delegate.resumeUndispatched(coroutineDispatcher, t); - } - - @Override - public void resumeUndispatchedWithException(@NotNull CoroutineDispatcher coroutineDispatcher, @NotNull Throwable throwable) { - if(segment != null) { - segment.end(); - segment = null; - } - delegate.resumeUndispatchedWithException(coroutineDispatcher, throwable); - } - - @Override - public void resume(T t, @Nullable Function1 function1) { - if(segment != null) { - segment.end(); - segment = null; - } - delegate.resume(t,function1); - } -} diff --git a/instrumentation/kotlin-coroutines-1.4/src/main/java/kotlinx/coroutines/Delay_Instrumentation.java b/instrumentation/kotlin-coroutines-1.4/src/main/java/kotlinx/coroutines/Delay_Instrumentation.java index 3b57f1ee85..fe52face96 100644 --- a/instrumentation/kotlin-coroutines-1.4/src/main/java/kotlinx/coroutines/Delay_Instrumentation.java +++ b/instrumentation/kotlin-coroutines-1.4/src/main/java/kotlinx/coroutines/Delay_Instrumentation.java @@ -4,7 +4,6 @@ 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.kotlin.coroutines_14.NRDelayCancellableContinuation; import com.newrelic.instrumentation.kotlin.coroutines_14.NRDelayContinuation; import com.newrelic.instrumentation.kotlin.coroutines_14.Utils; import kotlin.Unit; @@ -24,9 +23,6 @@ public Object delay(long timeMills, Continuation continuation) { @Trace public void scheduleResumeAfterDelay(long timeMills, CancellableContinuation continuation) { - if(Utils.DELAYED_ENABLED && !(continuation instanceof NRDelayContinuation)) { - continuation = new NRDelayCancellableContinuation<>(continuation,"scheduleResumeAfterDelay"); - } Weaver.callOriginal(); } diff --git a/instrumentation/kotlin-coroutines-1.7/src/main/java/com/newrelic/instrumentation/kotlin/coroutines_17/NRDelayCancellableContinuation.java b/instrumentation/kotlin-coroutines-1.7/src/main/java/com/newrelic/instrumentation/kotlin/coroutines_17/NRDelayCancellableContinuation.java deleted file mode 100644 index 6b60a068f7..0000000000 --- a/instrumentation/kotlin-coroutines-1.7/src/main/java/com/newrelic/instrumentation/kotlin/coroutines_17/NRDelayCancellableContinuation.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.newrelic.instrumentation.kotlin.coroutines_17; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Segment; -import kotlin.Unit; -import kotlin.coroutines.CoroutineContext; -import kotlin.jvm.functions.Function1; -import kotlinx.coroutines.CancellableContinuation; -import kotlinx.coroutines.CoroutineDispatcher; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/* - * Used to wrap the tracking of a call to the Coroutine delay function if tracking is enabled - * Will report the delay as a segment - */ -public class NRDelayCancellableContinuation implements CancellableContinuation { - - private final CancellableContinuation delegate; - private Segment segment; - - public NRDelayCancellableContinuation(CancellableContinuation delegate, String type) { - this.delegate = delegate; - String name = Utils.getContinuationString(delegate); - segment = NewRelic.getAgent().getTransaction().startSegment(type); - segment.addCustomAttribute("CancellableContinuation", name); - } - - @Override - public void resumeWith(@NotNull Object o) { - if(segment != null) { - segment.end(); - segment = null; - } - if(delegate != null) { - delegate.resumeWith(o); - } - } - - @Override - public @NotNull CoroutineContext getContext() { - return delegate.getContext(); - } - - @Override - public boolean isActive() { - return delegate.isActive(); - } - - @Override - public boolean isCompleted() { - return delegate.isCompleted(); - } - - @Override - public boolean isCancelled() { - return delegate.isCancelled(); - } - - @Override - public @Nullable Object tryResume(T t, @Nullable Object o) { - if(segment != null) { - segment.end(); - segment = null; - } - return delegate.tryResume(t,o); - } - - @Override - public @Nullable Object tryResume(T t, @Nullable Object o, @Nullable Function1 function1) { - if(segment != null) { - segment.end(); - segment = null; - } - return delegate.tryResume(t,o, function1); - } - - @Override - public @Nullable Object tryResumeWithException(@NotNull Throwable throwable) { - NewRelic.noticeError(throwable); - if(segment != null) { - segment.end(); - segment = null; - } - return delegate.tryResumeWithException(throwable); - } - - @Override - public void completeResume(@NotNull Object o) { - if(segment != null) { - segment.end(); - segment = null; - } - delegate.completeResume(o); - } - - @Override - public void initCancellability() { - delegate.initCancellability(); - } - - @Override - public boolean cancel(@Nullable Throwable throwable) { - if(segment != null) { - segment.end(); - segment = null; - } - return delegate.cancel(throwable); - } - - @Override - public void invokeOnCancellation(@NotNull Function1 function1) { - if(segment != null) { - segment.end(); - segment = null; - } - delegate.invokeOnCancellation(function1); - } - - @Override - public void resumeUndispatched(@NotNull CoroutineDispatcher coroutineDispatcher, T t) { - if(segment != null) { - segment.end(); - segment = null; - } - delegate.resumeUndispatched(coroutineDispatcher, t); - } - - @Override - public void resumeUndispatchedWithException(@NotNull CoroutineDispatcher coroutineDispatcher, @NotNull Throwable throwable) { - if(segment != null) { - segment.end(); - segment = null; - } - delegate.resumeUndispatchedWithException(coroutineDispatcher, throwable); - } - - @Override - public void resume(T t, @Nullable Function1 function1) { - if(segment != null) { - segment.end(); - segment = null; - } - delegate.resume(t,function1); - } -} diff --git a/instrumentation/kotlin-coroutines-1.7/src/main/java/kotlinx/coroutines/Delay_Instrumentation.java b/instrumentation/kotlin-coroutines-1.7/src/main/java/kotlinx/coroutines/Delay_Instrumentation.java index 9af6b11940..8e0855e581 100644 --- a/instrumentation/kotlin-coroutines-1.7/src/main/java/kotlinx/coroutines/Delay_Instrumentation.java +++ b/instrumentation/kotlin-coroutines-1.7/src/main/java/kotlinx/coroutines/Delay_Instrumentation.java @@ -1,14 +1,10 @@ package kotlinx.coroutines; -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Token; import com.newrelic.api.agent.Trace; 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.kotlin.coroutines_17.NRDelayCancellableContinuation; import com.newrelic.instrumentation.kotlin.coroutines_17.NRDelayContinuation; -import com.newrelic.instrumentation.kotlin.coroutines_17.NRRunnable; import com.newrelic.instrumentation.kotlin.coroutines_17.Utils; import kotlin.Unit; import kotlin.coroutines.Continuation; @@ -27,9 +23,6 @@ public Object delay(long timeMills, Continuation continuation) { @Trace public void scheduleResumeAfterDelay(long timeMills, CancellableContinuation continuation) { - if(Utils.DELAYED_ENABLED && !(continuation instanceof NRDelayContinuation)) { - continuation = new NRDelayCancellableContinuation<>(continuation,"scheduleResumeAfterDelay"); - } Weaver.callOriginal(); } diff --git a/instrumentation/kotlin-coroutines-1.9/src/main/java/com/newrelic/instrumentation/kotlin/coroutines_19/NRDelayCancellableContinuation.java b/instrumentation/kotlin-coroutines-1.9/src/main/java/com/newrelic/instrumentation/kotlin/coroutines_19/NRDelayCancellableContinuation.java deleted file mode 100644 index 9ea9be04ba..0000000000 --- a/instrumentation/kotlin-coroutines-1.9/src/main/java/com/newrelic/instrumentation/kotlin/coroutines_19/NRDelayCancellableContinuation.java +++ /dev/null @@ -1,159 +0,0 @@ -package com.newrelic.instrumentation.kotlin.coroutines_19; - -import kotlin.jvm.functions.Function3; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import com.newrelic.api.agent.NewRelic; -import com.newrelic.api.agent.Segment; - -import kotlin.Unit; -import kotlin.coroutines.CoroutineContext; -import kotlin.jvm.functions.Function1; -import kotlinx.coroutines.CancellableContinuation; -import kotlinx.coroutines.CoroutineDispatcher; - -/* - * Used to wrap the tracking of a call to the Coroutine delay function if tracking is enabled - * Will report the delay as a segment - */ -public class NRDelayCancellableContinuation implements CancellableContinuation { - - private final CancellableContinuation delegate; - private Segment segment; - - public NRDelayCancellableContinuation(CancellableContinuation delegate, String type) { - this.delegate = delegate; - String name = Utils.getContinuationString(delegate); - segment = NewRelic.getAgent().getTransaction().startSegment(type); - segment.addCustomAttribute("CancellableContinuation", name); - } - - @Override - public void resumeWith(@NotNull Object o) { - if(segment != null) { - segment.end(); - segment = null; - } - if(delegate != null) { - delegate.resumeWith(o); - } - } - - @Override - public @NotNull CoroutineContext getContext() { - return delegate.getContext(); - } - - @Override - public boolean isActive() { - return delegate.isActive(); - } - - @Override - public boolean isCompleted() { - return delegate.isCompleted(); - } - - @Override - public boolean isCancelled() { - return delegate.isCancelled(); - } - - @Override - public @Nullable Object tryResume(T t, @Nullable Object o) { - if(segment != null) { - segment.end(); - segment = null; - } - return delegate.tryResume(t,o); - } - - @Override - public @Nullable Object tryResumeWithException(@NotNull Throwable throwable) { - NewRelic.noticeError(throwable); - if(segment != null) { - segment.end(); - segment = null; - } - return delegate.tryResumeWithException(throwable); - } - - @Override - public void completeResume(@NotNull Object o) { - if(segment != null) { - segment.end(); - segment = null; - } - delegate.completeResume(o); - } - - @Override - public void initCancellability() { - delegate.initCancellability(); - } - - @Override - public boolean cancel(@Nullable Throwable throwable) { - if(segment != null) { - segment.end(); - segment = null; - } - return delegate.cancel(throwable); - } - - @Override - public void invokeOnCancellation(@NotNull Function1 function1) { - if(segment != null) { - segment.end(); - segment = null; - } - delegate.invokeOnCancellation(function1); - } - - @Override - public void resumeUndispatched(@NotNull CoroutineDispatcher coroutineDispatcher, T t) { - if(segment != null) { - segment.end(); - segment = null; - } - delegate.resumeUndispatched(coroutineDispatcher, t); - } - - @Override - public void resumeUndispatchedWithException(@NotNull CoroutineDispatcher coroutineDispatcher, @NotNull Throwable throwable) { - if(segment != null) { - segment.end(); - segment = null; - } - delegate.resumeUndispatchedWithException(coroutineDispatcher, throwable); - } - - @SuppressWarnings("deprecation") - @Override - public void resume(T t, @Nullable Function1 function1) { - if(segment != null) { - segment.end(); - segment = null; - } - delegate.resume(t,function1); - } - - @Override - public @Nullable Object tryResume(R r, @Nullable Object o,@Nullable Function3 function3) { - if(segment != null) { - segment.end(); - segment = null; - } - return delegate.tryResume(r,o,function3); - } - - @Override - public void resume(R r, @Nullable Function3 function3) { - if(segment != null) { - segment.end(); - segment = null; - } - delegate.resume(r,function3); - } -} diff --git a/instrumentation/kotlin-coroutines-1.9/src/main/java/kotlinx/coroutines/Delay_Instrumentation.java b/instrumentation/kotlin-coroutines-1.9/src/main/java/kotlinx/coroutines/Delay_Instrumentation.java index 2137b85ff6..1b47ed58fa 100644 --- a/instrumentation/kotlin-coroutines-1.9/src/main/java/kotlinx/coroutines/Delay_Instrumentation.java +++ b/instrumentation/kotlin-coroutines-1.9/src/main/java/kotlinx/coroutines/Delay_Instrumentation.java @@ -4,7 +4,6 @@ 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.kotlin.coroutines_19.NRDelayCancellableContinuation; import com.newrelic.instrumentation.kotlin.coroutines_19.NRDelayContinuation; import com.newrelic.instrumentation.kotlin.coroutines_19.Utils; import kotlin.Unit; @@ -24,9 +23,6 @@ public Object delay(long timeMills, Continuation continuation) { @Trace public void scheduleResumeAfterDelay(long timeMills, CancellableContinuation continuation) { - if(Utils.DELAYED_ENABLED && !(continuation instanceof NRDelayContinuation)) { - continuation = new NRDelayCancellableContinuation<>(continuation,"scheduleResumeAfterDelay"); - } Weaver.callOriginal(); }