Skip to content

Commit

Permalink
Merge pull request #22 from DNS-OARC/bug/min-avg
Browse files Browse the repository at this point in the history
Fix average calculation in timeout scenarios
  • Loading branch information
weyrick committed Oct 22, 2019
2 parents a9adc4b + aa27c3d commit 35ebcd0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions flame/metrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,15 @@ void MetricsMgr::aggregate(bool no_avgs)
}

// TODO avg of averages, here be dragons
auto rcv_cnt = 0;
for (const auto &i : _metrics) {
_agg_period_response_avg_ms += i->_period_response_avg_ms;
if (i->_period_r_count) {
rcv_cnt++;
_agg_period_response_avg_ms += i->_period_response_avg_ms;
}
_agg_period_pkt_size_avg += i->_period_pkt_size_avg;
}
_agg_period_response_avg_ms /= _metrics.size();
_agg_period_response_avg_ms /= rcv_cnt;
_agg_period_pkt_size_avg /= _metrics.size();
if (_agg_period_response_avg_ms) {
_agg_total_response_avg_ms = (_agg_period_response_avg_ms + (_agg_total_response_avg_ms * (_aggregate_count - 1))) / _aggregate_count;
Expand Down

0 comments on commit 35ebcd0

Please sign in to comment.