use of io.lettuce.core.event.metrics.CommandLatencyEvent in project lettuce-core by lettuce-io.
the class JfrEventRecorderUnitTests method shouldNotEmitEventForAbsentJfrEventType.
@Test
void shouldNotEmitEventForAbsentJfrEventType() throws IOException {
Recording recording = new Recording();
recording.start();
EventRecorder.getInstance().record(new CommandLatencyEvent(Collections.emptyMap()));
recording.stop();
File temp = getFile(recording);
RecordingFile input = new RecordingFile(temp.toPath());
assertThat(input.hasMoreEvents()).isFalse();
input.close();
}
use of io.lettuce.core.event.metrics.CommandLatencyEvent in project lettuce-core by lettuce-io.
the class ClientMetricsIntegrationTests method testMetricsEvent.
@Test
@Inject
void testMetricsEvent(RedisClient client, StatefulRedisConnection<String, String> connection) {
Collection<CommandLatencyEvent> events = new LinkedBlockingQueue<>();
EventBus eventBus = client.getResources().eventBus();
MetricEventPublisher publisher = (MetricEventPublisher) ReflectionTestUtils.getField(client.getResources(), "metricEventPublisher");
publisher.emitMetricsEvent();
Disposable disposable = eventBus.get().filter(redisEvent -> redisEvent instanceof CommandLatencyEvent).cast(CommandLatencyEvent.class).doOnNext(events::add).subscribe();
generateTestData(connection.sync());
publisher.emitMetricsEvent();
Wait.untilTrue(() -> !events.isEmpty()).waitOrTimeout();
assertThat(events).isNotEmpty();
disposable.dispose();
}
Aggregations