APISonar


pl.allegro.tech.hermes.common.metric.timer.ConsumerLatencyTimer.time

> pl > allegro > tech > hermes > common > metric > timer > ConsumerLatencyTimer > time
pl APIs allegro APIs tech APIs hermes APIs common APIs metric APIs timer APIs ConsumerLatencyTimer APIs time APIs

Example 1
private ConsumerLatencyTimer consumerLatencyTimer;

    private void sendMessage(final Message message) {
        rateLimiter.acquire();
        ConsumerLatencyTimer.Context timer = consumerLatencyTimer.time();
        CompletableFuture<MessageSendingResult> response = async.within(
                messageSender.send(message),
                Duration.ofMillis(asyncTimeoutMs + requestTimeoutMs)
        );
        response.thenAcceptAsync(new ResponseHandlingListener(message, timer), deliveryReportingExecutor)
                .exceptionally(e -> {
                    logger.error("An error occurred while handling message sending response of subscription {} [partition={}, offset={}, id={}]",
                            subscription.getQualifiedName(), message.getPartition(), message.getOffset(), message.getId(), e);
                    return null;
                });
    }
Example 2
private ConsumerLatencyTimer consumerLatencyTimer;

    private void setUpMetrics(Subscription subscription) {
        when(hermesMetrics.latencyTimer(subscription)).thenReturn(consumerLatencyTimer);
        when(hermesMetrics.consumerErrorsOtherMeter(subscription)).thenReturn(errors);
        when(consumerLatencyTimer.time()).thenReturn(consumerLatencyTimerContext);
        when(hermesMetrics.meter(Meters.FAILED_METER_SUBSCRIPTION, subscription.getTopicName(), subscription.getName())).thenReturn(failedMeter);
    }