This is an automated email from the ASF dual-hosted git repository.
zhangyifan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new 338f82f54 [server] add 'memory_usage' metric for server
338f82f54 is described below
commit 338f82f540f36ee874e79d168234fd2377e86c65
Author: Alexey Serbin <[email protected]>
AuthorDate: Fri Dec 23 16:04:47 2022 -0800
[server] add 'memory_usage' metric for server
Recently, from a post-mortem analysis of diagnostic logs created by
kudu-tserver process, I realized it would be useful to know current
memory consumption along with other metrics and stack traces of all
the threads run by the process.
I didn't add any tests for the newly introduced metric, but I manually
verified that both kudu-master and kudu-tserver processes properly
reported current memory usage among other server metrics at the
"/metrics" HTTP endpoint. The newly introduced metric was also present
in the diagnostic log files, and it was possible to extract the readings
of the metric by running the following kudu CLI command on the
corresponding files:
kudu diagnose parse_metrics --simple_metrics=server.memory_usage
Change-Id: If066be928bd1c7c3f37c875937ae8802dd8fcd33
Reviewed-on: http://gerrit.cloudera.org:8080/19389
Tested-by: Kudu Jenkins
Reviewed-by: Yifan Zhang <[email protected]>
---
src/kudu/server/server_base.cc | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/kudu/server/server_base.cc b/src/kudu/server/server_base.cc
index 5c9029534..8ca83ab88 100644
--- a/src/kudu/server/server_base.cc
+++ b/src/kudu/server/server_base.cc
@@ -271,6 +271,14 @@ METRIC_DEFINE_gauge_int64(server,
data_dirs_space_available_bytes,
"-1 if reading any of the disks fails",
kudu::MetricLevel::kInfo);
+#ifdef TCMALLOC_ENABLED
+METRIC_DEFINE_gauge_int64(server, memory_usage,
+ "Current Memory Usage",
+ kudu::MetricUnit::kBytes,
+ "Current memory usage of the server process",
+ kudu::MetricLevel::kInfo);
+#endif // #ifdef TCMALLOC_ENABLED
+
using kudu::security::RpcAuthentication;
using kudu::security::RpcEncryption;
using std::ostringstream;
@@ -939,6 +947,14 @@ Status ServerBase::Start() {
metric_entity_,
[this]() {return (MonoTime::Now() -
this->start_time()).ToMicroseconds();})->
AutoDetachToLastValue(&metric_detacher_);
+
+#ifdef TCMALLOC_ENABLED
+ METRIC_memory_usage.InstantiateFunctionGauge(
+ metric_entity_,
+ []() {return process_memory::CurrentConsumption();})->
+ AutoDetachToLastValue(&metric_detacher_);
+#endif // #ifdef TCMALLOC_ENABLED
+
METRIC_data_dirs_space_available_bytes.InstantiateFunctionGauge(
metric_entity_,
[this]() {