Class AsyncOperationEndSupport<REQUEST,RESPONSE>
java.lang.Object
io.opentelemetry.instrumentation.api.annotation.support.async.AsyncOperationEndSupport<REQUEST,RESPONSE>
A wrapper over
Instrumenter that is able to defer Instrumenter.end(Context, Object, Object, Throwable) until asynchronous computation finishes.-
Method Summary
Modifier and TypeMethodDescription<ASYNC> ASYNCasyncEnd(io.opentelemetry.context.Context context, REQUEST request, ASYNC asyncValue, Throwable throwable) Attempts to compose over passedasyncValueand delay theInstrumenter.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 newAsyncOperationEndSupportthat wraps over passedsyncInstrumenter, configured for usage with asynchronous computations that are instances ofasyncType.static <RESPONSE> RESPONSEtryToGetResponse(Class<RESPONSE> responseType, Object asyncValue)
-
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 newAsyncOperationEndSupportthat wraps over passedsyncInstrumenter, configured for usage with asynchronous computations that are instances ofasyncType. If the result of the async computation ends up being an instance ofresponseTypeit will be passed as the response to thesyncInstrumentercall; otherwisenullvalue 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 passedasyncValueand delay theInstrumenter.end(Context, Object, Object, Throwable)call until the async operation completes.This method will end the operation immediately if
throwableis passed, if there is noAsyncOperationEndStrategyfor theasyncTypeused, or if there is a type mismatch between passedasyncValueand theasyncTypethat was used to create this object.If the passed
asyncValueis recognized as an asynchronous computation, the operation won't beendeduntilasyncValuecompletes. -
tryToGetResponse
-