You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2018/12/22 13:59:55 UTC

[GitHub] sijie closed pull request #2983: add replication_delay to namespace metrics

sijie closed pull request #2983: add replication_delay to namespace metrics
URL: https://github.com/apache/pulsar/pull/2983
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
index d0be156b70..81f62dc50d 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
@@ -1223,6 +1223,10 @@ public void updateRates(NamespaceStats nsStats, NamespaceBundleStats bundleStats
             topicStatsStream.endObject();
 
             nsStats.msgReplBacklog += rStat.replicationBacklog;
+            // replication delay for a namespace is the max repl-delay among all the topics under this namespace
+            if (rStat.replicationDelayInSeconds > nsStats.maxMsgReplDelayInSeconds) {
+                nsStats.maxMsgReplDelayInSeconds = rStat.replicationDelayInSeconds;
+            }
 
             if (replStats.isMetricsEnabled()) {
                 String namespaceClusterKey = replStats.getKeyName(namespace, cluster);
diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/NamespaceStats.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/NamespaceStats.java
index 069e822e35..20f81df416 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/NamespaceStats.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/NamespaceStats.java
@@ -33,6 +33,7 @@
     public double storageSize;
     public double msgBacklog;
     public double msgReplBacklog;
+    public double maxMsgReplDelayInSeconds;
     public int consumerCount;
     public int producerCount;
     public int replicatorCount;
@@ -50,6 +51,7 @@ public void reset() {
         this.storageSize = 0;
         this.msgBacklog = 0;
         this.msgReplBacklog = 0;
+        this.maxMsgReplDelayInSeconds = 0;
         this.consumerCount = 0;
         this.producerCount = 0;
         this.replicatorCount = 0;
@@ -72,6 +74,7 @@ public Metrics add(String namespace) {
         dMetrics.put("brk_no_of_consumers", consumerCount);
         dMetrics.put("brk_msg_backlog", msgBacklog);
         dMetrics.put("brk_replication_backlog", msgReplBacklog);
+        dMetrics.put("brk_max_replication_delay_second", maxMsgReplDelayInSeconds);
 
         return dMetrics;
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services