Skip to content
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

Bug 1672198 - RLB: Allow to record an event with the provided timestamp #1549

Merged
merged 1 commit into from
Mar 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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