You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by li...@apache.org on 2022/07/11 03:13:05 UTC

[rocketmq-clients] 02/02: Export metrics once per second for when debug metric exporting; once per minute in production

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

lizhanhui pushed a commit to branch cpp_dev
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git

commit 9b1eedfcb830f5b56dae4f5f3ad2c436056be260
Author: Li Zhanhui <li...@gmail.com>
AuthorDate: Mon Jul 11 11:12:39 2022 +0800

    Export metrics once per second for when debug metric exporting; once per minute in production
---
 cpp/src/main/cpp/client/BUILD.bazel      | 1 +
 cpp/src/main/cpp/rocketmq/ClientImpl.cpp | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/cpp/src/main/cpp/client/BUILD.bazel b/cpp/src/main/cpp/client/BUILD.bazel
index c56f279..0af283e 100644
--- a/cpp/src/main/cpp/client/BUILD.bazel
+++ b/cpp/src/main/cpp/client/BUILD.bazel
@@ -37,5 +37,6 @@ cc_library(
         "//external:gtest",
     ],
     defines = [
+        "DEBUG_METRIC_EXPORTING",
     ],
 )
\ No newline at end of file
diff --git a/cpp/src/main/cpp/rocketmq/ClientImpl.cpp b/cpp/src/main/cpp/rocketmq/ClientImpl.cpp
index a5e7b62..9ef47be 100644
--- a/cpp/src/main/cpp/rocketmq/ClientImpl.cpp
+++ b/cpp/src/main/cpp/rocketmq/ClientImpl.cpp
@@ -203,7 +203,13 @@ void ClientImpl::start() {
   }
 
   std::weak_ptr<Client> client_weak_ptr(self());
+
+#ifdef DEBUG_METRIC_EXPORTING
+  opencensus::stats::StatsExporter::SetInterval(absl::Seconds(1));
+#else
   opencensus::stats::StatsExporter::SetInterval(absl::Minutes(1));
+#endif
+
   opencensus::stats::StatsExporter::RegisterPushHandler(absl::make_unique<OpencensusExporter>(target, client_weak_ptr));
 }