Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[METRICS] use built-in cost functions to fetch beans #1622

Merged
merged 7 commits into from
Mar 30, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix
  • Loading branch information
chia7712 committed Mar 30, 2023
commit 1c9080d92120bccd75bcf59cadd9eb0e5f0980ca
Original file line number Diff line number Diff line change
@@ -92,8 +92,13 @@ public String metricName() {
return metricName;
}

public Gauge fetch(MBeanClient mBeanClient) {
return new Gauge(mBeanClient.bean(ALL.get(this)));
public HasBeanObject fetch(MBeanClient mBeanClient) {
switch (this) {
case CLUSTER_ID:
return new ClusterIdGauge(mBeanClient.bean(ALL.get(this)));
default:
return new Gauge(mBeanClient.bean(ALL.get(this)));
}
}

public static KafkaServer ofAlias(String alias) {
Original file line number Diff line number Diff line change
@@ -72,7 +72,10 @@ void testPublishAndClose() {
Utils.sleep(Duration.ofSeconds(3));
Assertions.assertEquals(Set.of(-1000), fetcher.identities());
Assertions.assertNotEquals(0, queue.size());
queue.forEach((id, es) -> Assertions.assertEquals(beans, es));
queue.forEach(
(id, es) ->
Assertions.assertEquals(
beans, es.stream().distinct().collect(Collectors.toUnmodifiableList())));

var latest = fetcher.latest();
Assertions.assertEquals(1, latest.size());