[Counter] Refactor to accept plain string as well

This commit is contained in:
Jan-Erik Rediger 2021-11-24 14:51:31 +01:00 коммит произвёл Jan-Erik Rediger
Родитель bd1d7954fc
Коммит 7b18903e22
1 изменённых файлов: 11 добавлений и 3 удалений

Просмотреть файл

@ -54,7 +54,8 @@ impl CounterMetric {
}
}
/// Internal only, synchronous API for incremeting a counter
/// Increases the counter by `amount` synchronously.
#[doc(hidden)]
pub fn add_sync(&self, glean: &Glean, amount: i32) {
if !self.should_record(glean) {
return;
@ -97,8 +98,15 @@ impl CounterMetric {
}
/// Get current value
pub fn get_value(&self, glean: &Glean, ping_name: Option<&str>) -> Option<i32> {
let queried_ping_name = ping_name.unwrap_or_else(|| &self.meta().send_in_pings[0]);
#[doc(hidden)]
pub fn get_value<'a, S: Into<Option<&'a str>>>(
&self,
glean: &Glean,
ping_name: S,
) -> Option<i32> {
let queried_ping_name = ping_name
.into()
.unwrap_or_else(|| &self.meta().send_in_pings[0]);
match StorageManager.snapshot_metric_for_test(
glean.storage(),