-
Notifications
You must be signed in to change notification settings - Fork 11.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ISSUE #7381] Fix the problem of inaccurate timer message metric #7382
Conversation
@@ -599,7 +599,12 @@ public void addMetric(MessageExt msg, int value) { | |||
if (null == msg || null == msg.getProperty(MessageConst.PROPERTY_REAL_TOPIC)) { | |||
return; | |||
} | |||
timerMetrics.addAndGet(msg.getProperty(MessageConst.PROPERTY_REAL_TOPIC), value); | |||
if (msg.getProperty(TIMER_ENQUEUE_MS) != null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NumberUtils.toLong() might be more clear
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need of msg.getProperty(TIMER_ENQUEUE_MS) != null
if using NumberUtils.toLong
, you can check this out
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Under normal situation, this indicator is still null when exiting the queue, so this judgment is necessary.
When leaving the queue, the 'enququ_time' attribute in the message has not been retrieved from the timerRequest yet. When leaving the queue, this attribute will not be null unless it is determined that it has never entered the time wheel.
DefaultStoreMetricsManager.incTimerDequeueCount(getRealTopic(msgExt)); | ||
if (tr.getEnqueueTime() == Long.MAX_VALUE) { | ||
// never enqueue, mark it. | ||
MessageAccessor.putProperty(msgExt, TIMER_ENQUEUE_MS, Long.MAX_VALUE+""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will String.valueOF(Long.MAX_VALUE)
be more clear?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Codecov Report
@@ Coverage Diff @@
## develop #7382 +/- ##
==========================================
Coverage 42.51% 42.52%
- Complexity 9440 9442 +2
==========================================
Files 1150 1150
Lines 82728 82738 +10
Branches 10775 10778 +3
==========================================
+ Hits 35174 35182 +8
- Misses 43143 43148 +5
+ Partials 4411 4408 -3
... and 13 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Which Issue(s) This PR Fixes
Fixes #7381
Brief Description
When entering the time wheel, if it is judged that it can be dequeued, its enqueue time is set to infinity, which means that it has never entered the time wheel.
Skip messages with an infinite enqueue time when counting metrics.
How Did You Test This Change?