-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A metrics reporting issue was observed where infrequent updates to percentile timers resulted in inconsistent reporting of metrics values. Unusual peaks and valleys were seen on the query side. Capturing measurement reporting from the spectatord process revealed that the base timer values were being reported in a consistent manner, but some of the percentile counters were missing. The percentile timer meters kept a local cache of the percentile counters, with shared pointer references to corresponding meters in the Registry. When the Registry expires meters, it does so based upon last update time, rather than the number of pointers still held. Thus, infrequently used percentile counters were removed from the Registry, but remained within the local percentile timer cache. The cached values would be updated, but this would not translate to the Registry, and there was no opportunity to recreate them. The fix is to remove the local percentile counter cache from the percentile timer meter, and rely on the Registry to keep track of all counters. If one is expired, it will then be recreated. This will add a little bit of overhead, but it should be minimal. The same applies to the percentile distribution summaries.
- Loading branch information
1 parent
b1fa055
commit 6461d38
Showing
5 changed files
with
14 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,19 @@ | ||
#pragma once | ||
|
||
#include "../percentile_buckets.h" | ||
#include "../registry.h" | ||
#include <array> | ||
|
||
namespace spectator::detail { | ||
|
||
#include "../percentile_bucket_tags.inc" | ||
|
||
using counters_t = | ||
std::array<std::shared_ptr<Counter>, PercentileBucketsLength()>; | ||
|
||
struct lazy_policy { | ||
static void init(Registry* /* r */, const Id& /* id */, | ||
counters_t* /* counters */, | ||
const std::string* /* perc_tags */) {} | ||
static auto get_counter(Registry* r, const Id& id, | ||
counters_t* counters, | ||
size_t index, | ||
const std::string* perc_tags) -> std::shared_ptr<Counter> { | ||
static auto get_counter(Registry* r, const Id& id, size_t index, const std::string* perc_tags) | ||
-> std::shared_ptr<Counter> { | ||
using spectator::refs; | ||
auto& c = counters->at(index); | ||
if (!c) { | ||
auto counterId = | ||
id.WithTags(refs().statistic(), refs().percentile(), | ||
refs().percentile(), intern_str(perc_tags[index])); | ||
counters->at(index) = r->GetCounter(std::move(counterId)); | ||
c = counters->at(index); | ||
} | ||
return c; | ||
auto counterId = id.WithTags(refs().statistic(), refs().percentile(), refs().percentile(), | ||
intern_str(perc_tags[index])); | ||
return r->GetCounter(std::move(counterId)); | ||
} | ||
}; | ||
|
||
} // namespace spectator::detail | ||
} // namespace spectator::detail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters