[BugFix] Fix merge commit latency metrics overflow (backport #67168) #67275
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.
Why I'm doing:
Merge commit latency metrics use bvar
LatencyRecorder, and the unit is nanoseconds, but if the latency is larger than 2 seconds, the bvar will report overflow as the followingThe reason is that although
LatencyRecorderacceptsint64_tas input (https://github.com/apache/brpc/blob/master/src/bvar/latency_recorder.h#L100), but it actually uses
IntRecorderto store the latency as int (https://github.com/apache/brpc/blob/master/src/bvar/latency_recorder.h#L54), so the allowed latency in nanosecond is2147483647(about 2.1s)What I'm doing:
bvar does not provide other recorders to support
int64_t. For merge commit latency, it's not necessary to use nanosecond precision, so just change the latency unit to microsecond, and the max latency can be 35.8 minutes which should be enough.Note changing metric unit introduces behavior change, and add the document to explain it
Fixes #issue
What type of PR is this:
Does this PR entail a change in behavior?
If yes, please specify the type of change:
Checklist:
Bugfix cherry-pick branch check:
Note
Fixes overflow in merge-commit latency metrics by switching from nanoseconds to microseconds and documenting the change.
g_mc_*_latency_nswithg_mc_*_latency_usinisomorphic_batch_write.cpp, addNS_TO_USconversions, and update logs/recorders accordinglyWritten by Cursor Bugbot for commit 126d8f7. This will update automatically on new commits. Configure here.
This is an automatic backport of pull request #67168 done by [Mergify](https://mergify.com).