Skip to content

Latest commit

 

History

History
40 lines (32 loc) · 1.42 KB

custom_integrations.md

File metadata and controls

40 lines (32 loc) · 1.42 KB

Custom integrations

BlockHound can be extended without changing its code by using the JVM's SPI mechanism.

You will need to implement reactor.blockhound.integration.BlockHoundIntegration interface and add the implementor to META-INF/services/reactor.blockhound.integration.BlockHoundIntegration file.

ℹ️ Hint: consider using Google's AutoService for it:

@AutoService(BlockHoundIntegration.class)
public class MyIntegration implements BlockHoundIntegration {
    // ...
}

Writing integrations

An integration is just a consumer of BlockHound's Builder and uses the same API as described in customization.

Here is an example:

public class MyIntegration implements BlockHoundIntegration {

    @Override
    public void applyTo(BlockHound.Builder builder) {
        builder.nonBlockingThreadPredicate(current -> {
            return current.or(t -> {
                if (t.getName() == null) {
                    return false;
                }
                return t.getName().contains("my-pool-");
            });
        });
    }
}

BlockHound's built-in integrations use the same mechanism and can be used as more advanced examples:
https://github.com/reactor/BlockHound/tree/master/agent/src/main/java/reactor/blockhound/integration