зеркало из https://github.com/mozilla/glean.git
Bug 1681570: Remove docs on implementations of traits in the RLB (#1382)
This commit is contained in:
Родитель
141ae1da58
Коммит
d00e288b0e
|
@ -31,26 +31,11 @@ impl BooleanMetric {
|
|||
|
||||
#[inherent(pub)]
|
||||
impl glean_core::traits::Boolean for BooleanMetric {
|
||||
/// Sets to the specified boolean value.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `value` - the value to set.
|
||||
fn set(&self, value: bool) {
|
||||
let metric = Arc::clone(&self.0);
|
||||
dispatcher::launch(move || crate::with_glean(|glean| metric.set(glean, value)));
|
||||
}
|
||||
|
||||
/// **Exported for test purposes.**
|
||||
///
|
||||
/// Gets the currently stored value as a boolean.
|
||||
///
|
||||
/// This doesn't clear the stored value.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `ping_name` - represents the optional name of the ping to retrieve the
|
||||
/// metric for. Defaults to the first value in `send_in_pings`.
|
||||
fn test_get_value<'a, S: Into<Option<&'a str>>>(&self, ping_name: S) -> Option<bool> {
|
||||
dispatcher::block_on_queue();
|
||||
|
||||
|
|
|
@ -32,30 +32,11 @@ impl CounterMetric {
|
|||
|
||||
#[inherent(pub)]
|
||||
impl glean_core::traits::Counter for CounterMetric {
|
||||
/// Increases the counter by `amount`.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `amount` - The amount to increase by. Should be positive.
|
||||
///
|
||||
/// ## Notes
|
||||
///
|
||||
/// Logs an error if the `amount` is 0 or negative.
|
||||
fn add(&self, amount: i32) {
|
||||
let metric = Arc::clone(&self.0);
|
||||
dispatcher::launch(move || crate::with_glean(|glean| metric.add(glean, amount)));
|
||||
}
|
||||
|
||||
/// **Exported for test purposes.**
|
||||
///
|
||||
/// Gets the currently stored value as an integer.
|
||||
///
|
||||
/// This doesn't clear the stored value.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `ping_name` - represents the optional name of the ping to retrieve the
|
||||
/// metric for. Defaults to the first value in `send_in_pings`.
|
||||
fn test_get_value<'a, S: Into<Option<&'a str>>>(&self, ping_name: S) -> Option<i32> {
|
||||
dispatcher::block_on_queue();
|
||||
|
||||
|
@ -66,19 +47,6 @@ impl glean_core::traits::Counter for CounterMetric {
|
|||
crate::with_glean(|glean| self.0.test_get_value(glean, queried_ping_name))
|
||||
}
|
||||
|
||||
/// **Exported for test purposes.**
|
||||
///
|
||||
/// Gets the number of recorded errors for the given metric and error type.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `error` - The type of error
|
||||
/// * `ping_name` - represents the optional name of the ping to retrieve the
|
||||
/// metric for. Defaults to the first value in `send_in_pings`.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// The number of errors reported.
|
||||
fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
|
||||
&self,
|
||||
error: ErrorType,
|
||||
|
|
|
@ -124,35 +124,11 @@ impl<T> glean_core::traits::Labeled<T> for LabeledMetric<T>
|
|||
where
|
||||
T: AllowLabeled + Clone,
|
||||
{
|
||||
/// Gets a specific metric for a given label.
|
||||
///
|
||||
/// If a set of acceptable labels were specified in the `metrics.yaml` file,
|
||||
/// and the given label is not in the set, it will be recorded under the special `OTHER_LABEL` label.
|
||||
///
|
||||
/// If a set of acceptable labels was not specified in the `metrics.yaml` file,
|
||||
/// only the first 16 unique labels will be used.
|
||||
/// After that, any additional labels will be recorded under the special `OTHER_LABEL` label.
|
||||
///
|
||||
/// Labels must be `snake_case` and less than 30 characters.
|
||||
/// If an invalid label is used, the metric will be recorded in the special `OTHER_LABEL` label.
|
||||
fn get(&self, label: &str) -> T {
|
||||
let inner = self.0.get(label);
|
||||
T::from_inner(inner)
|
||||
}
|
||||
|
||||
/// **Exported for test purposes.**
|
||||
///
|
||||
/// Gets the number of recorded errors for the given metric and error type.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `error` - The type of error
|
||||
/// * `ping_name` - represents the optional name of the ping to retrieve the
|
||||
/// metric for. Defaults to the first value in `send_in_pings`.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// The number of errors reported.
|
||||
fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
|
||||
&self,
|
||||
error: ErrorType,
|
||||
|
|
|
@ -42,25 +42,6 @@ impl PingType {
|
|||
|
||||
#[inherent(pub)]
|
||||
impl glean_core::traits::Ping for PingType {
|
||||
/// Collect and submit the ping for eventual upload.
|
||||
///
|
||||
/// This will collect all stored data to be included in the ping.
|
||||
/// Data with lifetime `ping` will then be reset.
|
||||
///
|
||||
/// If the ping is configured with `send_if_empty = false`
|
||||
/// and the ping currently contains no content,
|
||||
/// it will not be queued for upload.
|
||||
/// If the ping is configured with `send_if_empty = true`
|
||||
/// it will be queued for upload even if otherwise empty.
|
||||
///
|
||||
/// Pings always contain the `ping_info` and `client_info` sections.
|
||||
/// See [ping sections](https://mozilla.github.io/glean/book/user/pings/index.html#ping-sections)
|
||||
/// for details.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `reason` - The reason the ping is being submitted.
|
||||
/// Must be one of the configured `reason_codes`.
|
||||
fn submit(&self, reason: Option<&str>) {
|
||||
crate::submit_ping(self, reason)
|
||||
}
|
||||
|
|
|
@ -32,26 +32,11 @@ impl QuantityMetric {
|
|||
|
||||
#[inherent(pub)]
|
||||
impl glean_core::traits::Quantity for QuantityMetric {
|
||||
/// Sets to the specified value. Must be non-negative.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `value` - The Quantity to set the metric to.
|
||||
fn set(&self, value: i64) {
|
||||
let metric = Arc::clone(&self.0);
|
||||
dispatcher::launch(move || crate::with_glean(|glean| metric.set(glean, value)));
|
||||
}
|
||||
|
||||
/// **Exported for test purposes.**
|
||||
///
|
||||
/// Gets the currently stored value.
|
||||
///
|
||||
/// This doesn't clear the stored value.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `ping_name` - represents the optional name of the ping to retrieve the
|
||||
/// metric for. Defaults to the first value in `send_in_pings`.
|
||||
fn test_get_value<'a, S: Into<Option<&'a str>>>(&self, ping_name: S) -> Option<i64> {
|
||||
dispatcher::block_on_queue();
|
||||
|
||||
|
@ -62,19 +47,6 @@ impl glean_core::traits::Quantity for QuantityMetric {
|
|||
crate::with_glean(|glean| self.0.test_get_value(glean, queried_ping_name))
|
||||
}
|
||||
|
||||
/// **Exported for test purposes.**
|
||||
///
|
||||
/// Gets the number of recorded errors for the given metric and error type.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `error` - The type of error
|
||||
/// * `ping_name` - represents the optional name of the ping to retrieve the
|
||||
/// metric for. Defaults to the first value in `send_in_pings`.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// The number of errors reported.
|
||||
#[allow(dead_code)] // Remove after mozilla/glean#1328
|
||||
fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
|
||||
&self,
|
||||
|
|
|
@ -32,31 +32,12 @@ impl StringMetric {
|
|||
|
||||
#[inherent(pub)]
|
||||
impl glean_core::traits::String for StringMetric {
|
||||
/// Sets to the specified value.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `value` - The string to set the metric to.
|
||||
///
|
||||
/// ## Notes
|
||||
///
|
||||
/// Truncates the value if it is longer than `MAX_STRING_LENGTH` bytes and logs an error.
|
||||
fn set<S: Into<std::string::String>>(&self, value: S) {
|
||||
let metric = Arc::clone(&self.0);
|
||||
let new_value = value.into();
|
||||
dispatcher::launch(move || crate::with_glean(|glean| metric.set(glean, new_value)));
|
||||
}
|
||||
|
||||
/// **Exported for test purposes.**
|
||||
///
|
||||
/// Gets the currently stored value as a string.
|
||||
///
|
||||
/// This doesn't clear the stored value.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `ping_name` - represents the optional name of the ping to retrieve the
|
||||
/// metric for. Defaults to the first value in `send_in_pings`.
|
||||
fn test_get_value<'a, S: Into<Option<&'a str>>>(
|
||||
&self,
|
||||
ping_name: S,
|
||||
|
@ -70,19 +51,6 @@ impl glean_core::traits::String for StringMetric {
|
|||
crate::with_glean(|glean| self.0.test_get_value(glean, queried_ping_name))
|
||||
}
|
||||
|
||||
/// **Exported for test purposes.**
|
||||
///
|
||||
/// Gets the number of recorded errors for the given metric and error type.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `error` - The type of error
|
||||
/// * `ping_name` - represents the optional name of the ping to retrieve the
|
||||
/// metric for. Defaults to the first value in `send_in_pings`.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// The number of errors reported.
|
||||
fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
|
||||
&self,
|
||||
error: ErrorType,
|
||||
|
|
|
@ -34,14 +34,6 @@ impl TimespanMetric {
|
|||
|
||||
#[inherent(pub)]
|
||||
impl glean_core::traits::Timespan for TimespanMetric {
|
||||
/// Starts tracking time for the provided metric.
|
||||
///
|
||||
/// This uses an internal monotonic timer.
|
||||
///
|
||||
/// This records an error if it's already tracking time (i.e.
|
||||
/// [`start`](TimespanMetric::start) was already called with no
|
||||
/// corresponding [`stop`](TimespanMetric::stop)): in that case the original
|
||||
/// start time will be preserved.
|
||||
fn start(&self) {
|
||||
let start_time = time::precise_time_ns();
|
||||
|
||||
|
@ -56,9 +48,6 @@ impl glean_core::traits::Timespan for TimespanMetric {
|
|||
});
|
||||
}
|
||||
|
||||
/// Stops tracking time for the provided metric. Sets the metric to the elapsed time.
|
||||
///
|
||||
/// This will record an error if no [`start`](TimespanMetric::start) was called.
|
||||
fn stop(&self) {
|
||||
let stop_time = time::precise_time_ns();
|
||||
|
||||
|
@ -73,8 +62,6 @@ impl glean_core::traits::Timespan for TimespanMetric {
|
|||
});
|
||||
}
|
||||
|
||||
/// Aborts a previous [`start`](TimespanMetric::start) call. No error is
|
||||
/// recorded if no [`start`](TimespanMetric::start) was called.
|
||||
fn cancel(&self) {
|
||||
let metric = Arc::clone(&self.0);
|
||||
dispatcher::launch(move || {
|
||||
|
@ -84,16 +71,7 @@ impl glean_core::traits::Timespan for TimespanMetric {
|
|||
lock.cancel()
|
||||
});
|
||||
}
|
||||
/// **Exported for test purposes.**
|
||||
///
|
||||
/// Gets the currently stored value as an integer.
|
||||
///
|
||||
/// This doesn't clear the stored value.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `ping_name` - represents the optional name of the ping to retrieve the
|
||||
/// metric for. Defaults to the first value in `send_in_pings`.
|
||||
|
||||
fn test_get_value<'a, S: Into<Option<&'a str>>>(&self, ping_name: S) -> Option<u64> {
|
||||
dispatcher::block_on_queue();
|
||||
|
||||
|
@ -116,19 +94,6 @@ impl glean_core::traits::Timespan for TimespanMetric {
|
|||
})
|
||||
}
|
||||
|
||||
/// **Exported for test purposes.**
|
||||
///
|
||||
/// Gets the number of recorded errors for the given metric and error type.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `error` - The type of error
|
||||
/// * `ping_name` - represents the optional name of the ping to retrieve the
|
||||
/// metric for. Defaults to the first value in `send_in_pings`.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// The number of errors reported.
|
||||
fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
|
||||
&self,
|
||||
error: ErrorType,
|
||||
|
|
|
@ -32,17 +32,11 @@ impl UuidMetric {
|
|||
|
||||
#[inherent(pub)]
|
||||
impl glean_core::traits::Uuid for UuidMetric {
|
||||
/// Sets to the specified value.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `value` - The [`Uuid`](uuid::Uuid) to set the metric to.
|
||||
fn set(&self, value: uuid::Uuid) {
|
||||
let metric = Arc::clone(&self.0);
|
||||
dispatcher::launch(move || crate::with_glean(|glean| metric.set(glean, value)));
|
||||
}
|
||||
|
||||
/// Generates a new random UUID and sets the metric to it.
|
||||
fn generate_and_set(&self) -> uuid::Uuid {
|
||||
// TODO: We can use glean-core's generate_and_set after bug 1673017.
|
||||
let uuid = uuid::Uuid::new_v4();
|
||||
|
@ -50,16 +44,6 @@ impl glean_core::traits::Uuid for UuidMetric {
|
|||
uuid
|
||||
}
|
||||
|
||||
/// **Exported for test purposes.**
|
||||
///
|
||||
/// Gets the currently stored value.
|
||||
///
|
||||
/// This doesn't clear the stored value.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `ping_name` - represents the optional name of the ping to retrieve the
|
||||
/// metric for. Defaults to the first value in `send_in_pings`.
|
||||
fn test_get_value<'a, S: Into<Option<&'a str>>>(&self, ping_name: S) -> Option<uuid::Uuid> {
|
||||
dispatcher::block_on_queue();
|
||||
|
||||
|
@ -70,19 +54,6 @@ impl glean_core::traits::Uuid for UuidMetric {
|
|||
crate::with_glean(|glean| self.0.test_get_value(glean, queried_ping_name))
|
||||
}
|
||||
|
||||
/// **Exported for test purposes.**
|
||||
///
|
||||
/// Gets the number of recorded errors for the given metric and error type.
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `error` - The type of error
|
||||
/// * `ping_name` - represents the optional name of the ping to retrieve the
|
||||
/// metric for. Defaults to the first value in `send_in_pings`.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// The number of errors reported.
|
||||
fn test_get_num_recorded_errors<'a, S: Into<Option<&'a str>>>(
|
||||
&self,
|
||||
error: ErrorType,
|
||||
|
|
Загрузка…
Ссылка в новой задаче