Skip to content
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

Merged

Conversation

mariusc83
Copy link
Member

@mariusc83 mariusc83 commented Sep 21, 2023

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)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@mariusc83 mariusc83 requested a review from a team as a code owner September 21, 2023 12:26
@mariusc83 mariusc83 force-pushed the mconstantin/rum-1095/fix-batch-close-telemetry-data branch 2 times, most recently from b815d63 to 96b6b65 Compare September 21, 2023 12:55
0xnm
0xnm previously approved these changes Sep 21, 2023
xgouchet
xgouchet previously approved these changes Sep 21, 2023
return try {
dateTimeProvider.getDeviceTimestamp() - file.name.toLong()
this.name.toLong()
Copy link
Member

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

Copy link
Member Author

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 ?

Copy link
Member

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-commenter
Copy link

codecov-commenter commented Sep 21, 2023

Codecov Report

Merging #1633 (876f439) into develop (956f75e) will decrease coverage by 0.02%.
Report is 22 commits behind head on develop.
The diff coverage is 100.00%.

@@             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     
Files Coverage Δ
...id/core/internal/metrics/BatchMetricsDispatcher.kt 98.21% <100.00%> (+4.99%) ⬆️
...al/persistence/file/batch/BatchFileOrchestrator.kt 93.67% <100.00%> (-1.23%) ⬇️

... and 15 files with indirect coverage changes

@mariusc83 mariusc83 dismissed stale reviews from xgouchet and 0xnm via 4654c0a September 22, 2023 06:58
@mariusc83 mariusc83 force-pushed the mconstantin/rum-1095/fix-batch-close-telemetry-data branch from 96b6b65 to 4654c0a Compare September 22, 2023 06:58
0xnm
0xnm previously approved these changes Sep 22, 2023
@mariusc83 mariusc83 requested a review from xgouchet September 22, 2023 07:28
jonathanmos
jonathanmos previously approved these changes Sep 24, 2023
@mariusc83 mariusc83 dismissed stale reviews from jonathanmos and 0xnm via 98ff93d September 25, 2023 09:05
@mariusc83 mariusc83 force-pushed the mconstantin/rum-1095/fix-batch-close-telemetry-data branch 2 times, most recently from 98ff93d to 2450355 Compare September 25, 2023 11:25
@@ -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()) {
Copy link
Member

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

Suggested change
if (!batchFile.existsSafe(internalLogger) || trackName == null || !sampler.sample()) {
if (trackName == null || !sampler.sample() || !batchFile.existsSafe(internalLogger)) {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

jonathanmos
jonathanmos previously approved these changes Sep 26, 2023
@mariusc83 mariusc83 force-pushed the mconstantin/rum-1095/fix-batch-close-telemetry-data branch from 2450355 to 876f439 Compare September 26, 2023 11:51
@mariusc83 mariusc83 merged commit c6d7291 into develop Sep 26, 2023
@mariusc83 mariusc83 deleted the mconstantin/rum-1095/fix-batch-close-telemetry-data branch September 26, 2023 13:01
@xgouchet xgouchet added this to the 2.2.0 milestone Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants