Loading cmds/statsd/src/guardrail/StatsdStats.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -458,6 +458,15 @@ void StatsdStats::noteInvalidatedBucket(int64_t metricId) { getAtomMetricStats(metricId).invalidatedBucket++; } void StatsdStats::noteBucketBoundaryDelayNs(int64_t metricId, int64_t timeDelayNs) { lock_guard<std::mutex> lock(mLock); AtomMetricStats& pullStats = getAtomMetricStats(metricId); pullStats.maxBucketBoundaryDelayNs = std::max(pullStats.maxBucketBoundaryDelayNs, timeDelayNs); pullStats.minBucketBoundaryDelayNs = std::min(pullStats.minBucketBoundaryDelayNs, timeDelayNs); } StatsdStats::AtomMetricStats& StatsdStats::getAtomMetricStats(int metricId) { auto atomMetricStatsIter = mAtomMetricStats.find(metricId); if (atomMetricStatsIter != mAtomMetricStats.end()) { Loading cmds/statsd/src/guardrail/StatsdStats.h +8 −0 Original line number Diff line number Diff line Loading @@ -374,6 +374,12 @@ public: */ void noteInvalidatedBucket(int64_t metricId); /** * For pulls at bucket boundaries, it represents the misalignment between the real timestamp and * the end of the bucket. */ void noteBucketBoundaryDelayNs(int64_t metricId, int64_t timeDelayNs); /** * Reset the historical stats. Including all stats in icebox, and the tracked stats about * metrics, matchers, and atoms. The active configs will be kept and StatsdStats will continue Loading Loading @@ -420,6 +426,8 @@ public: long conditionChangeInNextBucket = 0; long invalidatedBucket = 0; long bucketDropped = 0; int64_t minBucketBoundaryDelayNs = 0; int64_t maxBucketBoundaryDelayNs = 0; } AtomMetricStats; private: Loading cmds/statsd/src/metrics/ValueMetricProducer.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -387,6 +387,8 @@ void ValueMetricProducer::onDataPulled(const std::vector<std::shared_ptr<LogEven // If the sleep was very long, we skip more than one bucket before sleep. In this case, // if the diff base will be cleared and this new data will serve as new diff base. int64_t bucketEndTime = calcPreviousBucketEndTime(originalPullTimeNs) - 1; StatsdStats::getInstance().noteBucketBoundaryDelayNs( mMetricId, originalPullTimeNs - bucketEndTime); accumulateEvents(allData, originalPullTimeNs, bucketEndTime); // We can probably flush the bucket. Since we used bucketEndTime when calling Loading cmds/statsd/src/stats_log.proto +2 −0 Original line number Diff line number Diff line Loading @@ -419,6 +419,8 @@ message StatsdStatsReport { optional int64 condition_change_in_next_bucket = 6; optional int64 invalidated_bucket = 7; optional int64 bucket_dropped = 8; optional int64 min_bucket_boundary_delay_ns = 9; optional int64 max_bucket_boundary_delay_ns = 10; } repeated AtomMetricStats atom_metric_stats = 17; Loading cmds/statsd/src/stats_log_util.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,8 @@ const int FIELD_ID_BAD_VALUE_TYPE = 5; const int FIELD_ID_CONDITION_CHANGE_IN_NEXT_BUCKET = 6; const int FIELD_ID_INVALIDATED_BUCKET = 7; const int FIELD_ID_BUCKET_DROPPED = 8; const int FIELD_ID_MIN_BUCKET_BOUNDARY_DELAY_NS = 9; const int FIELD_ID_MAX_BUCKET_BOUNDARY_DELAY_NS = 10; namespace { Loading Loading @@ -500,6 +502,10 @@ void writeAtomMetricStatsToStream(const std::pair<int, StatsdStats::AtomMetricSt (long long)pair.second.invalidatedBucket); protoOutput->write(FIELD_TYPE_INT64 | FIELD_ID_BUCKET_DROPPED, (long long)pair.second.bucketDropped); protoOutput->write(FIELD_TYPE_INT64 | FIELD_ID_MIN_BUCKET_BOUNDARY_DELAY_NS, (long long)pair.second.minBucketBoundaryDelayNs); protoOutput->write(FIELD_TYPE_INT64 | FIELD_ID_MAX_BUCKET_BOUNDARY_DELAY_NS, (long long)pair.second.maxBucketBoundaryDelayNs); protoOutput->end(token); } Loading Loading
cmds/statsd/src/guardrail/StatsdStats.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -458,6 +458,15 @@ void StatsdStats::noteInvalidatedBucket(int64_t metricId) { getAtomMetricStats(metricId).invalidatedBucket++; } void StatsdStats::noteBucketBoundaryDelayNs(int64_t metricId, int64_t timeDelayNs) { lock_guard<std::mutex> lock(mLock); AtomMetricStats& pullStats = getAtomMetricStats(metricId); pullStats.maxBucketBoundaryDelayNs = std::max(pullStats.maxBucketBoundaryDelayNs, timeDelayNs); pullStats.minBucketBoundaryDelayNs = std::min(pullStats.minBucketBoundaryDelayNs, timeDelayNs); } StatsdStats::AtomMetricStats& StatsdStats::getAtomMetricStats(int metricId) { auto atomMetricStatsIter = mAtomMetricStats.find(metricId); if (atomMetricStatsIter != mAtomMetricStats.end()) { Loading
cmds/statsd/src/guardrail/StatsdStats.h +8 −0 Original line number Diff line number Diff line Loading @@ -374,6 +374,12 @@ public: */ void noteInvalidatedBucket(int64_t metricId); /** * For pulls at bucket boundaries, it represents the misalignment between the real timestamp and * the end of the bucket. */ void noteBucketBoundaryDelayNs(int64_t metricId, int64_t timeDelayNs); /** * Reset the historical stats. Including all stats in icebox, and the tracked stats about * metrics, matchers, and atoms. The active configs will be kept and StatsdStats will continue Loading Loading @@ -420,6 +426,8 @@ public: long conditionChangeInNextBucket = 0; long invalidatedBucket = 0; long bucketDropped = 0; int64_t minBucketBoundaryDelayNs = 0; int64_t maxBucketBoundaryDelayNs = 0; } AtomMetricStats; private: Loading
cmds/statsd/src/metrics/ValueMetricProducer.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -387,6 +387,8 @@ void ValueMetricProducer::onDataPulled(const std::vector<std::shared_ptr<LogEven // If the sleep was very long, we skip more than one bucket before sleep. In this case, // if the diff base will be cleared and this new data will serve as new diff base. int64_t bucketEndTime = calcPreviousBucketEndTime(originalPullTimeNs) - 1; StatsdStats::getInstance().noteBucketBoundaryDelayNs( mMetricId, originalPullTimeNs - bucketEndTime); accumulateEvents(allData, originalPullTimeNs, bucketEndTime); // We can probably flush the bucket. Since we used bucketEndTime when calling Loading
cmds/statsd/src/stats_log.proto +2 −0 Original line number Diff line number Diff line Loading @@ -419,6 +419,8 @@ message StatsdStatsReport { optional int64 condition_change_in_next_bucket = 6; optional int64 invalidated_bucket = 7; optional int64 bucket_dropped = 8; optional int64 min_bucket_boundary_delay_ns = 9; optional int64 max_bucket_boundary_delay_ns = 10; } repeated AtomMetricStats atom_metric_stats = 17; Loading
cmds/statsd/src/stats_log_util.cpp +6 −0 Original line number Diff line number Diff line Loading @@ -80,6 +80,8 @@ const int FIELD_ID_BAD_VALUE_TYPE = 5; const int FIELD_ID_CONDITION_CHANGE_IN_NEXT_BUCKET = 6; const int FIELD_ID_INVALIDATED_BUCKET = 7; const int FIELD_ID_BUCKET_DROPPED = 8; const int FIELD_ID_MIN_BUCKET_BOUNDARY_DELAY_NS = 9; const int FIELD_ID_MAX_BUCKET_BOUNDARY_DELAY_NS = 10; namespace { Loading Loading @@ -500,6 +502,10 @@ void writeAtomMetricStatsToStream(const std::pair<int, StatsdStats::AtomMetricSt (long long)pair.second.invalidatedBucket); protoOutput->write(FIELD_TYPE_INT64 | FIELD_ID_BUCKET_DROPPED, (long long)pair.second.bucketDropped); protoOutput->write(FIELD_TYPE_INT64 | FIELD_ID_MIN_BUCKET_BOUNDARY_DELAY_NS, (long long)pair.second.minBucketBoundaryDelayNs); protoOutput->write(FIELD_TYPE_INT64 | FIELD_ID_MAX_BUCKET_BOUNDARY_DELAY_NS, (long long)pair.second.maxBucketBoundaryDelayNs); protoOutput->end(token); } Loading