Class AsyncOperationEndSupport<REQUEST,RESPONSE>

java.lang.Object
io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationEndSupport<REQUEST,RESPONSE>

public final class AsyncOperationEndSupport<REQUEST,RESPONSE> extends Object
A wrapper over Instrumenter that is able to defer Instrumenter.end(Context, Object, Object, Throwable) until asynchronous computation finishes.
  • Method Summary

    Modifier and Type
    Method
    Description
    <ASYNC> ASYNC
    asyncEnd(io.opentelemetry.context.Context context, REQUEST request, ASYNC asyncValue, Throwable throwable)
    Attempts to compose over passed asyncValue and delay the Instrumenter.end(Context, Object, Object, Throwable) call until the async operation completes.
    static <REQUEST, RESPONSE>
    AsyncOperationEndSupport<REQUEST,RESPONSE>
    create(io.opentelemetry.instrumentation.api.instrumenter.Instrumenter<REQUEST,RESPONSE> syncInstrumenter, Class<RESPONSE> responseType, Class<?> asyncType)
    Returns a new AsyncOperationEndSupport that wraps over passed syncInstrumenter, configured for usage with asynchronous computations that are instances of asyncType.
    static <RESPONSE> RESPONSE
    tryToGetResponse(Class<RESPONSE> responseType, Object asyncValue)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • create

      public static <REQUEST, RESPONSE> AsyncOperationEndSupport<REQUEST,RESPONSE> create(io.opentelemetry.instrumentation.api.instrumenter.Instrumenter<REQUEST,RESPONSE> syncInstrumenter, Class<RESPONSE> responseType, Class<?> asyncType)
      Returns a new AsyncOperationEndSupport that wraps over passed syncInstrumenter, configured for usage with asynchronous computations that are instances of asyncType. If the result of the async computation ends up being an instance of responseType it will be passed as the response to the syncInstrumenter call; otherwise null value will be used as the response.
    • asyncEnd

      @Nullable public <ASYNC> ASYNC asyncEnd(io.opentelemetry.context.Context context, REQUEST request, @Nullable ASYNC asyncValue, @Nullable Throwable throwable)
      Attempts to compose over passed asyncValue and delay the Instrumenter.end(Context, Object, Object, Throwable) call until the async operation completes.

      This method will end the operation immediately if throwable is passed, if there is no AsyncOperationEndStrategy for the asyncType used, or if there is a type mismatch between passed asyncValue and the asyncType that was used to create this object.

      If the passed asyncValue is recognized as an asynchronous computation, the operation won't be ended until asyncValue completes.

    • tryToGetResponse

      @Nullable public static <RESPONSE> RESPONSE tryToGetResponse(Class<RESPONSE> responseType, @Nullable Object asyncValue)