Package reactor.blockhound
Class BlockHound.Builder
java.lang.Object
reactor.blockhound.BlockHound.Builder
- Enclosing class:
- BlockHound
-
Method Summary
Modifier and TypeMethodDescriptionaddDynamicThreadPredicate(Predicate<Thread> predicate) Appends the provided predicate to the current one.allowBlockingCallsInside(String className, String methodName) Allows blocking calls inside any method of a class with name identified by the provided className and which name matches the provided methodName.blockingMethodCallback(Consumer<BlockingMethod> consumer) Overrides the callback that is being triggered when a blocking method is detecteddisallowBlockingCallsInside(String className, String methodName) Disallows blocking calls inside any method of a class with name identified by the provided className and which name matches the provided methodName.Replaces the current dynamic thread predicate with the result of applying the provided function.voidinstall()Installs the agent and runs the instrumentation, but only if BlockHound wasn't installed yet (it is global).loadIntegrations(BlockHoundIntegration... integrations) Loads integrations withServiceLoaderand adds provided integrations using {with(BlockHoundIntegration)}.markAsBlocking(Class clazz, String methodName, String signature) Marks provided method of the provided class as "blocking".markAsBlocking(String className, String methodName, String signature) Marks provided method of the class identified by the provided name as "blocking".Replaces the current non-blocking thread predicate with the result of applying the provided function.with(Instrumentation instrumentation) Configure theInstrumentationto use.with(BlockHoundIntegration integration) Applies the providedBlockHoundIntegrationto the current builder
-
Method Details
-
markAsBlocking
Marks provided method of the provided class as "blocking". The descriptor should be in JVM's format: https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/types.html#wp276- Parameters:
clazz- a class referencemethodName- a method namesignature- a method descriptor in JVM's format- Returns:
- this
-
markAsBlocking
Marks provided method of the class identified by the provided name as "blocking". The descriptor should be in JVM's format: https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/types.html#wp276- Parameters:
className- class' name (e.g. "java.lang.Thread")methodName- a method namesignature- a method signature (in JVM's format)- Returns:
- this
-
allowBlockingCallsInside
Allows blocking calls inside any method of a class with name identified by the provided className and which name matches the provided methodName.There are two special cases for
methodName:-
static initializers are currently supported by their JVM reserved name of
"<clinit>" - constructors are currently not supported (ByteBuddy cannot weave the necessary instrumentation around a constructor that throws an exception, see gh174)
- Parameters:
className- class' name (e.g. "java.lang.Thread")methodName- a method name- Returns:
- this
-
static initializers are currently supported by their JVM reserved name of
-
disallowBlockingCallsInside
Disallows blocking calls inside any method of a class with name identified by the provided className and which name matches the provided methodName.There are two special cases for
methodName:-
static initializers are currently supported by their JVM reserved name of
"<clinit>" - constructors are currently not supported (ByteBuddy cannot weave the necessary instrumentation around a constructor that throws an exception, see gh174)
- Parameters:
className- class' name (e.g. "java.lang.Thread")methodName- a method name- Returns:
- this
-
static initializers are currently supported by their JVM reserved name of
-
blockingMethodCallback
Overrides the callback that is being triggered when a blocking method is detected- Parameters:
consumer- a consumer of the detected blocking method call's description (BlockingMethod).- Returns:
- this
-
nonBlockingThreadPredicate
public BlockHound.Builder nonBlockingThreadPredicate(Function<Predicate<Thread>, Predicate<Thread>> function) Replaces the current non-blocking thread predicate with the result of applying the provided function. Warning! Consider always usingPredicate.or(Predicate)and not override the previous one:nonBlockingThreadPredicate(current -> current.or(MyMarker.class::isInstance))- Parameters:
function- a function to immediately apply on the current instance of the predicate- Returns:
- this
-
dynamicThreadPredicate
public BlockHound.Builder dynamicThreadPredicate(Function<Predicate<Thread>, Predicate<Thread>> function) Replaces the current dynamic thread predicate with the result of applying the provided function. Warning! Consider always usingPredicate.or(Predicate)and not override the previous one:dynamicThreadPredicate(current -> current.or(MyMarker.class::isInstance))- Parameters:
function- a function to immediately apply on the current instance of the predicate- Returns:
- this
-
addDynamicThreadPredicate
Appends the provided predicate to the current one.- Parameters:
predicate- a predicate to append to the current instance of the predicate- Returns:
- this
-
loadIntegrations
Loads integrations withServiceLoaderand adds provided integrations using {with(BlockHoundIntegration)}. If you don't want to load the integrations using service loader, only usewith(BlockHoundIntegration)method.- Parameters:
integrations- an array of integrations to automatically apply on the builder usingwith(BlockHoundIntegration)- Returns:
- this
- See Also:
-
with
Applies the providedBlockHoundIntegrationto the current builder- Parameters:
integration- an integration to apply- Returns:
- this
-
with
Configure theInstrumentationto use. If not provided,ByteBuddyAgent.install()is used.- Parameters:
instrumentation- The instrumentation instance to use.- Returns:
- this
-
install
public void install()Installs the agent and runs the instrumentation, but only if BlockHound wasn't installed yet (it is global).
-