-
public final class CoroutineExtKt
-
-
Method Summary
Modifier and Type Method Description final static JoblaunchTraced(CoroutineScope $self, String operationName, CoroutineContext context, CoroutineStart start, SuspendFunction1<CoroutineScopeSpan, Unit> block)Launches a new coroutine without blocking the current thread and returns a reference to the coroutine as a Job. final static <T extends Any> TrunBlockingTraced(String operationName, CoroutineContext context, SuspendFunction1<CoroutineScope, T> block)Runs a new coroutine and blocks the current thread interruptibly until its completion. final static <T extends Any> Deferred<T>asyncTraced(CoroutineScope $self, String operationName, CoroutineContext context, CoroutineStart start, SuspendFunction1<CoroutineScopeSpan, T> block)Creates a coroutine and returns its future result as an implementation of Deferred. final static <T extends Any> TawaitTraced(Deferred<T> $self, String operationName)Awaits for completion of this value without blocking a thread and resumes when deferred computation is complete, returning the resulting value or throwing the corresponding exception if the deferred was cancelled. final static <T extends Any> TwithContextTraced(String operationName, CoroutineContext context, SuspendFunction1<CoroutineScopeSpan, T> block)Calls the specified suspending block with a given coroutine context, suspends until it completes, and returns the result. -
-
Method Detail
-
launchTraced
final static Job launchTraced(CoroutineScope $self, String operationName, CoroutineContext context, CoroutineStart start, SuspendFunction1<CoroutineScopeSpan, Unit> block)
Launches a new coroutine without blocking the current thread and returns a reference to the coroutine as a Job. A span will be created around the coroutine code and sent to Datadog.
See launch to learn more about launching a new coroutine.
- Parameters:
operationName- the name of the Span created around the coroutine code.context- additional to CoroutineScope.coroutineContext context of the coroutine.start- coroutine start option.block- the coroutine code which will be invoked in the context of the provided scope.
-
runBlockingTraced
final static <T extends Any> T runBlockingTraced(String operationName, CoroutineContext context, SuspendFunction1<CoroutineScope, T> block)
Runs a new coroutine and blocks the current thread interruptibly until its completion. A span will be created around the coroutine code and sent to Datadog.
This function should not be used from a coroutine. It is designed to bridge regular blocking code to libraries that are written in suspending style, to be used in
mainfunctions and in tests.See runBlocking to learn more about running a coroutine waiting for completion.
- Parameters:
operationName- the name of the Span created around the coroutine code.context- the context of the coroutine.block- the coroutine code.
-
asyncTraced
final static <T extends Any> Deferred<T> asyncTraced(CoroutineScope $self, String operationName, CoroutineContext context, CoroutineStart start, SuspendFunction1<CoroutineScopeSpan, T> block)
Creates a coroutine and returns its future result as an implementation of Deferred. A span will be created around the coroutine code and sent to Datadog.
See async to learn more about using deferred coroutine results.
- Parameters:
operationName- the name of the Span created around the coroutine code.context- the context to use for the async blockstart- defines how the block is scheduled (use CoroutineStart.LAZY to start the coroutine lazily)block- the coroutine code.
-
awaitTraced
final static <T extends Any> T awaitTraced(Deferred<T> $self, String operationName)
Awaits for completion of this value without blocking a thread and resumes when deferred computation is complete, returning the resulting value or throwing the corresponding exception if the deferred was cancelled. A span will be created around the completion and sent to Datadog.
See Deferred.await to learn more about awaiting completion on a Deferred result.
- Parameters:
operationName- the name of the Span created around the coroutine code.
-
withContextTraced
final static <T extends Any> T withContextTraced(String operationName, CoroutineContext context, SuspendFunction1<CoroutineScopeSpan, T> block)
Calls the specified suspending block with a given coroutine context, suspends until it completes, and returns the result. A span will be created around the coroutine code and sent to Datadog.
See withContext to learn more about running a coroutine within a specific CoroutineContext.
- Parameters:
operationName- the name of the Span created around the coroutine code.context- the context of the coroutine.block- the coroutine code.
-
-
-
-