Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
deb76f8
Add ability to filter stats to be flushed to sinks.
pradeepcrao Oct 27, 2021
6215133
Merge remote-tracking branch 'upstream/main' into stats_filter2
pradeepcrao Oct 27, 2021
5c593e3
Merge remote-tracking branch 'upstream/main' into stats_filter2
pradeepcrao Oct 27, 2021
e0f6a99
Add tests for histograms.
pradeepcrao Nov 9, 2021
58d423a
Merge remote-tracking branch 'upstream/main' into stats_filter2
pradeepcrao Nov 9, 2021
d82fb8f
Fix format.
pradeepcrao Nov 9, 2021
b8c7472
Merge remote-tracking branch 'upstream/main' into stats_filter2
pradeepcrao Nov 9, 2021
6f0eecc
Merge remote-tracking branch 'upstream/main' into histograms
pradeepcrao Dec 1, 2021
0a95f77
Merge remote-tracking branch 'upstream/main' into histograms
pradeepcrao Dec 1, 2021
5798431
Fix tests.
pradeepcrao Dec 1, 2021
155447b
Merge remote-tracking branch 'upstream/main' into histograms
pradeepcrao Dec 1, 2021
b430e67
Add tests.
pradeepcrao Dec 2, 2021
2544e4f
Address feedback.
pradeepcrao Jan 4, 2022
2376924
Merge remote-tracking branch 'upstream/main' into histograms
pradeepcrao Jan 4, 2022
560a6f9
Fix test.
pradeepcrao Jan 19, 2022
bb2de6e
Merge remote-tracking branch 'upstream/main' into histograms
pradeepcrao Jan 19, 2022
eb89117
Add method to get sink predicates from StoreRoot.
pradeepcrao Jan 20, 2022
3394bf9
Merge remote-tracking branch 'upstream/main' into histograms
pradeepcrao Jan 20, 2022
9ae13c6
Fix Format.
pradeepcrao Jan 20, 2022
f68aa44
Address feedback.
pradeepcrao Jan 20, 2022
9a85185
Merge remote-tracking branch 'upstream/main' into histograms
pradeepcrao Jan 20, 2022
b44b4af
Merge remote-tracking branch 'upstream/main' into histograms_for_each
pradeepcrao Jan 26, 2022
6e6635a
Add for each iteration for histograms.
pradeepcrao Jan 26, 2022
d1dda13
Address feedback.
pradeepcrao Feb 1, 2022
7f9798b
Merge remote-tracking branch 'upstream/main' into histograms_for_each
pradeepcrao Feb 1, 2022
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
1 change: 1 addition & 0 deletions envoy/stats/store.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class Store : public Scope {
virtual void forEachCounter(SizeFn f_size, StatFn<Counter> f_stat) const PURE;
virtual void forEachGauge(SizeFn f_size, StatFn<Gauge> f_stat) const PURE;
virtual void forEachTextReadout(SizeFn f_size, StatFn<TextReadout> f_stat) const PURE;
virtual void forEachHistogram(SizeFn f_size, StatFn<ParentHistogram> f_stat) const PURE;
virtual void forEachScope(SizeFn f_size, StatFn<const Scope> f_stat) const PURE;

/**
Expand Down
5 changes: 5 additions & 0 deletions source/common/stats/isolated_store_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ class IsolatedStoreImpl : public StoreImpl {
text_readouts_.forEachStat(f_size, f_stat);
}

void forEachHistogram(SizeFn f_size, StatFn<ParentHistogram> f_stat) const override {
UNREFERENCED_PARAMETER(f_size);
UNREFERENCED_PARAMETER(f_stat);
}

void forEachScope(SizeFn f_size, StatFn<const Scope> f_stat) const override {
if (f_size != nullptr) {
f_size(1);
Expand Down
26 changes: 15 additions & 11 deletions source/common/stats/thread_local_store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,10 @@ std::vector<TextReadoutSharedPtr> ThreadLocalStoreImpl::textReadouts() const {

std::vector<ParentHistogramSharedPtr> ThreadLocalStoreImpl::histograms() const {
std::vector<ParentHistogramSharedPtr> ret;
Thread::LockGuard lock(hist_mutex_);
{
ret.reserve(histogram_set_.size());
for (const auto& histogram_ptr : histogram_set_) {
ret.emplace_back(histogram_ptr);
}
}

forEachHistogram([&ret](std::size_t size) mutable { ret.reserve(size); },
[&ret](ParentHistogram& histogram) mutable {
ret.emplace_back(ParentHistogramSharedPtr(&histogram));
});
return ret;
}

Expand Down Expand Up @@ -241,9 +237,7 @@ void ThreadLocalStoreImpl::mergeHistograms(PostMergeCb merge_complete_cb) {

void ThreadLocalStoreImpl::mergeInternal(PostMergeCb merge_complete_cb) {
if (!shutting_down_) {
for (const ParentHistogramSharedPtr& histogram : histograms()) {
histogram->merge();
}
forEachHistogram(nullptr, [](ParentHistogram& histogram) { histogram.merge(); });
merge_complete_cb();
merge_in_progress_ = false;
}
Expand Down Expand Up @@ -967,6 +961,16 @@ void ThreadLocalStoreImpl::forEachTextReadout(SizeFn f_size, StatFn<TextReadout>
alloc_.forEachTextReadout(f_size, f_stat);
}

void ThreadLocalStoreImpl::forEachHistogram(SizeFn f_size, StatFn<ParentHistogram> f_stat) const {
Thread::LockGuard lock(hist_mutex_);
if (f_size != nullptr) {
f_size(histogram_set_.size());
}
for (ParentHistogramImpl* histogram : histogram_set_) {
f_stat(*histogram);
}
}

void ThreadLocalStoreImpl::forEachScope(std::function<void(std::size_t)> f_size,
StatFn<const Scope> f_scope) const {
Thread::LockGuard lock(lock_);
Expand Down
1 change: 1 addition & 0 deletions source/common/stats/thread_local_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ class ThreadLocalStoreImpl : Logger::Loggable<Logger::Id::stats>, public StoreRo
void forEachCounter(SizeFn f_size, StatFn<Counter> f_stat) const override;
void forEachGauge(SizeFn f_size, StatFn<Gauge> f_stat) const override;
void forEachTextReadout(SizeFn f_size, StatFn<TextReadout> f_stat) const override;
void forEachHistogram(SizeFn f_size, StatFn<ParentHistogram> f_stat) const override;
void forEachScope(SizeFn f_size, StatFn<const Scope> f_stat) const override;

// Stats::StoreRoot
Expand Down
24 changes: 14 additions & 10 deletions source/server/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,34 +180,38 @@ void InstanceImpl::failHealthcheck(bool fail) {

MetricSnapshotImpl::MetricSnapshotImpl(Stats::Store& store, TimeSource& time_source) {
store.forEachSinkedCounter(
[this](std::size_t size) mutable {
[this](std::size_t size) {
snapped_counters_.reserve(size);
counters_.reserve(size);
},
[this](Stats::Counter& counter) mutable {
[this](Stats::Counter& counter) {
snapped_counters_.push_back(Stats::CounterSharedPtr(&counter));
counters_.push_back({counter.latch(), counter});
});

store.forEachSinkedGauge(
[this](std::size_t size) mutable {
[this](std::size_t size) {
snapped_gauges_.reserve(size);
gauges_.reserve(size);
},
[this](Stats::Gauge& gauge) mutable {
[this](Stats::Gauge& gauge) {
ASSERT(gauge.importMode() != Stats::Gauge::ImportMode::Uninitialized);
snapped_gauges_.push_back(Stats::GaugeSharedPtr(&gauge));
gauges_.push_back(gauge);
});

snapped_histograms_ = store.histograms();
histograms_.reserve(snapped_histograms_.size());
for (const auto& histogram : snapped_histograms_) {
histograms_.push_back(*histogram);
}
store.forEachHistogram(
[this](std::size_t size) {
snapped_histograms_.reserve(size);
histograms_.reserve(size);
},
[this](Stats::ParentHistogram& histogram) {
snapped_histograms_.push_back(Stats::ParentHistogramSharedPtr(&histogram));
histograms_.push_back(histogram);
});

store.forEachSinkedTextReadout(
[this](std::size_t size) mutable {
[this](std::size_t size) {
snapped_text_readouts_.reserve(size);
text_readouts_.reserve(size);
},
Expand Down
Loading