You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by al...@apache.org on 2024/04/02 23:39:03 UTC

(kudu) branch master updated (d980c688d -> dd4e37b44)

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

alexey pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git


    from d980c688d [rpc] relax settings for MeasureAcceptorDispatchTimes
     new ab368443d [tests] fix a misprint
     new dd4e37b44 KUDU-3561 skip tablet entities in Prometheus format

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../integration-tests/disk_reservation-itest.cc    |  2 +-
 src/kudu/util/metrics.cc                           | 51 +++++++++++++---------
 2 files changed, 32 insertions(+), 21 deletions(-)


(kudu) 02/02: KUDU-3561 skip tablet entities in Prometheus format

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit dd4e37b445da7f367746fb83d92e21b8dc3d8eb8
Author: Alexey Serbin <al...@apache.org>
AuthorDate: Sun Mar 31 21:05:36 2024 -0700

    KUDU-3561 skip tablet entities in Prometheus format
    
    Currently, the Prometheus metrics writer outputs only server-level
    metrics.  Prior to this patch, the Prometheus metrics writer would
    output a warning message for every tablet it encounters while iterating
    through all the existing metric entities.
    
    This patch addresses the issue: the tablet entries are now silently
    skipped, as they should.
    
    I also added a TODO for KUDU-3563 to output tablet-level metrics
    in Prometheus format as well.
    
    Change-Id: I618bbc2caab7a8d9812eeaeb67ac42b0293b0654
    Reviewed-on: http://gerrit.cloudera.org:8080/21226
    Reviewed-by: Mahesh Reddy <mr...@cloudera.com>
    Reviewed-by: Abhishek Chennaka <ac...@cloudera.com>
    Tested-by: Alexey Serbin <al...@apache.org>
---
 src/kudu/util/metrics.cc | 51 +++++++++++++++++++++++++++++-------------------
 1 file changed, 31 insertions(+), 20 deletions(-)

diff --git a/src/kudu/util/metrics.cc b/src/kudu/util/metrics.cc
index dfcea6db1..0f1590de5 100644
--- a/src/kudu/util/metrics.cc
+++ b/src/kudu/util/metrics.cc
@@ -405,15 +405,25 @@ Status MetricEntity::WriteAsJson(JsonWriter* writer, const MetricJsonOptions& op
 }
 
 Status MetricEntity::WriteAsPrometheus(PrometheusWriter* writer) const {
-  MetricMap metrics;
-  AttributeMap attrs;
+  static const string kIdMaster = "kudu.master";
+  static const string kIdTabletServer = "kudu.tabletserver";
+
+  if (strcmp(prototype_->name(), "server") != 0) {
+    // Only server-level metrics are emitted in Prometheus format as of now,
+    // non-server metric entities are currently silently skipped.
+    //
+    // TODO(KUDU-3563): output tablet-level metrics in Prometheus format as well
+    return Status::OK();
+  }
+
+  // Empty filters result in getting all the metrics for this MetricEntity.
+  //
+  // TODO(aserbin): instead of hard-coding, pass MetricFilters as a parameter
   MetricFilters filters;
   filters.entity_level = "debug";
-  const string master_prefix = "kudu_master_";
-  const string tserver_prefix = "kudu_tserver_";
-  const string master_server = "kudu.master";
-  const string tablet_server = "kudu.tabletserver";
-  // Empty filters results in getting all the metrics for this MetricEntity.
+
+  MetricMap metrics;
+  AttributeMap attrs;
   const auto s = GetMetricsAndAttrs(filters, &metrics, &attrs);
   if (s.IsNotFound()) {
     // Status::NotFound is returned when this entity has been filtered, treat it
@@ -421,21 +431,22 @@ Status MetricEntity::WriteAsPrometheus(PrometheusWriter* writer) const {
     return Status::OK();
   }
   RETURN_NOT_OK(s);
-  // Only emit server level metrics
-  if (strcmp(prototype_->name(), "server") == 0) {
-    if (id_ == master_server) {
-      // attach kudu_master_ as prefix to metrics
-      WriteMetricsPrometheus(writer, metrics, master_prefix);
-      return Status::OK();
-    }
-    if (id_ == tablet_server) {
-      // attach kudu_tserver_ as prefix to metrics
-      WriteMetricsPrometheus(writer, metrics, tserver_prefix);
-      return Status::OK();
-    }
+
+  if (id_ == kIdMaster) {
+    // Prefix all master metrics with 'kudu_master_'.
+    static const string kMasterPrefix = "kudu_master_";
+    WriteMetricsPrometheus(writer, metrics, kMasterPrefix);
+    return Status::OK();
+  }
+  if (id_ == kIdTabletServer) {
+    // Prefix all tablet server metrics with 'kudu_tserver_'.
+    static const string kTabletServerPrefix = "kudu_tserver_";
+    WriteMetricsPrometheus(writer, metrics, kTabletServerPrefix);
+    return Status::OK();
   }
 
-  return Status::NotFound("Entity is not relevant to Prometheus");
+  return Status::NotSupported(
+      Substitute("$0: unexpected server-level metric entity", id_));
 }
 
 Status MetricEntity::CollectTo(MergedEntityMetrics* collections,


(kudu) 01/02: [tests] fix a misprint

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit ab368443d276006e93370a5b6bd5862eea2475fe
Author: Alexey Serbin <al...@apache.org>
AuthorDate: Mon Apr 1 19:40:38 2024 -0700

    [tests] fix a misprint
    
    Tests should use ASSERT_NE(), not DCHECK_NE().
    
    This is a follow-up to e54c80cf9ba129b943eed6af3266899753b1b4ac.
    
    Change-Id: I78428cf60449820508f995c4a7c2a84582ce32c1
    Reviewed-on: http://gerrit.cloudera.org:8080/21229
    Tested-by: Alexey Serbin <al...@apache.org>
    Reviewed-by: Mahesh Reddy <mr...@cloudera.com>
    Reviewed-by: Abhishek Chennaka <ac...@cloudera.com>
---
 src/kudu/integration-tests/disk_reservation-itest.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/kudu/integration-tests/disk_reservation-itest.cc b/src/kudu/integration-tests/disk_reservation-itest.cc
index 519a2dfa7..d7e8dad01 100644
--- a/src/kudu/integration-tests/disk_reservation-itest.cc
+++ b/src/kudu/integration-tests/disk_reservation-itest.cc
@@ -177,7 +177,7 @@ TEST_F(DiskReservationITest, AvailableSpaceMetrics) {
   NO_FATALS(StartCluster(ts_flags, {}, 1));
 
   auto* ts = cluster_->tablet_server(0);
-  DCHECK_NE(nullptr, ts);
+  ASSERT_NE(nullptr, ts);
   const auto& addr = ts->bound_http_hostport();
 
   auto space_getter_data_dirs = [&](int64_t* available_bytes) {