0

I've set up rsocket metrics using rsocket-micrometer on the CLIENT side, by configuring the RSocketConnector with interceptors, like this (Kotlin):

    rSocketReqesterBuilder.rsocketConnector { configureConnector(it) }

   // ...

    private fun configureConnector(rSocketConnector: RSocketConnector) {
        rSocketConnector.interceptors { iRegistry ->
            // This gives us the rsocket.* counter metrics, like rsocket.frame
            iRegistry.forResponder(MicrometerRSocketInterceptor(registry, *localTags.toArray()))
            iRegistry.forRequester(MicrometerRSocketInterceptor(registry, *localTags.toArray()))
            iRegistry.forConnection(MicrometerDuplexConnectionInterceptor(registry, *localTags.toArray()))
        }
    }

But on the SERVER side, I'm using an annotated (@MessageMapping) Spring Boot RSocket Controller, like this (Java):

    @MessageMapping("replace-channel-controller")
    public Flux<TransformResponse> replace(Flux<String> texts) ...

Here, I'm not explicitly in control of the connector.
How do I add interceptors on the server side?

Eric J Turley
  • 350
  • 1
  • 5
  • 20

1 Answers1

0
@Configuration
public class RSocketConfig implements RSocketServerCustomizer {

    private final MeterRegistry registry;

    public RSocketConfig(MeterRegistry registry) {
        this.registry = registry;
    }

    @Override
    public void customize(RSocketServer rSocketServer) {
        rSocketServer.interceptors(
                iRegistry -> {
                    log.info("Adding RSocket interceptors...");
                    iRegistry.forResponder(new MicrometerRSocketInterceptor(registry, tags));
                    iRegistry.forRequester(new MicrometerRSocketInterceptor(registry, tags));
                    iRegistry.forConnection(new MicrometerDuplexConnectionInterceptor(registry, tags));
                }
        );
    }
}
Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Eric J Turley
  • 350
  • 1
  • 5
  • 20