Bug 1751402 - Guarantee getMonotonicNow doesn't return a negative value #1130
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We were previously extracting the TIME_ORIGIN from Date.now()
in case performance.now was not available in the environment.
That could create negative timestamps, because Date.now is not
guaranteed to be monotonically increasing. (Yeah... it is
contradictiory to have a function called getMonotonicNow, but not
guarantee monotonically increasing timestamps for some platforms.
At least there is a TODO comment to address the incoherence at
some point).
Subtracting the TIME_ORIGIN was essentially pointless and I don't really
know why that was the case before. That function is used by the Timestamp
metric type and for event timestamps which are both about elapsed time,
so the absoulte timestamp should not matter.
EXTRA: Address stray TODO comment on TimespanMetricType test suite.
Pull Request checklist
glean/
folder, run:npm run test
Runs all testsnpm run lint
Runs all lintersTests: This PR includes thorough tests or an explanation of why it does notCHANGELOG.md
or an explanation of why it does not need oneDocumentation: This PR includes documentation changes, an explanation of why it does not need that or a follow-up bug has been filed to do that work