@cryptotaxi247 / netdata-1 / commits / 87c11722e

statsd sets should show zero when not collected

Costa Tsaousis (ktsaou) committed Apr 17, 2018 at 00:00 UTC 87c11722efa005f713e12808deea2b725f9e9131
1 file changed +18 -16
src/statsd.c
+18 -16
@@ -1693,6 +1693,9 @@ static inline void statsd_flush_set(STATSD_METRIC *m) {
1693 m->reset = 1;
1694 updated = 1;
1695 }
1696 + else {
1697 + m->last = 0;
1698 + }
1699
1700 if(unlikely(m->options & STATSD_METRIC_OPTION_PRIVATE_CHART_ENABLED && (updated || !(m->options & STATSD_METRIC_OPTION_SHOW_GAPS_WHEN_NOT_COLLECTED))))
1701 statsd_private_chart_set(m);
@@ -1701,22 +1704,6 @@ static inline void statsd_flush_set(STATSD_METRIC *m) {
1704 static inline void statsd_flush_timer_or_histogram(STATSD_METRIC *m, const char *dim, const char *family, const char *units) {
1705 debug(D_STATSD, "flushing %s metric '%s'", dim, m->name);
1706
1704 - if(unlikely(!m->histogram.ext->zeroed)) {
1705 - // reset the metrics
1706 - // if we collected anything, they will be updated below
1707 - // this ensures that we report zeros if nothing is collected
1708 -
1709 - m->histogram.ext->last_min = 0;
1710 - m->histogram.ext->last_max = 0;
1711 - m->last = 0;
1712 - m->histogram.ext->last_median = 0;
1713 - m->histogram.ext->last_stddev = 0;
1714 - m->histogram.ext->last_sum = 0;
1715 - m->histogram.ext->last_percentile = 0;
1716 -
1717 - m->histogram.ext->zeroed = 1;
1718 - }
1719 -
1707 int updated = 0;
1708 if(unlikely(!m->reset && m->count && m->histogram.ext->used > 0)) {
1709 netdata_mutex_lock(&m->histogram.ext->mutex);
@@ -1747,6 +1734,21 @@ static inline void statsd_flush_timer_or_histogram(STATSD_METRIC *m, const char
1734 m->reset = 1;
1735 updated = 1;
1736 }
1737 + else if(unlikely(!m->histogram.ext->zeroed)) {
1738 + // reset the metrics
1739 + // if we collected anything, they will be updated below
1740 + // this ensures that we report zeros if nothing is collected
1741 +
1742 + m->histogram.ext->last_min = 0;
1743 + m->histogram.ext->last_max = 0;
1744 + m->last = 0;
1745 + m->histogram.ext->last_median = 0;
1746 + m->histogram.ext->last_stddev = 0;
1747 + m->histogram.ext->last_sum = 0;
1748 + m->histogram.ext->last_percentile = 0;
1749 +
1750 + m->histogram.ext->zeroed = 1;
1751 + }
1752
1753 if(unlikely(m->options & STATSD_METRIC_OPTION_PRIVATE_CHART_ENABLED && (updated || !(m->options & STATSD_METRIC_OPTION_SHOW_GAPS_WHEN_NOT_COLLECTED))))
1754 statsd_private_chart_timer_or_histogram(m, dim, family, units);