Skip to content

Commit

Permalink
[fix][broker]fix bug: fail to expose managed ledger client stats to p…
Browse files Browse the repository at this point in the history
…rometheus if bookkeeperClientExposeStatsToPrometheus is true (#16219)
  • Loading branch information
HQebupt authored Jul 1, 2022
1 parent a9af980 commit f35228d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void initialize(ServiceConfiguration conf, MetadataStoreExtended metadata
StatsLogger statsLogger = statsProvider.getStatsLogger("pulsar_managedLedger_client");

this.defaultBkClient =
bookkeeperProvider.create(conf, metadataStore, eventLoopGroup, Optional.empty(), null);
bookkeeperProvider.create(conf, metadataStore, eventLoopGroup, Optional.empty(), null, statsLogger);

BookkeeperFactoryForCustomEnsemblePlacementPolicy bkFactory = (
EnsemblePlacementPolicyConfig ensemblePlacementPolicyConfig) -> {
Expand All @@ -94,7 +94,7 @@ public void initialize(ServiceConfiguration conf, MetadataStoreExtended metadata
try {
return bookkeeperProvider.create(conf, metadataStore, eventLoopGroup,
Optional.ofNullable(ensemblePlacementPolicyConfig.getPolicyClass()),
ensemblePlacementPolicyConfig.getProperties());
ensemblePlacementPolicyConfig.getProperties(), statsLogger);
} catch (Exception e) {
log.error("Failed to initialize bk-client for policy {}, properties {}",
ensemblePlacementPolicyConfig.getPolicyClass(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,24 @@ public void testManagedLedgerBookieClientStats() throws Exception {
"pulsar_managedLedger_client", "bookkeeper_ml_scheduler_total_tasks"));
assertEquals(cm.size(), 1);
assertEquals(cm.get(0).tags.get("cluster"), "test");

cm = (List<Metric>) metrics.get(
keyNameBySubstrings(metrics,
"pulsar_managedLedger_client", "bookkeeper_ml_scheduler_threads"));
assertEquals(cm.size(), 1);
assertEquals(cm.get(0).tags.get("cluster"), "test");

cm = (List<Metric>) metrics.get(
keyNameBySubstrings(metrics,
"pulsar_managedLedger_client", "bookkeeper_ml_scheduler_task_execution_sum"));
assertEquals(cm.size(), 2);
assertEquals(cm.get(0).tags.get("cluster"), "test");

cm = (List<Metric>) metrics.get(
keyNameBySubstrings(metrics,
"pulsar_managedLedger_client", "bookkeeper_ml_scheduler_max_queue_size"));
assertEquals(cm.size(), 1);
assertEquals(cm.get(0).tags.get("cluster"), "test");
}

private static String keyNameBySubstrings(Multimap<String, Metric> metrics, String... substrings) {
Expand Down

0 comments on commit f35228d

Please sign in to comment.