| 87 | namespace |
| 88 | { |
| 89 | int |
| 90 | EventMetricStatSync(const char *, RecDataT, RecData *, RecRawStatBlock *rsb, int) |
| 91 | { |
| 92 | using Graph = EThread::Metrics::Graph; |
| 93 | |
| 94 | int id = 0; |
| 95 | EThread::Metrics summary; |
| 96 | |
| 97 | // scan the thread local values |
| 98 | for (EThread *t : eventProcessor.active_group_threads(ET_CALL)) { |
| 99 | t->metrics.summarize(summary); |
| 100 | } |
| 101 | |
| 102 | ink_mutex_acquire(&(rsb->mutex)); |
| 103 | |
| 104 | // Update a specific enumerated stat. |
| 105 | auto slice_stat_update = [=](EThread::Metrics::Slice::STAT_ID stat_id, int stat_idx, size_t value) { |
| 106 | auto idx = stat_idx + static_cast<unsigned>(stat_id); |
| 107 | auto stat = rsb->global[idx]; |
| 108 | stat->sum = value; |
| 109 | stat->count = 1; |
| 110 | RecRawStatUpdateSum(rsb, idx); |
| 111 | }; |
| 112 | |
| 113 | // Enumerated stats are first - one set for each time scale. |
| 114 | for (unsigned ts_idx = 0; ts_idx < EThread::Metrics::N_TIMESCALES; ++ts_idx, id += EThread::Metrics::Slice::N_STAT_ID) { |
| 115 | using ID = EThread::Metrics::Slice::STAT_ID; |
| 116 | auto slice = summary._slice.data() + ts_idx; |
| 117 | |
| 118 | slice_stat_update(ID::LOOP_COUNT, id, slice->_count); |
| 119 | slice_stat_update(ID::LOOP_WAIT, id, slice->_wait); |
| 120 | slice_stat_update(ID::LOOP_TIME_MIN, id, slice->_duration._min); |
| 121 | slice_stat_update(ID::LOOP_TIME_MAX, id, slice->_duration._max); |
| 122 | slice_stat_update(ID::LOOP_EVENTS, id, slice->_events._total); |
| 123 | slice_stat_update(ID::LOOP_EVENTS_MIN, id, slice->_events._min); |
| 124 | slice_stat_update(ID::LOOP_EVENTS_MAX, id, slice->_events._max); |
| 125 | slice_stat_update(ID::LOOP_DRAIN_QUEUE_MAX, id, slice->_duration._max_drain_queue); |
| 126 | slice_stat_update(ID::LOOP_IO_WAIT_MAX, id, slice->_duration._max_io_wait); |
| 127 | slice_stat_update(ID::LOOP_IO_WORK_MAX, id, slice->_duration._max_io_work); |
| 128 | } |
| 129 | |
| 130 | // Next are the event loop histogram buckets. |
| 131 | for (Graph::raw_type idx = 0; idx < Graph::N_BUCKETS; ++idx, ++id) { |
| 132 | rsb->global[id]->sum = summary._loop_timing[idx]; |
| 133 | rsb->global[id]->count = 1; |
| 134 | RecRawStatUpdateSum(rsb, id); |
| 135 | } |
| 136 | |
| 137 | // Last are the plugin API histogram buckets. |
| 138 | for (Graph::raw_type idx = 0; idx < Graph::N_BUCKETS; ++idx, ++id) { |
| 139 | rsb->global[id]->sum = summary._api_timing[idx]; |
| 140 | rsb->global[id]->count = 1; |
| 141 | RecRawStatUpdateSum(rsb, id); |
| 142 | } |
| 143 | |
| 144 | // Check if it's time to schedule a decay of the histogram data. |
| 145 | // Done here so that it's (roughly) synchronized across the ET_NET threads. |
| 146 | // The decay is done in the local threads, this bumps a counter to indicate it should be done. |
nothing calls this directly
no test coverage detected