asafm commented on code in PR #17041:
URL: https://github.com/apache/pulsar/pull/17041#discussion_r959331016
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/PrometheusMetricsTest.java:
##########
@@ -1522,6 +1517,83 @@ public void testSplitTopicAndPartitionLabel() throws
Exception {
consumer2.close();
}
+
+ @Test
+ public void testMetadataStoreStats() throws Exception {
+ String ns = "prop/ns-abc1";
+ admin.namespaces().createNamespace(ns);
+
+ String topic = "persistent://prop/ns-abc1/metadata-store-" +
UUID.randomUUID();
+ String subName = "my-sub1";
+
+ @Cleanup
+ Producer<String> producer = pulsarClient.newProducer(Schema.STRING)
+ .topic(topic).create();
+ @Cleanup
+ Consumer<String> consumer = pulsarClient.newConsumer(Schema.STRING)
+ .topic(topic).subscriptionName(subName).subscribe();
+
+ for (int i = 0; i < 100; i++) {
+ producer.newMessage().value(UUID.randomUUID().toString()).send();
+ }
+
+ for (;;) {
+ Message<String> message = consumer.receive(10, TimeUnit.SECONDS);
+ if (message == null) {
+ break;
+ }
+ consumer.acknowledge(message);
+ }
+
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
+ PrometheusMetricsGenerator.generate(pulsar, false, false, false,
false, output);
+ String metricsStr = output.toString();
+ Multimap<String, Metric> metricsMap = parseMetrics(metricsStr);
+
+ Collection<Metric> getOpsFailed =
metricsMap.get("pulsar_metadata_store_get_ops_failed" + "_total");
+ Collection<Metric> delOpsFailed =
metricsMap.get("pulsar_metadata_store_del_ops_failed" + "_total");
+ Collection<Metric> putOpsFailed =
metricsMap.get("pulsar_metadata_store_put_ops_failed" + "_total");
+
+ Collection<Metric> getOpsLatency =
metricsMap.get("pulsar_metadata_store_get_ops_latency" + "_sum");
+ Collection<Metric> delOpsLatency =
metricsMap.get("pulsar_metadata_store_del_ops_latency" + "_sum");
+ Collection<Metric> putOpsLatency =
metricsMap.get("pulsar_metadata_store_put_ops_latency" + "_sum");
+
+ Collection<Metric> putBytes =
metricsMap.get("pulsar_metadata_store_put_bytes" + "_total");
+
+ Assert.assertTrue(getOpsFailed.size() > 0);
Review Comment:
One more small thing: It's customary for the person making the comment to
resolve the comment, since he is the one needs to check that it was implemented
- I treat it like a to-do list when I revisit a PR, and resolve when I'm done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]