-
Notifications
You must be signed in to change notification settings - Fork 140
RUM-8042 Add pending batches to batch deleted metric #2191
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-8042 Add pending batches to batch deleted metric #2191
Conversation
8d0f383
to
a6cd347
Compare
Datadog ReportBranch report: ✅ 0 Failed, 790 Passed, 3020 Skipped, 59.93s Total Time |
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.
Looks good. Just some questions
@ReadWriteLock | ||
private var pendingBatches: Int = 0 |
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'm using a lock here because getting and deleting a file can happen on different threads, but this can add penalty to the call thread.
The other option will be to read the directory each time we send the telemetry:
BatchDeletedMetric.pendingBatches: try? directory.files()
But this also has the drawback of reading the disk each time.
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.
Looks good! I left a couple of questions.
@@ -258,6 +268,9 @@ internal class FilesOrchestrator: FilesOrchestratorType { | |||
/// | |||
/// Note: The `batchFile` doesn't exist at this point. | |||
private func sendBatchDeletedMetric(batchFile: ReadableFile, deletionReason: BatchDeletedMetric.RemovalReason) { | |||
// Decrement pending batches at each batch deletion | |||
pendingBatches -= 1 |
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.
Shouldn't the decrementation happen where the batch is deleted rather than when sending the telemetry?
let files = try directory.files() | ||
|
||
// Reset pending batches for telemetry | ||
pendingBatches = files.count |
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.
Could this lead to discrepancies? Right now this variable can be updated from different places.
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.
That's a fair point! Makes me leaning toward the solution proposed here. This was, we would be sure that data is accurate.
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.
Or could we update pendingBatches
either only here, or when a file gets created & removed? This way we keep the lock.
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.
Getting the files.count
while reading is to know the pending batches when the SDK starts. At start, no file has been created or removed but there could be files on disk. So, we need to get the count at read/create/delete operations. I will push the other solution, LMKWYT!
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.
Got it!
How often would this telemetry be sent, apart from app launch? I wonder what would be the performance impact of reading from disk.
Initially I wanted to suggest initializing the counter when creating the FileOrchestrator
, but I see getReadableFiles
is called from other places so that won't work.
Given that potential inconsistencies only happen at app launch, when the reset happens, would the initial counter implementation be acceptable? It might be a good tradeoff between performance and accuracy.
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 think reading the disk each time we send the telemetry is acceptable. With average
upload frequency, this will be call every 2s if a batch is present and ready. So I don't expect any perf impact.
9932036
to
63e8fd6
Compare
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.
🚀
63e8fd6
to
737e7f4
Compare
/merge |
View all feedbacks in Devflow UI.
This merge request is not mergeable yet, because of pending checks/missing approvals. It will be added to the queue as soon as checks pass and/or get approvals.
The median merge time in
|
What and why?
Add pending batches attribute to Batch Deleted Metric.
This attribute will help drawing distribution of pending batches throughout sessions.
How?
FilesOrchestrator
keeps track of pending batches and send it as part ofBatchDeletedMetric
telemetry.Review checklist
make api-surface
)