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

morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 4c571cb  Revert "[Metrics] Support tablet level metrics (#4327)" 
(#4397)
4c571cb is described below

commit 4c571cb6f562334aab75ca0eb7e849d52043352c
Author: Mingyu Chen <[email protected]>
AuthorDate: Wed Aug 19 22:37:52 2020 +0800

    Revert "[Metrics] Support tablet level metrics (#4327)" (#4397)
    
    This reverts commit 56260a65c87830ffe34109195ee4d6f1d543e630.
    
    Co-authored-by: morningman <[email protected]>
---
 be/src/exec/olap_scanner.cpp                           |  3 ---
 be/src/http/action/metrics_action.cpp                  |  5 ++---
 be/src/http/action/stream_load.cpp                     |  2 +-
 be/src/olap/base_tablet.cpp                            | 16 +---------------
 be/src/olap/base_tablet.h                              |  7 -------
 be/src/olap/data_dir.cpp                               |  2 +-
 be/src/olap/delta_writer.cpp                           |  6 +-----
 be/src/olap/memtable_flush_executor.h                  |  2 +-
 be/src/olap/tablet.cpp                                 |  6 ------
 be/src/olap/tablet.h                                   |  4 ----
 be/src/util/metrics.cpp                                | 14 ++++----------
 be/src/util/metrics.h                                  | 18 +++++-------------
 be/test/util/new_metrics_test.cpp                      |  4 ++--
 .../operation/monitor-metrics/be-metrics.md            |  9 ++-------
 .../operation/monitor-metrics/be-metrics.md            |  9 ++-------
 15 files changed, 22 insertions(+), 85 deletions(-)

diff --git a/be/src/exec/olap_scanner.cpp b/be/src/exec/olap_scanner.cpp
index 0b36edc..a9bc32e 100644
--- a/be/src/exec/olap_scanner.cpp
+++ b/be/src/exec/olap_scanner.cpp
@@ -479,9 +479,6 @@ void OlapScanner::update_counter() {
     
DorisMetrics::instance()->query_scan_bytes.increment(_compressed_bytes_read);
     DorisMetrics::instance()->query_scan_rows.increment(_raw_rows_read);
 
-    _tablet->query_scan_bytes.increment(_compressed_bytes_read);
-    _tablet->query_scan_rows.increment(_raw_rows_read);
-
     _has_update_counter = true;
 }
 
diff --git a/be/src/http/action/metrics_action.cpp 
b/be/src/http/action/metrics_action.cpp
index 809bf14..2ffca2f 100644
--- a/be/src/http/action/metrics_action.cpp
+++ b/be/src/http/action/metrics_action.cpp
@@ -34,14 +34,13 @@ namespace doris {
 
 void MetricsAction::handle(HttpRequest* req) {
     const std::string& type = req->param("type");
-    const std::string& with_tablet = req->param("with_tablet");
     std::string str;
     if (type == "core") {
         str = _metric_registry->to_core_string();
     } else if (type == "json") {
-        str = _metric_registry->to_json(with_tablet == "true");
+        str = _metric_registry->to_json();
     } else {
-        str = _metric_registry->to_prometheus(with_tablet == "true");
+        str = _metric_registry->to_prometheus();
     }
 
     req->add_output_header(HttpHeaders::CONTENT_TYPE, "text/plain; 
version=0.0.4");
diff --git a/be/src/http/action/stream_load.cpp 
b/be/src/http/action/stream_load.cpp
index 95231e2..f807972 100644
--- a/be/src/http/action/stream_load.cpp
+++ b/be/src/http/action/stream_load.cpp
@@ -96,7 +96,7 @@ StreamLoadAction::StreamLoadAction(ExecEnv* exec_env) : 
_exec_env(exec_env) {
 }
 
 StreamLoadAction::~StreamLoadAction() {
-    
DorisMetrics::instance()->metric_registry()->deregister_entity(_stream_load_entity->name());
+    
DorisMetrics::instance()->metric_registry()->deregister_entity("stream_load");
 }
 
 void StreamLoadAction::handle(HttpRequest* req) {
diff --git a/be/src/olap/base_tablet.cpp b/be/src/olap/base_tablet.cpp
index f67b649..d544f36 100644
--- a/be/src/olap/base_tablet.cpp
+++ b/be/src/olap/base_tablet.cpp
@@ -17,34 +17,20 @@
 
 #include "olap/base_tablet.h"
 
-#include "gutil/strings/substitute.h"
 #include "olap/data_dir.h"
-#include "util/doris_metrics.h"
 #include "util/path_util.h"
 
 namespace doris {
 
-extern MetricPrototype METRIC_query_scan_bytes;
-extern MetricPrototype METRIC_query_scan_rows;
-
 BaseTablet::BaseTablet(TabletMetaSharedPtr tablet_meta, DataDir* data_dir)
         : _state(tablet_meta->tablet_state()),
           _tablet_meta(tablet_meta),
           _schema(tablet_meta->tablet_schema()),
           _data_dir(data_dir) {
     _gen_tablet_path();
-
-    _metric_entity = 
DorisMetrics::instance()->metric_registry()->register_entity(
-        strings::Substitute("Tablet.$0", tablet_id()),
-        {{"tablet_id", std::to_string(tablet_id())}},
-        MetricEntityType::kTablet);
-    METRIC_REGISTER(_metric_entity, query_scan_bytes);
-    METRIC_REGISTER(_metric_entity, query_scan_rows);
 }
 
-BaseTablet::~BaseTablet() {
-    
DorisMetrics::instance()->metric_registry()->deregister_entity(_metric_entity->name());
-}
+BaseTablet::~BaseTablet() {}
 
 OLAPStatus BaseTablet::set_tablet_state(TabletState state) {
     if (_tablet_meta->tablet_state() == TABLET_SHUTDOWN && state != 
TABLET_SHUTDOWN) {
diff --git a/be/src/olap/base_tablet.h b/be/src/olap/base_tablet.h
index 2e01488..f3b0c2d 100644
--- a/be/src/olap/base_tablet.h
+++ b/be/src/olap/base_tablet.h
@@ -23,7 +23,6 @@
 #include "olap/olap_define.h"
 #include "olap/tablet_meta.h"
 #include "olap/utils.h"
-#include "util/metrics.h"
 
 namespace doris {
 
@@ -75,12 +74,6 @@ protected:
     DataDir* _data_dir;
     std::string _tablet_path;
 
-    // metrics of this tablet
-    MetricEntity* _metric_entity = nullptr;
-public:
-    IntCounter query_scan_bytes;
-    IntCounter query_scan_rows;
-
 private:
     DISALLOW_COPY_AND_ASSIGN(BaseTablet);
 };
diff --git a/be/src/olap/data_dir.cpp b/be/src/olap/data_dir.cpp
index 6a07197..1ecd24e 100644
--- a/be/src/olap/data_dir.cpp
+++ b/be/src/olap/data_dir.cpp
@@ -86,7 +86,7 @@ DataDir::DataDir(const std::string& path, int64_t 
capacity_bytes,
 }
 
 DataDir::~DataDir() {
-    
DorisMetrics::instance()->metric_registry()->deregister_entity(_data_dir_metric_entity->name());
+    
DorisMetrics::instance()->metric_registry()->deregister_entity(std::string("data_dir.")
 + _path);
     delete _id_generator;
     delete _meta;
 }
diff --git a/be/src/olap/delta_writer.cpp b/be/src/olap/delta_writer.cpp
index b93033a..74c76a2 100644
--- a/be/src/olap/delta_writer.cpp
+++ b/be/src/olap/delta_writer.cpp
@@ -60,10 +60,6 @@ DeltaWriter::~DeltaWriter() {
     if (_flush_token != nullptr) {
         // cancel and wait all memtables in flush queue to be finished
         _flush_token->cancel();
-
-        const FlushStatistic& stat = _flush_token->get_stats();
-        _tablet->flush_bytes.increment(stat.flush_size_bytes);
-        _tablet->flush_count.increment(stat.flush_count);
     }
 
     if (_tablet != nullptr) {
@@ -96,7 +92,7 @@ OLAPStatus DeltaWriter::init() {
     TabletManager* tablet_mgr = _storage_engine->tablet_manager();
     _tablet = tablet_mgr->get_tablet(_req.tablet_id, _req.schema_hash);
     if (_tablet == nullptr) {
-        LOG(WARNING) << "fail to find tablet. tablet_id=" << _req.tablet_id
+        LOG(WARNING) << "fail to find tablet . tablet_id=" << _req.tablet_id
                      << ", schema_hash=" << _req.schema_hash;
         return OLAP_ERR_TABLE_NOT_FOUND;
     }
diff --git a/be/src/olap/memtable_flush_executor.h 
b/be/src/olap/memtable_flush_executor.h
index cb789c4..b3d0cbe 100644
--- a/be/src/olap/memtable_flush_executor.h
+++ b/be/src/olap/memtable_flush_executor.h
@@ -35,7 +35,7 @@ class MemTable;
 // use atomic because it may be updated by multi threads
 struct FlushStatistic {
     int64_t flush_time_ns = 0;
-    int64_t flush_count = 0;
+    int64_t flush_count= 0;
     int64_t flush_size_bytes = 0;
 };
 
diff --git a/be/src/olap/tablet.cpp b/be/src/olap/tablet.cpp
index 24e42c4..ca309a4 100644
--- a/be/src/olap/tablet.cpp
+++ b/be/src/olap/tablet.cpp
@@ -48,9 +48,6 @@ using std::sort;
 using std::string;
 using std::vector;
 
-DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(flush_bytes, MetricUnit::BYTES);
-DEFINE_COUNTER_METRIC_PROTOTYPE_2ARG(flush_count, MetricUnit::OPERATIONS);
-
 TabletSharedPtr Tablet::create_tablet_from_meta(TabletMetaSharedPtr 
tablet_meta,
                                                 DataDir* data_dir) {
     return std::make_shared<Tablet>(tablet_meta, data_dir);
@@ -68,9 +65,6 @@ Tablet::Tablet(TabletMetaSharedPtr tablet_meta, DataDir* 
data_dir,
         _cumulative_compaction_type(cumulative_compaction_type) {
     // change _rs_graph to _timestamped_version_tracker
     
_timestamped_version_tracker.construct_versioned_tracker(_tablet_meta->all_rs_metas());
-
-    METRIC_REGISTER(_metric_entity, flush_bytes);
-    METRIC_REGISTER(_metric_entity, flush_count);
 }
 
 OLAPStatus Tablet::_init_once_action() {
diff --git a/be/src/olap/tablet.h b/be/src/olap/tablet.h
index 3da8ae8..e8372fb 100644
--- a/be/src/olap/tablet.h
+++ b/be/src/olap/tablet.h
@@ -300,10 +300,6 @@ private:
     std::unique_ptr<CumulativeCompactionPolicy> _cumulative_compaction_policy;
     std::string _cumulative_compaction_type;
     DISALLOW_COPY_AND_ASSIGN(Tablet);
-
-public:
-    IntCounter flush_bytes;
-    IntCounter flush_count;
 };
 
 inline CumulativeCompactionPolicy* Tablet::cumulative_compaction_policy() {
diff --git a/be/src/util/metrics.cpp b/be/src/util/metrics.cpp
index dc97c05..1a1ff93 100644
--- a/be/src/util/metrics.cpp
+++ b/be/src/util/metrics.cpp
@@ -156,8 +156,8 @@ void MetricEntity::trigger_hook_unlocked(bool force) const {
 MetricRegistry::~MetricRegistry() {
 }
 
-MetricEntity* MetricRegistry::register_entity(const std::string& name, const 
Labels& labels, MetricEntityType type) {
-    std::shared_ptr<MetricEntity> entity = 
std::make_shared<MetricEntity>(type, name, labels);
+MetricEntity* MetricRegistry::register_entity(const std::string& name, const 
Labels& labels) {
+    std::shared_ptr<MetricEntity> entity = 
std::make_shared<MetricEntity>(name, labels);
 
     std::lock_guard<SpinLock> l(_lock);
     DCHECK(_entities.find(name) == _entities.end()) << name;
@@ -187,15 +187,12 @@ void MetricRegistry::trigger_all_hooks(bool force) const {
     }
 }
 
-std::string MetricRegistry::to_prometheus(bool with_tablet_metrics) const {
+std::string MetricRegistry::to_prometheus() const {
     std::stringstream ss;
     // Reorder by MetricPrototype
     EntityMetricsByType entity_metrics_by_types;
     std::lock_guard<SpinLock> l(_lock);
     for (const auto& entity : _entities) {
-        if (entity.second->_type == MetricEntityType::kTablet && 
!with_tablet_metrics) {
-            continue;
-        }
         std::lock_guard<SpinLock> l(entity.second->_lock);
         entity.second->trigger_hook_unlocked(false);
         for (const auto& metric : entity.second->_metrics) {
@@ -227,14 +224,11 @@ std::string MetricRegistry::to_prometheus(bool 
with_tablet_metrics) const {
     return ss.str();
 }
 
-std::string MetricRegistry::to_json(bool with_tablet_metrics) const {
+std::string MetricRegistry::to_json() const {
     rj::Document doc{rj::kArrayType};
     rj::Document::AllocatorType& allocator = doc.GetAllocator();
     std::lock_guard<SpinLock> l(_lock);
     for (const auto& entity : _entities) {
-        if (entity.second->_type == MetricEntityType::kTablet && 
!with_tablet_metrics) {
-            continue;
-        }
         std::lock_guard<SpinLock> l(entity.second->_lock);
         entity.second->trigger_hook_unlocked(false);
         for (const auto& metric : entity.second->_metrics) {
diff --git a/be/src/util/metrics.h b/be/src/util/metrics.h
index 6fa34d3..50093fe 100644
--- a/be/src/util/metrics.h
+++ b/be/src/util/metrics.h
@@ -284,17 +284,10 @@ struct MetricPrototypeEqualTo {
 
 using MetricMap = std::unordered_map<const MetricPrototype*, Metric*, 
MetricPrototypeHash, MetricPrototypeEqualTo>;
 
-enum class MetricEntityType {
-    kServer,
-    kTablet
-};
-
 class MetricEntity {
 public:
-    MetricEntity(MetricEntityType type, const std::string& name, const Labels& 
labels)
-        : _type(type), _name(name), _labels(labels) {}
-
-    const std::string& name() const { return _name; }
+    MetricEntity(const std::string& name, const Labels& labels)
+        : _name(name), _labels(labels) {}
 
     void register_metric(const MetricPrototype* metric_type, Metric* metric);
     void deregister_metric(const MetricPrototype* metric_type);
@@ -308,7 +301,6 @@ public:
 private:
     friend class MetricRegistry;
 
-    MetricEntityType _type;
     std::string _name;
     Labels _labels;
 
@@ -324,14 +316,14 @@ public:
     MetricRegistry(const std::string& name) : _name(name) {}
     ~MetricRegistry();
 
-    MetricEntity* register_entity(const std::string& name, const Labels& 
labels, MetricEntityType type = MetricEntityType::kServer);
+    MetricEntity* register_entity(const std::string& name, const Labels& 
labels);
     void deregister_entity(const std::string& name);
     std::shared_ptr<MetricEntity> get_entity(const std::string& name);
 
     void trigger_all_hooks(bool force) const;
 
-    std::string to_prometheus(bool with_tablet_metrics = false) const;
-    std::string to_json(bool with_tablet_metrics = false) const;
+    std::string to_prometheus() const;
+    std::string to_json() const;
     std::string to_core_string() const;
 
 private:
diff --git a/be/test/util/new_metrics_test.cpp 
b/be/test/util/new_metrics_test.cpp
index 9e33067..67b7aea 100644
--- a/be/test/util/new_metrics_test.cpp
+++ b/be/test/util/new_metrics_test.cpp
@@ -205,7 +205,7 @@ TEST_F(MetricsTest, MetricPrototype) {
 }
 
 TEST_F(MetricsTest, MetricEntityWithMetric) {
-    MetricEntity entity(MetricEntityType::kServer, "test_entity", {});
+    MetricEntity entity("test_entity", {});
 
     IntCounter cpu_idle;
     MetricPrototype cpu_idle_type(MetricType::COUNTER, MetricUnit::PERCENT, 
"cpu_idle");
@@ -234,7 +234,7 @@ TEST_F(MetricsTest, MetricEntityWithMetric) {
 }
 
 TEST_F(MetricsTest, MetricEntityWithHook) {
-    MetricEntity entity(MetricEntityType::kServer, "test_entity", {});
+    MetricEntity entity("test_entity", {});
 
     IntCounter cpu_idle;
     MetricPrototype cpu_idle_type(MetricType::COUNTER, MetricUnit::PERCENT, 
"cpu_idle");
diff --git 
a/docs/en/administrator-guide/operation/monitor-metrics/be-metrics.md 
b/docs/en/administrator-guide/operation/monitor-metrics/be-metrics.md
index 81acc63..4fd45d4 100644
--- a/docs/en/administrator-guide/operation/monitor-metrics/be-metrics.md
+++ b/docs/en/administrator-guide/operation/monitor-metrics/be-metrics.md
@@ -38,14 +38,9 @@ BE metrics can be viewed by visiting:
 
 The default format is of [Prometheus](https://prometheus.io/).
 
-### Optional Parameters
-- You can get Json format by visiting:
+You can get Json format by visiting:
 
-  `http://be_host:be_webserver_port/metrics?type=json`
-
-- You can get Tablet level metrics by visiting:
-
-  `http://be_host:be_webserver_port/metrics?with_tablet=true`
+`http://be_host:be_webserver_port/metrics?type=json`
 
 ## Metrics List
 
diff --git 
a/docs/zh-CN/administrator-guide/operation/monitor-metrics/be-metrics.md 
b/docs/zh-CN/administrator-guide/operation/monitor-metrics/be-metrics.md
index 63576c3..db555ef 100644
--- a/docs/zh-CN/administrator-guide/operation/monitor-metrics/be-metrics.md
+++ b/docs/zh-CN/administrator-guide/operation/monitor-metrics/be-metrics.md
@@ -38,14 +38,9 @@ BE 的监控项可以通过以下方式访问:
 
 默认显示为 [Prometheus](https://prometheus.io/) 格式。
 
-### 可选参数
-- 通过以下接口可以获取 Json 格式的监控项:
+通过以下接口可以获取 Json 格式的监控项:
 
-  `http://be_host:be_webserver_port/metrics?type=json`
-
-- 通过以下接口可以获取 Tablet 级别的监控项:
-  
-  `http://be_host:be_webserver_port/metrics?with_tablet=true`
+`http://be_host:be_webserver_port/metrics?type=json`
 
 ## 监控项列表
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to