Skip to content

Commit

Permalink
include ACK in per broker metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
moscicky committed Jan 17, 2024
1 parent 3213615 commit ddf46b5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Timer;
import pl.allegro.tech.hermes.api.Topic;

import java.time.Duration;

Expand All @@ -12,9 +13,10 @@ public BrokerMetrics(MeterRegistry meterRegistry) {
this.meterRegistry = meterRegistry;
}

public void recordBrokerLatency(String broker, Duration duration) {
public void recordBrokerLatency(String broker, Topic.Ack ack, Duration duration) {
Timer.builder("broker.latency")
.tag("broker", broker)
.tag("ack", ack.name())
.publishPercentileHistogram()
.maximumExpectedValue(Duration.ofSeconds(5))
.register(meterRegistry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ private void doReport(Duration duration,
duration.toMillis(), ack, messageId, broker);
}

metricsFacade.broker().recordBrokerLatency(broker, duration);
metricsFacade.broker().recordBrokerLatency(broker, ack, duration);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void shouldReportBrokerLatencyMetrics() {
// then
assertThat(response).hasStatus(CREATED);
wait.until(() -> {
Double metricValue = getMetricValue("hermes_frontend_broker_latency_seconds_count{broker=\"localhost\",").orElse(0.0);
Double metricValue = getMetricValue("hermes_frontend_broker_latency_seconds_count{ack=\"LEADER\",broker=\"localhost\",").orElse(0.0);
assertThat(metricValue).isGreaterThan(0.0d);
}, 5);
}
Expand Down

0 comments on commit ddf46b5

Please sign in to comment.