Description
The current implementation computes the counter file end time during the file creation time.
The end time is the next upload date (that's determined by the day of week written in the weekends file). An exception also applies for the new users - instead of the next upload date, the counter packages picks 7+ days later. This exception was originally designed before the telemetry was changed to the opt-in model, to ensure to give at least a week before uploading telemetry data. However, this requirement is no longer critical in the current telemetry model.
The start time is on the other hand determined mostly by the instrumented process's start time (unless the process is a long running process and the counter file rotation happens to occur during the process lifetime). For example, if a user starts gopls on oct 21, 22 and 23, and the week ends on oct 24 according to the user's weekends file, there are three counter files (created on 2023-10-21, 2023-10-22, and 2023-10-23) and they all have the end date 2023-10-24. In theory the 2023-10-21 file can be still active and certain processes are still holding the reference.
This end time computation adds extra complexity: the counter package computes the end time deep in the call chain of rotate -> rotate1 -> filename -> fileValidity -> read weekends. The upload package also cannot safely determine when to upload a file without reading the file's content and its metadata.
If we change the counter file to always rotate daily, we may simplify both counter and uploader.
- Counter package creates and rotates counter file daily. The counter package doesn't need to read the weekends file.
- Each count file ends at the end of the day. (UTC)
- Upload package assumes all the files whose names indicate old(+some slack time).
Additional benefits include:
- Upload some counters sooner (if we want and need to).
- Remove the unnecessary 7day+ delay for new users.