Fix missing add request stats after group flush for add response #4179
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
After support group flush add response, we missing update add requests stats:

org.apache.bookkeeper.proto.WriteEntryProcessor#writeComplete
Changes
AddRequestStatsdescribes that the metric is updated after the add entry request into thewriteThreadPooland the response is sent to the client through the network.We need to update the
AddRequestStatcorresponding to the add request after the group flush add response.So here I record the time when the first request of Group Add into the queue of
writeThreadPool, the number of successes and failures of Add, the statistics of the difference between the enqueuing time of all successful requests and the enqueuing time of the first request, and all failures. Statistics on the difference between the requested enqueuing time and the first requested enqueuing time.The count of
AddRequestStatsreflects the number of requests, so we need to callregisterEventfor each individualAddRequestloop, and the time-consuming metric of eachAddRequestuses the average time-consuming of theGroup Addas a whole.