This is an automated email from the ASF dual-hosted git repository.
guangmingchen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git
The following commit(s) were added to refs/heads/master by this push:
new f6424919 add gflag max_multi_dimension_stats_count (#2894)
f6424919 is described below
commit f642491996b675496330cdd611fc764bd4b80ac7
Author: caidj <[email protected]>
AuthorDate: Thu Feb 20 14:33:10 2025 +0800
add gflag max_multi_dimension_stats_count (#2894)
---
src/bvar/multi_dimension.h | 4 +---
src/bvar/multi_dimension_inl.h | 3 ++-
src/bvar/mvariable.cpp | 11 +++++++++++
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/src/bvar/multi_dimension.h b/src/bvar/multi_dimension.h
index 43be82cc..cc249c5f 100644
--- a/src/bvar/multi_dimension.h
+++ b/src/bvar/multi_dimension.h
@@ -29,8 +29,6 @@
namespace bvar {
-constexpr uint64_t MAX_MULTI_DIMENSION_STATS_COUNT = 20000;
-
template <typename T>
class MultiDimension : public MVariable {
public:
@@ -150,4 +148,4 @@ private:
#include "bvar/multi_dimension_inl.h"
-#endif // BVAR_MULTI_DIMENSION_H
\ No newline at end of file
+#endif // BVAR_MULTI_DIMENSION_H
diff --git a/src/bvar/multi_dimension_inl.h b/src/bvar/multi_dimension_inl.h
index a0158b15..d1132c79 100644
--- a/src/bvar/multi_dimension_inl.h
+++ b/src/bvar/multi_dimension_inl.h
@@ -27,6 +27,7 @@ namespace bvar {
DECLARE_int32(bvar_latency_p1);
DECLARE_int32(bvar_latency_p2);
DECLARE_int32(bvar_latency_p3);
+DECLARE_uint32(max_multi_dimension_stats_count);
static const std::string ALLOW_UNUSED METRIC_TYPE_COUNTER = "counter";
static const std::string ALLOW_UNUSED METRIC_TYPE_SUMMARY = "summary";
@@ -37,7 +38,7 @@ template <typename T>
inline
MultiDimension<T>::MultiDimension(const key_type& labels)
: Base(labels)
- , _max_stats_count(MAX_MULTI_DIMENSION_STATS_COUNT)
+ , _max_stats_count(FLAGS_max_multi_dimension_stats_count)
{
_metric_map.Modify(init_flatmap);
}
diff --git a/src/bvar/mvariable.cpp b/src/bvar/mvariable.cpp
index 86eadf13..26bb97c4 100644
--- a/src/bvar/mvariable.cpp
+++ b/src/bvar/mvariable.cpp
@@ -60,6 +60,17 @@ DEFINE_int32(bvar_max_dump_multi_dimension_metric_number,
1024,
BUTIL_VALIDATE_GFLAG(bvar_max_dump_multi_dimension_metric_number,
validator_bvar_max_dump_multi_dimension_metric_number);
+static bool validator_max_multi_dimension_stats_count(const char*, uint32_t v)
{
+ if (v < 1) {
+ LOG(ERROR) << "Invalid max_multi_dimension_stats_count=" << v;
+ return false;
+ }
+ return true;
+}
+DEFINE_uint32(max_multi_dimension_stats_count, 20000, "Max stats count of a
multi dimension metric.");
+BUTIL_VALIDATE_GFLAG(max_multi_dimension_stats_count,
+ validator_max_multi_dimension_stats_count);
+
class MVarEntry {
public:
MVarEntry() : var(NULL) {}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]