Skip to content

Commit

Permalink
Merge pull request #1549 from mozilla/event-with-timestamp
Browse files Browse the repository at this point in the history
Bug 1672198 - RLB: Allow to record an event with the provided timestamp
  • Loading branch information
badboy authored Mar 15, 2021
2 parents ad412a4 + 7be3b15 commit 70529f0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Added `rate` metric type ([#1516](https://github.com/mozilla/glean/pull/1516)).
* Set `internal_metrics::os_version` for MacOS, Windows and Linux ([#1538](https://github.com/mozilla/glean/pull/1538))
* Expose a function `get_timestamp_ms` to get a timestamp from a monotonic clock on all supported operating systems, to be used for event timestamps.
* Expose a function to record events with an externally provided timestamp.
* iOS
* **Breaking Change**: Event timestamps are now correctly recorded in milliseconds.
* Since the first release event timestamps were erroneously recorded with nanosecond precision.
Expand Down
9 changes: 9 additions & 0 deletions glean-core/rlb/src/private/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ impl<K: traits::ExtraKeys> EventMetric<K> {
extra_keys: PhantomData,
}
}

/// Record a new event with a provided timestamp.
///
/// It's the caller's responsibility to ensure the timestamp comes from the same clock source.
/// Use [`glean::get_timestamp_ms`](crate::get_timestamp_ms) to get a valid timestamp.
pub fn record_with_time(&self, timestamp: u64, extra: HashMap<i32, String>) {
let metric = Arc::clone(&self.inner);
crate::launch_with_glean(move |glean| metric.record(glean, timestamp, Some(extra)));
}
}

#[inherent(pub)]
Expand Down

0 comments on commit 70529f0

Please sign in to comment.