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 2020/04/17 19:47:20 UTC
[kudu] 03/03: [metrics] make 'merged_entities_count_of_tablet'
visible when only one entity merged
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 faae74ce4af6b0c30a7ebd4ff81233576b20162e
Author: zhangyifan27 <ch...@163.com>
AuthorDate: Thu Apr 9 19:27:32 2020 +0800
[metrics] make 'merged_entities_count_of_tablet' visible when only one entity merged
Before this patch, the metric 'merged_entities_count_of_tablet' is hidden
when tablet server aggregate metrics by the same attribute and there is
only one entity merged, because it's modification epoch is not updated.
We should expose the metric in this condition.
Change-Id: Ia74cae25b5bde7d61db1186e44abdff487d3f23f
Reviewed-on: http://gerrit.cloudera.org:8080/15707
Tested-by: Kudu Jenkins
Reviewed-by: Alexey Serbin <as...@cloudera.com>
---
src/kudu/tserver/tablet_server-test.cc | 13 +++++++++++++
src/kudu/util/metrics.cc | 3 +++
2 files changed, 16 insertions(+)
diff --git a/src/kudu/tserver/tablet_server-test.cc b/src/kudu/tserver/tablet_server-test.cc
index 863534a..864032f 100644
--- a/src/kudu/tserver/tablet_server-test.cc
+++ b/src/kudu/tserver/tablet_server-test.cc
@@ -659,6 +659,19 @@ TEST_F(TabletServerTest, TestTombstonedTabletOnWebUI) {
ASSERT_STR_NOT_CONTAINS(s, mini_server_->bound_rpc_addr().ToString());
}
+// When tablet server merge metrics by the same attributes, the metric
+// 'merged_entities_count_of_tablet' should be visible
+TEST_F(TabletServerTest, TestMergedEntitiesCount) {
+ EasyCurl c;
+ faststring buf;
+ const string addr = mini_server_->bound_http_addr().ToString();
+ ASSERT_OK(c.FetchURL(Substitute("http://$0/metrics", addr), &buf));
+ ASSERT_STR_NOT_CONTAINS(buf.ToString(), "merged_entities_count_of_tablet");
+ ASSERT_OK(c.FetchURL(Substitute("http://$0/metrics?merge_rules=tablet|table|table_name", addr),
+ &buf));
+ ASSERT_STR_CONTAINS(buf.ToString(), "merged_entities_count_of_tablet");
+}
+
class TabletServerDiskSpaceTest : public TabletServerTestBase,
public testing::WithParamInterface<string> {
public:
diff --git a/src/kudu/util/metrics.cc b/src/kudu/util/metrics.cc
index f84edab..a48f870 100644
--- a/src/kudu/util/metrics.cc
+++ b/src/kudu/util/metrics.cc
@@ -426,6 +426,9 @@ Status MetricEntity::CollectTo(MergedEntityMetrics* collections,
scoped_refptr<Metric> entry = FindPtrOrNull(entity_collection, prototype);
if (!entry) {
scoped_refptr<Metric> new_metric = metric->snapshot();
+ if (!new_metric->invalid_for_merge_) {
+ new_metric->UpdateModificationEpoch();
+ }
InsertOrDie(&entity_collection, new_metric->prototype(), new_metric);
} else {
entry->MergeFrom(metric);