Interface InvocationInstrumenter
-
public interface InvocationInstrumenter
An interface for invocation instrumentation.- Since:
- 1.3
-
-
Field Summary
Fields Modifier and Type Field Description static InvocationInstrumenter
NOOP
Noop implementation ifInvocationInstrumenter
.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static InvocationInstrumenter
combine(java.util.Collection<InvocationInstrumenter> invocationInstrumenters)
Combines multiple instrumenters into one.static java.lang.Runnable
instrument(java.lang.Runnable runnable, InvocationInstrumenter invocationInstrumenter)
WrapsRunnable
with instrumentation invocations.static java.lang.Runnable
instrument(java.lang.Runnable runnable, java.util.Collection<InvocationInstrumenter> invocationInstrumenters)
WrapsRunnable
with instrumentation invocations.static <V> java.util.concurrent.Callable<V>
instrument(java.util.concurrent.Callable<V> callable, InvocationInstrumenter invocationInstrumenter)
WrapsCallable
with instrumentation invocations.static <V> java.util.concurrent.Callable<V>
instrument(java.util.concurrent.Callable<V> callable, java.util.Collection<InvocationInstrumenter> invocationInstrumenters)
WrapsCallable
with instrumentation invocations.static java.util.concurrent.Executor
instrument(java.util.concurrent.Executor executor, InvocationInstrumenter invocationInstrumenter)
Wraps theexecutor
so that every tasks submitted to it will be executed instrumented with the giveninvocationInstrumenter
.Instrumentation
newInstrumentation()
-
-
-
Field Detail
-
NOOP
static final InvocationInstrumenter NOOP
Noop implementation ifInvocationInstrumenter
.
-
-
Method Detail
-
newInstrumentation
@NonNull Instrumentation newInstrumentation()
- Returns:
- a one-time
Instrumentation
instance 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)
WrapsRunnable
with instrumentation invocations.- Parameters:
runnable
-Runnable
to 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)
WrapsCallable
with instrumentation invocations.- Type Parameters:
V
- callable generic param- Parameters:
callable
-Callable
to be wrappedinvocationInstrumenters
- instrumenters to be used- Returns:
- wrapper
-
instrument
@NonNull static java.lang.Runnable instrument(@NonNull java.lang.Runnable runnable, InvocationInstrumenter invocationInstrumenter)
WrapsRunnable
with instrumentation invocations.- Parameters:
runnable
-Runnable
to 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)
WrapsCallable
with instrumentation invocations.- Type Parameters:
V
- callable generic param- Parameters:
callable
-Callable
to 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 theexecutor
so 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 sameinvocationInstrumenter
instance. 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 subtype
ExecutorService
orScheduledExecutorService
if 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
-
-