Skip to content

Commit

Permalink
[metrics] make 'merged_entities_count_of_tablet' visible when only on…
Browse files Browse the repository at this point in the history
…e 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 <[email protected]>
  • Loading branch information
zhangyifan27 authored and alexeyserbin committed Apr 17, 2020
1 parent 163cd25 commit faae74c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/kudu/tserver/tablet_server-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions src/kudu/util/metrics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit faae74c

Please sign in to comment.