pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From si...@apache.org
Subject [pulsar] branch master updated: add replication_delay to namespace metrics (#2983)
Date Sat, 22 Dec 2018 13:59:58 GMT
This is an automated email from the ASF dual-hosted git repository.

sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/master by this push:
     new a901a35  add replication_delay to namespace metrics (#2983)
a901a35 is described below

commit a901a35e5c6a18e2bccdc4320a8bb86678f83f74
Author: Rajan Dhabalia <rdhabalia@apache.org>
AuthorDate: Sat Dec 22 05:59:53 2018 -0800

    add replication_delay to namespace metrics (#2983)
    
    ### Motivation
    
    Right now, broker metrics provide `replicationDelay` per topic level but we have setup
monitoring on namespace metrics `./pulsar-admin  broker-stats monitoring-metrics` and we also
need `replicationDelay` at namespace level to get estimate delay from namespace graphs.
    
    ### Modifications
    
    Find out max replication-delay among all the topics of a namespace and use it to namespace-metrics
to provide estimate repl-dealy for a namespace.
---
 .../org/apache/pulsar/broker/service/persistent/PersistentTopic.java  | 4 ++++
 .../src/main/java/org/apache/pulsar/broker/stats/NamespaceStats.java  | 3 +++
 2 files changed, 7 insertions(+)

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 eed5b27..cc73d0c 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
@@ -1238,6 +1238,10 @@ public class PersistentTopic implements Topic, AddEntryCallback {
             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 069e822..20f81df 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 class NamespaceStats {
     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 class NamespaceStats {
         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 class NamespaceStats {
         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;
 


Mime
View raw message