Skip to content

Commit d0b9d75

Browse files
committed
Record the event timestamp before dispatching
Recording the timestamp in a dispatched function could potentially delay its recording and provide inaccurate timestamps.
1 parent b2fceb3 commit d0b9d75

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

glean/src/core/metrics/types/event.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ class EventMetricType extends MetricType {
3333
* The maximum length for values is 100 bytes.
3434
*/
3535
record(extra?: ExtraMap): void {
36+
const timestamp = getMonotonicNow();
37+
3638
Context.dispatcher.launch(async () => {
3739
if (!this.shouldRecord(Context.uploadEnabled)) {
3840
return;
3941
}
4042

41-
const timestamp = getMonotonicNow();
42-
4343
// Truncate the extra keys, if needed.
4444
let truncatedExtra: ExtraMap | undefined = undefined;
4545
if (extra && this.allowedExtraKeys) {

0 commit comments

Comments
 (0)