| 1 |
// This Source Code Form is subject to the terms of the Mozilla Public |
| 2 |
// License, v. 2.0. If a copy of the MPL was not distributed with this |
| 3 |
// file, You can obtain one at https://mozilla.org/MPL/2.0/. |
| 4 |
|
| 5 |
use crate::ErrorType; |
| 6 |
|
| 7 |
/// A description for the [`UrlMetric`](crate::metrics::UrlMetric) type. |
| 8 |
/// |
| 9 |
/// When changing this trait, make sure all the operations are |
| 10 |
/// implemented in the related type in `../metrics/`. |
| 11 |
pub trait Url { |
| 12 |
/// Sets to the specified stringified URL. |
| 13 |
/// |
| 14 |
/// # Arguments |
| 15 |
/// |
| 16 |
/// * `glean` - The Glean instance this metric belongs to. |
| 17 |
/// * `value` - The stringified URL to set the metric to. |
| 18 |
/// |
| 19 |
/// ## Notes |
| 20 |
/// |
| 21 |
/// Truncates the value if it is longer than `MAX_URL_LENGTH` bytes and logs an error. |
| 22 |
fn set<S: Into<std::string::String>>(&self, value: S); |
| 23 |
|
| 24 |
/// **Exported for test purposes.** |
| 25 |
/// |
| 26 |
/// Gets the currently stored value as a string. |
| 27 |
/// |
| 28 |
/// This doesn't clear the stored value. |
| 29 |
/// |
| 30 |
/// # Arguments |
| 31 |
/// |
| 32 |
/// * `ping_name` - represents the optional name of the ping to retrieve the |
| 33 |
/// metric for. Defaults to the first value in `send_in_pings`. |
| 34 |
fn test_get_value<'a, S: Into<Option<&'a str>>>( |
| 35 |
&self, |
| 36 |
ping_name: S, |
| 37 |
) -> Option<std::string::String>; |
| 38 |
|
| 39 |
/// **Exported for test purposes.** |
| 40 |
/// |
| 41 |
/// Gets the number of recorded errors for the given metric and error type. |
| 42 |
/// |
| 43 |
/// # Arguments |
| 44 |
/// |
| 45 |
/// * `error` - The type of error |
| 46 |
/// |
| 47 |
/// # Returns |
| 48 |
/// |
| 49 |
/// The number of errors reported. |
| 50 |
fn test_get_num_recorded_errors(&self, error: ErrorType) -> i32; |
| 51 |
} |