Update the milestone state given the milestones and timer.
| 8860 | |
| 8861 | /// Update the milestone state given the milestones and timer. |
| 8862 | void |
| 8863 | HttpSM::milestone_update_api_time() |
| 8864 | { |
| 8865 | // Bit of funkiness - we set @a api_timer to be the negative value when we're tracking |
| 8866 | // non-active API time. In that case we need to make a note of it and flip the value back |
| 8867 | // to positive. |
| 8868 | if (api_timer) { |
| 8869 | ink_hrtime delta; |
| 8870 | bool active = api_timer >= 0; |
| 8871 | if (!active) { |
| 8872 | api_timer = -api_timer; |
| 8873 | } |
| 8874 | // Zero or negative time is a problem because we want to signal *something* happened |
| 8875 | // vs. no API activity at all. This can happen due to graininess or real time |
| 8876 | // clock adjustment. |
| 8877 | delta = std::max<ink_hrtime>(1, ink_get_hrtime() - api_timer); |
| 8878 | api_timer = 0; |
| 8879 | |
| 8880 | if (0 == milestones[TS_MILESTONE_PLUGIN_TOTAL]) { |
| 8881 | milestones[TS_MILESTONE_PLUGIN_TOTAL] = milestones[TS_MILESTONE_SM_START]; |
| 8882 | } |
| 8883 | milestones[TS_MILESTONE_PLUGIN_TOTAL] += delta; |
| 8884 | if (active) { |
| 8885 | if (0 == milestones[TS_MILESTONE_PLUGIN_ACTIVE]) { |
| 8886 | milestones[TS_MILESTONE_PLUGIN_ACTIVE] = milestones[TS_MILESTONE_SM_START]; |
| 8887 | } |
| 8888 | milestones[TS_MILESTONE_PLUGIN_ACTIVE] += delta; |
| 8889 | } |
| 8890 | this_ethread()->metrics.record_api_time(delta); |
| 8891 | } |
| 8892 | } |
no test coverage detected