You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by ti...@apache.org on 2022/12/10 16:19:39 UTC

[pulsar] branch master updated: [feat][broker] Provide readable consumer stats time (#14251)

This is an automated email from the ASF dual-hosted git repository.

tison 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 882479f65e8 [feat][broker] Provide readable consumer stats time (#14251)
882479f65e8 is described below

commit 882479f65e89a44262555d1f37ae1a4d622b8deb
Author: Rajan Dhabalia <rd...@apache.org>
AuthorDate: Sat Dec 10 21:49:31 2022 +0530

    [feat][broker] Provide readable consumer stats time (#14251)
    
    Co-authored-by: tison <wa...@gmail.com>
---
 .../pulsar/broker/stats/ConsumerStatsTest.java     |  2 +
 .../policies/data/stats/ConsumerStatsImpl.java     | 13 ++++
 site2/docs/admin-api-topics.md                     | 24 ++++----
 site2/docs/administration-stats.md                 | 70 +++++++++++-----------
 4 files changed, 63 insertions(+), 46 deletions(-)

diff --git a/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/ConsumerStatsTest.java b/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/ConsumerStatsTest.java
index d2eea9e13e4..1b0ee700fd0 100644
--- a/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/ConsumerStatsTest.java
+++ b/pulsar-broker/src/test/java/org/apache/pulsar/broker/stats/ConsumerStatsTest.java
@@ -225,7 +225,9 @@ public class ConsumerStatsTest extends ProducerConsumerBase {
                 "avgMessagesPerEntry",
                 "blockedConsumerOnUnackedMsgs",
                 "readPositionWhenJoining",
+                "lastAckedTime",
                 "lastAckedTimestamp",
+                "lastConsumedTime",
                 "lastConsumedTimestamp",
                 "lastConsumedFlowTimestamp",
                 "keyHashRanges",
diff --git a/pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/stats/ConsumerStatsImpl.java b/pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/stats/ConsumerStatsImpl.java
index b75afaa24cf..ddae2e71356 100644
--- a/pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/stats/ConsumerStatsImpl.java
+++ b/pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/stats/ConsumerStatsImpl.java
@@ -24,6 +24,7 @@ import java.util.Map;
 import java.util.Objects;
 import lombok.Data;
 import org.apache.pulsar.common.policies.data.ConsumerStats;
+import org.apache.pulsar.common.util.DateFormatter;
 
 /**
  * Consumer statistics.
@@ -95,7 +96,11 @@ public class ConsumerStatsImpl implements ConsumerStats {
     @JsonIgnore
     private int clientVersionLength;
 
+    // ignore this json field to skip from stats in future release. replaced with readable #getLastAckedTime().
+    @Deprecated
     public long lastAckedTimestamp;
+    // ignore this json field to skip from stats in future release. replaced with readable #getLastConsumedTime().
+    @Deprecated
     public long lastConsumedTimestamp;
 
     public long lastConsumedFlowTimestamp;
@@ -175,4 +180,12 @@ public class ConsumerStatsImpl implements ConsumerStats {
     public String getReadPositionWhenJoining() {
         return readPositionWhenJoining;
     }
+
+    public String getLastAckedTime() {
+        return DateFormatter.format(lastAckedTimestamp);
+    }
+
+    public String getLastConsumedTime() {
+        return DateFormatter.format(lastConsumedTimestamp);
+    }
 }
diff --git a/site2/docs/admin-api-topics.md b/site2/docs/admin-api-topics.md
index a46d93be310..87c16345b32 100644
--- a/site2/docs/admin-api-topics.md
+++ b/site2/docs/admin-api-topics.md
@@ -12,14 +12,14 @@ import TabItem from '@theme/TabItem';
 
 :::tip
 
- This page only shows **some frequently used operations**.
-
- - For the latest and complete information about `Pulsar admin`, including commands, flags, descriptions, and more, see [Pulsar admin doc](/tools/pulsar-admin/)
- 
- - For the latest and complete information about `REST API`, including parameters, responses, samples, and more, see {@inject: rest:REST:/} API doc.
- 
- - For the latest and complete information about `Java admin API`, including classes, methods, descriptions, and more, see [Java admin API doc](/api/admin/).
- 
+This page only shows **some frequently used operations**.
+
+- For the latest and complete information about `Pulsar admin`, including commands, flags, descriptions, and more, see [Pulsar admin doc](/tools/pulsar-admin/)
+
+- For the latest and complete information about `REST API`, including parameters, responses, samples, and more, see {@inject: rest:REST:/} API doc.
+
+- For the latest and complete information about `Java admin API`, including classes, methods, descriptions, and more, see [Java admin API doc](/api/admin/).
+
 :::
 
 Pulsar has persistent and non-persistent topics. A persistent topic is a logical endpoint for publishing and consuming messages. The topic name structure for persistent topics is:
@@ -593,7 +593,7 @@ admin.topics().examineMessage(topic, "latest", 1);
 </Tabs>
 ````
 
-### Get message ID 
+### Get message ID
 
 You can get message ID published at or just after the given datetime.
 
@@ -1641,7 +1641,7 @@ admin.topics().updatePartitionedTopic(topic, numPartitions);
 ````
 
 ### Delete
-You can delete partitioned topics with the [`delete-partitioned-topic`](/tools/pulsar-admin/) command, REST API and Java. 
+You can delete partitioned topics with the [`delete-partitioned-topic`](/tools/pulsar-admin/) command, REST API and Java.
 
 ````mdx-code-block
 <Tabs groupId="api-choice"
@@ -1951,9 +1951,9 @@ admin.topics().getSubscriptions(topic);
 </Tabs>
 ````
 
-### Unsubscribe subscription 
+### Unsubscribe subscription
 
-When a subscription does not process messages anymore, you can unsubscribe it using one of the following methods. 
+When a subscription does not process messages anymore, you can unsubscribe it using one of the following methods.
 
 ````mdx-code-block
 <Tabs groupId="api-choice"
diff --git a/site2/docs/administration-stats.md b/site2/docs/administration-stats.md
index ec2d6dd1202..ff6a5588a0a 100644
--- a/site2/docs/administration-stats.md
+++ b/site2/docs/administration-stats.md
@@ -37,19 +37,19 @@ The following table outlines the stats of a topic. For more details about how to
 
 ### Producer stats
 
-|Stat|Description|
-|---|---|
-|producerId| The internal identifier for this producer on this topic.|
-|producerName| The internal identifier for this producer, generated by the client library.|
-|address| IP address and source port for the connection of this producer.|
-|connectedSince| The timestamp when this producer is created or reconnected last time.|
-|accessMode| The type of access to the topic that the producer requires.|
-|msgRateIn| The total rate of messages (message per second) published by this publisher.|
-|msgThroughputIn| The total throughput (byte per second) of the messages published by this publisher.|
-|averageMsgSize| The average message size in bytes from this publisher within the last interval.|
-|chunkedMessageRate| The total rate of chunked messages published by this publisher.|
-|clientVersion| The client library version of this producer.|
-|metadata| The metadata (key/value strings) associated with this publisher.|
+| Stat               | Description                                                                         |
+|--------------------|-------------------------------------------------------------------------------------|
+| producerId         | The internal identifier for this producer on this topic.                            |
+| producerName       | The internal identifier for this producer, generated by the client library.         |
+| address            | IP address and source port for the connection of this producer.                     |
+| connectedSince     | The timestamp when this producer is created or reconnected last time.               |
+| accessMode         | The type of access to the topic that the producer requires.                         |
+| msgRateIn          | The total rate of messages (message per second) published by this publisher.        |
+| msgThroughputIn    | The total throughput (byte per second) of the messages published by this publisher. |
+| averageMsgSize     | The average message size in bytes from this publisher within the last interval.     |
+| chunkedMessageRate | The total rate of chunked messages published by this publisher.                     |
+| clientVersion      | The client library version of this producer.                                        |
+| metadata           | The metadata (key/value strings) associated with this publisher.                    |
 
 ### Subscription stats
 
@@ -93,27 +93,29 @@ The following table outlines the stats of a topic. For more details about how to
 
 ### Consumer stats
 
-| Stat                         | Description                                                                                                                                                                                                                                            |
-|------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| consumerName                 | Internal identifier for this consumer, generated by the client library.                                                                                                                                                                                |
-| msgRateOut                   | The total rate of messages (message per second) delivered to the consumer.                                                                                                                                                                             |
-| msgThroughputOut             | The total throughput (byte per second) delivered to the consumer.                                                                                                                                                                                      |
-| availablePermits             | The number of messages that the consumer has space for in the client library's listening queue. `0` means the client library's queue is full and `receive()` isn't called. A non-zero value means this consumer is ready for dispatched messages.      |
-| unackedMessages              | The number of unacknowledged messages for the consumer, where an unacknowledged message has been sent to the consumer but not yet acknowledged. This field is only meaningful when using a subscription that tracks individual message acknowledgment. |
-| blockedConsumerOnUnackedMsgs | The flag used to verify if the consumer is blocked due to reaching the threshold of the unacknowledged messages.                                                                                                                                       |
-| lastConsumedTimestamp        | The timestamp when the consumer reads a message the last time.                                                                                                                                                                                         |
-| lastAckedTimestamp           | The timestamp when the consumer acknowledges a message the last time.                                                                                                                                                                                  |
-| address                      | The IP address and source port for the connection of this consumer.                                                                                                                                                                                    |
-| connectedSince               | The timestamp when this consumer is created or reconnected last time.                                                                                                                                                                                  |
-| clientVersion                | The client library version of this consumer.                                                                                                                                                                                                           |
-| bytesOutCounter              | The total bytes delivered to a consumer.                                                                                                                                                                                                               |
-| msgOutCounter                | The total messages delivered to a consumer.                                                                                                                                                                                                            |
-| msgRateRedeliver             | The total rate of messages redelivered by this consumer (message per second).                                                                                                                                                                          |
-| chunkedMessageRate           | The total rate of chunked messages delivered to this consumer.                                                                                                                                                                                         |
-| avgMessagesPerEntry          | The number of average messages per entry for the consumer consumed.                                                                                                                                                                                    |
-| readPositionWhenJoining      | The read position of the cursor when the consumer joins.                                                                                                                                                                                               |
-| keyHashRanges                | The hash ranges assigned to this consumer if it uses Key_Shared sub mode.                                                                                                                                                                              |
-| metadata                     | The metadata (key/value strings) associated with this consumer.                                                                                                                                                                                        |
+| Stat                               | Description                                                                                                                                                                                                                                            |
+|------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| consumerName                       | Internal identifier for this consumer, generated by the client library.                                                                                                                                                                                |
+| msgRateOut                         | The total rate of messages (message per second) delivered to the consumer.                                                                                                                                                                             |
+| msgThroughputOut                   | The total throughput (byte per second) delivered to the consumer.                                                                                                                                                                                      |
+| availablePermits                   | The number of messages that the consumer has space for in the client library's listening queue. `0` means the client library's queue is full and `receive()` isn't called. A non-zero value means this consumer is ready for dispatched messages.      |
+| unackedMessages                    | The number of unacknowledged messages for the consumer, where an unacknowledged message has been sent to the consumer but not yet acknowledged. This field is only meaningful when using a subscription that tracks individual message acknowledgment. |
+| blockedConsumerOnUnackedMsgs       | The flag used to verify if the consumer is blocked due to reaching the threshold of the unacknowledged messages.                                                                                                                                       |
+| lastConsumedTimestamp (Deprecated) | The timestamp when the consumer reads a message the last time.                                                                                                                                                                                         |
+| lastConsumedTime                   | The time when the consumer reads a message the last time.                                                                                                                                                                                              |
+| lastAckedTimestamp (Deprecated)    | The timestamp when the consumer acknowledges a message the last time.                                                                                                                                                                                  |
+| lastAckedTime                      | The time when the consumer acknowledges a message the last time.                                                                                                                                                                                       |
+| address                            | The IP address and source port for the connection of this consumer.                                                                                                                                                                                    |
+| connectedSince                     | The timestamp when this consumer is created or reconnected last time.                                                                                                                                                                                  |
+| clientVersion                      | The client library version of this consumer.                                                                                                                                                                                                           |
+| bytesOutCounter                    | The total bytes delivered to a consumer.                                                                                                                                                                                                               |
+| msgOutCounter                      | The total messages delivered to a consumer.                                                                                                                                                                                                            |
+| msgRateRedeliver                   | The total rate of messages redelivered by this consumer (message per second).                                                                                                                                                                          |
+| chunkedMessageRate                 | The total rate of chunked messages delivered to this consumer.                                                                                                                                                                                         |
+| avgMessagesPerEntry                | The number of average messages per entry for the consumer consumed.                                                                                                                                                                                    |
+| readPositionWhenJoining            | The read position of the cursor when the consumer joins.                                                                                                                                                                                               |
+| keyHashRanges                      | The hash ranges assigned to this consumer if it uses Key_Shared sub mode.                                                                                                                                                                              |
+| metadata                           | The metadata (key/value strings) associated with this consumer.                                                                                                                                                                                        |
 
 ### Replication stats