public RSocket applyServer(RSocket rSocket) { for (RSocketInterceptor i : servers) { rSocket = i.apply(rSocket); } return rSocket; }
public ClientRSocketFactory addConnectionPlugin(DuplexConnectionInterceptor interceptor) { plugins.addConnectionPlugin(interceptor); return this; }
public ServerRSocketFactory addClientPlugin(RSocketInterceptor interceptor) { plugins.addClientPlugin(interceptor); return this; }
private static Counter counter( Type connectionType, MeterRegistry meterRegistry, String frameType, Tag... tags) { return meterRegistry.counter( "rsocket.frame", Tags.of(tags).and("connection.type", connectionType.name()).and("frame.type", frameType)); } }
missedAcks); RSocket wrappedRSocketClient = plugins.applyClient(rSocketClient); RSocket wrappedRSocketServer = plugins.applyServer(unwrappedServerSocket);
public ClientRSocketFactory addServerPlugin(RSocketInterceptor interceptor) { plugins.addServerPlugin(interceptor); return this; }
public DuplexConnection applyConnection( DuplexConnectionInterceptor.Type type, DuplexConnection connection) { for (DuplexConnectionInterceptor i : connections) { connection = i.apply(type, connection); } return connection; } }
@Before public void setup() { source = new TestDuplexConnection(); multiplexer = new ClientServerInputMultiplexer(source, new PluginRegistry()); }
/** * Creates a new {@link DuplexConnection}. * * @param connectionType the type of connection being monitored * @param delegate the {@link DuplexConnection} to delegate to * @param meterRegistry the {@link MeterRegistry} to use * @param tags additional tags to attach to {@link Meter}s * @throws NullPointerException if {@code connectionType}, {@code delegate}, or {@code * meterRegistry} is {@code null} */ MicrometerDuplexConnection( Type connectionType, DuplexConnection delegate, MeterRegistry meterRegistry, Tag... tags) { Objects.requireNonNull(connectionType, "connectionType must not be null"); this.delegate = Objects.requireNonNull(delegate, "delegate must not be null"); Objects.requireNonNull(meterRegistry, "meterRegistry must not be null"); this.close = meterRegistry.counter( "rsocket.duplex.connection.close", Tags.of(tags).and("connection.type", connectionType.name())); this.dispose = meterRegistry.counter( "rsocket.duplex.connection.dispose", Tags.of(tags).and("connection.type", connectionType.name())); this.frameCounters = new FrameCounters(connectionType, meterRegistry, tags); }
StreamIdSupplier.serverSupplier()); RSocket wrappedRSocketClient = plugins.applyClient(rSocketClient); .doOnNext( unwrappedServerSocket -> { RSocket wrappedRSocketServer = plugins.applyServer(unwrappedServerSocket);
public ServerRSocketFactory addConnectionPlugin(DuplexConnectionInterceptor interceptor) { plugins.addConnectionPlugin(interceptor); return this; }
public ClientRSocketFactory addClientPlugin(RSocketInterceptor interceptor) { plugins.addClientPlugin(interceptor); return this; }
public ServerRSocketFactory addServerPlugin(RSocketInterceptor interceptor) { plugins.addServerPlugin(interceptor); return this; }
public RSocket applyClient(RSocket rSocket) { for (RSocketInterceptor i : clients) { rSocket = i.apply(rSocket); } return rSocket; }
private Counter findCounter(Type connectionType, FrameType frameType) { return meterRegistry .get("rsocket.frame") .tag("connection.type", connectionType.name()) .tag("frame.type", frameType.name()) .tag("test-key", "test-value") .counter(); } }
public static void interceptConnection(DuplexConnectionInterceptor interceptor) { DEFAULT.addConnectionPlugin(interceptor); }
public static void interceptClient(RSocketInterceptor interceptor) { DEFAULT.addClientPlugin(interceptor); }
public static void interceptServer(RSocketInterceptor interceptor) { DEFAULT.addServerPlugin(interceptor); }
@DisplayName("dispose gathers metrics") @Test void dispose() { new MicrometerDuplexConnection( CLIENT, delegate, meterRegistry, Tag.of("test-key", "test-value")) .dispose(); assertThat( meterRegistry .get("rsocket.duplex.connection.dispose") .tag("connection.type", CLIENT.name()) .tag("test-key", "test-value") .counter() .count()) .isEqualTo(1); }
@DisplayName("onClose gathers metrics") @Test void onClose() { when(delegate.onClose()).thenReturn(Mono.empty()); new MicrometerDuplexConnection( CLIENT, delegate, meterRegistry, Tag.of("test-key", "test-value")) .onClose() .subscribe(Operators.drainSubscriber()); assertThat( meterRegistry .get("rsocket.duplex.connection.close") .tag("connection.type", CLIENT.name()) .tag("test-key", "test-value") .counter() .count()) .isEqualTo(1); }