Skip to content

Commit

Permalink
[ISSUE #8223] Add two metrics rocketmq_topic_number and rocketmq_cons…
Browse files Browse the repository at this point in the history
…umer_group_number (#8225)

* Add tow metric createTopicTime and createSubscriptionTime in broker

* roll back BrokerConfig.java

* Add metric view of createTopicTime and createSubscriptionTime in broker

* Add two metric rocketmq_active_topic_number and rocketmq_active_subscription_number

* Add two metric rocketmq_active_topic_number and rocketmq_active_subscription_number

Signed-off-by: 黄梓淇 <[email protected]>

---------

Signed-off-by: 黄梓淇 <[email protected]>
Co-authored-by: 黄梓淇 <[email protected]>
  • Loading branch information
Stephanie0002 and 黄梓淇 authored May 31, 2024
1 parent 4027139 commit a430796
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class BrokerMetricsConstant {

public static final String GAUGE_PROCESSOR_WATERMARK = "rocketmq_processor_watermark";
public static final String GAUGE_BROKER_PERMISSION = "rocketmq_broker_permission";
public static final String GAUGE_TOPIC_NUM = "rocketmq_topic_number";
public static final String GAUGE_CONSUMER_GROUP_NUM = "rocketmq_consumer_group_number";

public static final String COUNTER_MESSAGES_IN_TOTAL = "rocketmq_messages_in_total";
public static final String COUNTER_MESSAGES_OUT_TOTAL = "rocketmq_messages_out_total";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
import static org.apache.rocketmq.broker.metrics.BrokerMetricsConstant.COUNTER_ROLLBACK_MESSAGES_TOTAL;
import static org.apache.rocketmq.broker.metrics.BrokerMetricsConstant.COUNTER_THROUGHPUT_IN_TOTAL;
import static org.apache.rocketmq.broker.metrics.BrokerMetricsConstant.COUNTER_THROUGHPUT_OUT_TOTAL;
import static org.apache.rocketmq.broker.metrics.BrokerMetricsConstant.GAUGE_TOPIC_NUM;
import static org.apache.rocketmq.broker.metrics.BrokerMetricsConstant.GAUGE_CONSUMER_GROUP_NUM;
import static org.apache.rocketmq.broker.metrics.BrokerMetricsConstant.GAUGE_BROKER_PERMISSION;
import static org.apache.rocketmq.broker.metrics.BrokerMetricsConstant.GAUGE_CONSUMER_CONNECTIONS;
import static org.apache.rocketmq.broker.metrics.BrokerMetricsConstant.GAUGE_CONSUMER_INFLIGHT_MESSAGES;
Expand Down Expand Up @@ -131,6 +133,9 @@ public class BrokerMetricsManager {
// broker stats metrics
public static ObservableLongGauge processorWatermark = new NopObservableLongGauge();
public static ObservableLongGauge brokerPermission = new NopObservableLongGauge();
public static ObservableLongGauge topicNum = new NopObservableLongGauge();
public static ObservableLongGauge consumerGroupNum = new NopObservableLongGauge();


// request metrics
public static LongCounter messagesInTotal = new NopLongCounter();
Expand Down Expand Up @@ -490,6 +495,16 @@ private void initStatsMetrics() {
.setDescription("Broker permission")
.ofLongs()
.buildWithCallback(measurement -> measurement.record(brokerConfig.getBrokerPermission(), newAttributesBuilder().build()));

topicNum = brokerMeter.gaugeBuilder(GAUGE_TOPIC_NUM)
.setDescription("Active topic number")
.ofLongs()
.buildWithCallback(measurement -> measurement.record(brokerController.getTopicConfigManager().getTopicConfigTable().size(), newAttributesBuilder().build()));

consumerGroupNum = brokerMeter.gaugeBuilder(GAUGE_CONSUMER_GROUP_NUM)
.setDescription("Active subscription group number")
.ofLongs()
.buildWithCallback(measurement -> measurement.record(brokerController.getSubscriptionGroupManager().getSubscriptionGroupTable().size(), newAttributesBuilder().build()));
}

private void initRequestMetrics() {
Expand Down

0 comments on commit a430796

Please sign in to comment.