Interface InvocationInstrumenter
-
public interface InvocationInstrumenterAn interface for invocation instrumentation.- Since:
- 1.3
-
-
Field Summary
Fields Modifier and Type Field Description static InvocationInstrumenterNOOPNoop implementation ifInvocationInstrumenter.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static InvocationInstrumentercombine(java.util.Collection<InvocationInstrumenter> invocationInstrumenters)Combines multiple instrumenters into one.static java.lang.Runnableinstrument(java.lang.Runnable runnable, InvocationInstrumenter invocationInstrumenter)WrapsRunnablewith instrumentation invocations.static java.lang.Runnableinstrument(java.lang.Runnable runnable, java.util.Collection<InvocationInstrumenter> invocationInstrumenters)WrapsRunnablewith instrumentation invocations.static <V> java.util.concurrent.Callable<V>instrument(java.util.concurrent.Callable<V> callable, InvocationInstrumenter invocationInstrumenter)WrapsCallablewith instrumentation invocations.static <V> java.util.concurrent.Callable<V>instrument(java.util.concurrent.Callable<V> callable, java.util.Collection<InvocationInstrumenter> invocationInstrumenters)WrapsCallablewith instrumentation invocations.static java.util.concurrent.Executorinstrument(java.util.concurrent.Executor executor, InvocationInstrumenter invocationInstrumenter)Wraps theexecutorso that every tasks submitted to it will be executed instrumented with the giveninvocationInstrumenter.InstrumentationnewInstrumentation()
-
-
-
Field Detail
-
NOOP
static final InvocationInstrumenter NOOP
Noop implementation ifInvocationInstrumenter.
-
-
Method Detail
-
newInstrumentation
@NonNull Instrumentation newInstrumentation()
- Returns:
- a one-time
Instrumentationinstance which to be used in a try-with-resources to do the instrumentation. To force cleanup invokeInstrumentation.forceCleanup()on the retuned instance. - Since:
- 2.0
-
combine
@NonNull static InvocationInstrumenter combine(java.util.Collection<InvocationInstrumenter> invocationInstrumenters)
Combines multiple instrumenters into one.- Parameters:
invocationInstrumenters- instrumenters to combine- Returns:
- new instrumenter
-
instrument
@NonNull static java.lang.Runnable instrument(@NonNull java.lang.Runnable runnable, java.util.Collection<InvocationInstrumenter> invocationInstrumenters)WrapsRunnablewith instrumentation invocations.- Parameters:
runnable-Runnableto be wrappedinvocationInstrumenters- instrumenters to be used- Returns:
- wrapper
-
instrument
@NonNull static <V> java.util.concurrent.Callable<V> instrument(@NonNull java.util.concurrent.Callable<V> callable, java.util.Collection<InvocationInstrumenter> invocationInstrumenters)WrapsCallablewith instrumentation invocations.- Type Parameters:
V- callable generic param- Parameters:
callable-Callableto be wrappedinvocationInstrumenters- instrumenters to be used- Returns:
- wrapper
-
instrument
@NonNull static java.lang.Runnable instrument(@NonNull java.lang.Runnable runnable, InvocationInstrumenter invocationInstrumenter)WrapsRunnablewith instrumentation invocations.- Parameters:
runnable-Runnableto be wrappedinvocationInstrumenter- instrumenter to be used- Returns:
- wrapper
-
instrument
@NonNull static <V> java.util.concurrent.Callable<V> instrument(@NonNull java.util.concurrent.Callable<V> callable, InvocationInstrumenter invocationInstrumenter)WrapsCallablewith instrumentation invocations.- Type Parameters:
V- callable generic param- Parameters:
callable-Callableto be wrappedinvocationInstrumenter- instrumenter to be used- Returns:
- wrapper
-
instrument
static java.util.concurrent.Executor instrument(@NonNull java.util.concurrent.Executor executor, @NonNull InvocationInstrumenter invocationInstrumenter)Wraps theexecutorso that every tasks submitted to it will be executed instrumented with the giveninvocationInstrumenter. Execution itself will be delegated to the underlyingexecutor, but it has to be considered that all instrumentation will be done with this very sameinvocationInstrumenterinstance. This is especially useful when follow-up actions of a given task need to be registered, where a new instrumenter, thus a new wrapped executor instance belongs to each task. The returned wrapped executor be of subtypeExecutorServiceorScheduledExecutorServiceif the input executor instance implemented those interfaces.- Parameters:
executor- the executor to wrapinvocationInstrumenter- the instrumenter to be used upon task executions with the returned executor- Returns:
- the wrapped executor
-
-