Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/bvar/multi_dimension.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,15 @@ class MultiDimension : public MVariable {

// Remove all stats so those not count and dump
void delete_stats();

void set_max_stats_count(size_t max_stats_count) {
_max_stats_count = max_stats_count;
}

static size_t init_flatmap(MetricMap& bg);

private:
size_t _max_stats_count;
MetricMapDBD _metric_map;
};

Expand Down
11 changes: 5 additions & 6 deletions src/bvar/multi_dimension_inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ template <typename T>
inline
MultiDimension<T>::MultiDimension(const key_type& labels)
: Base(labels)
, _max_stats_count(MAX_MULTI_DIMENSION_STATS_COUNT)
{
_metric_map.Modify(init_flatmap);
}
Expand All @@ -45,9 +46,8 @@ template <typename T>
inline
MultiDimension<T>::MultiDimension(const butil::StringPiece& name,
const key_type& labels)
: Base(labels)
: MultiDimension(labels)
{
_metric_map.Modify(init_flatmap);
this->expose(name);
}

Expand All @@ -56,9 +56,8 @@ inline
MultiDimension<T>::MultiDimension(const butil::StringPiece& prefix,
const butil::StringPiece& name,
const key_type& labels)
: Base(labels)
: MultiDimension(labels)
{
_metric_map.Modify(init_flatmap);
this->expose_as(prefix, name);
}

Expand Down Expand Up @@ -190,8 +189,8 @@ T* MultiDimension<T>::get_stats_impl(const key_type& labels_value, STATS_OP stat
return nullptr;
}

if (metric_map_ptr->size() > MAX_MULTI_DIMENSION_STATS_COUNT) {
LOG(ERROR) << "Too many stats seen, overflow detected, max stats count:" << MAX_MULTI_DIMENSION_STATS_COUNT;
if (metric_map_ptr->size() > _max_stats_count) {
LOG(ERROR) << "Too many stats seen, overflow detected, max stats count=" << _max_stats_count;
return nullptr;
}
}
Expand Down
2 changes: 2 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ ifeq ($(SYSTEM), Darwin)
DYNAMIC_LINKINGS+=-Wl,-U,_bthread_getspecific
DYNAMIC_LINKINGS+=-Wl,-U,_bthread_setspecific
DYNAMIC_LINKINGS+=-Wl,-U,_bthread_key_create
DYNAMIC_LINKINGS+=-Wl,-U,_bthread_self
DYNAMIC_LINKINGS+=-Wl,-U,_bthread_timed_connect
endif

UT_DYNAMIC_LINKINGS = -lbrpc.dbg $(DYNAMIC_LINKINGS)
Expand Down