-
Notifications
You must be signed in to change notification settings - Fork 63
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
RUM-1095 Fix the batch duration value in batch_close telemetry event #1633
RUM-1095 Fix the batch duration value in batch_close telemetry event #1633
Conversation
b815d63
to
96b6b65
Compare
return try { | ||
dateTimeProvider.getDeviceTimestamp() - file.name.toLong() | ||
this.name.toLong() |
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.
we could use .toLongOrNull()
to avoid throwing an exception
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.
I wanted to have the exception just for us though...to see in case we have a weird filename in there. What do you think ?
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.
You can still log the filename when the result is null, but throwing an exception costs resources, it's more efficient to avoid it when we can
Codecov Report
@@ Coverage Diff @@
## develop #1633 +/- ##
===========================================
- Coverage 83.81% 83.79% -0.02%
===========================================
Files 455 455
Lines 15686 15684 -2
Branches 2331 2333 +2
===========================================
- Hits 13147 13142 -5
- Misses 1916 1918 +2
- Partials 623 624 +1
|
96b6b65
to
4654c0a
Compare
98ff93d
to
2450355
Compare
@@ -47,7 +48,7 @@ internal class BatchMetricsDispatcher( | |||
} | |||
|
|||
override fun sendBatchClosedMetric(batchFile: File, batchMetadata: BatchClosedMetadata) { | |||
if (trackName == null || !sampler.sample()) { | |||
if (!batchFile.existsSafe(internalLogger) || trackName == null || !sampler.sample()) { |
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.
small performance gain - let's put the check if file exists to the right - this way we won't do it if metric is not sampled, we are saving some I/O capacity and block the thread less
if (!batchFile.existsSafe(internalLogger) || trackName == null || !sampler.sample()) { | |
if (trackName == null || !sampler.sample() || !batchFile.existsSafe(internalLogger)) { |
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.
Good catch
2450355
to
876f439
Compare
What does this PR do?
Before we were computing the batch duration value for the
batch_close
telemetry event as:System.currentTimeInMillis - lastTimeBatchWasAccessed
which was completely wrong. In this PR we are addressing this issue.Motivation
What inspired you to submit this pull request?
Additional Notes
Anything else we should know when reviewing?
Review checklist (to be filled by reviewers)