RUM-1095 Fix the batch duration value in batch_close telemetry event#1633
Conversation
b815d63 to
96b6b65
Compare
| private fun File.nameAsTimestampSafe(): Long? { | ||
| return try { | ||
| dateTimeProvider.getDeviceTimestamp() - file.name.toLong() | ||
| this.name.toLong() |
There was a problem hiding this comment.
we could use .toLongOrNull() to avoid throwing an exception
There was a problem hiding this comment.
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.
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
|
|
||
| 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.
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)) { |
2450355 to
876f439
Compare
What does this PR do?
Before we were computing the batch duration value for the
batch_closetelemetry event as:System.currentTimeInMillis - lastTimeBatchWasAccessedwhich 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)