Bug 1938145 Part one - Rename MetricId -> BaseMetricId and MetricGetter -> MetricId to make it clearer what the struct is doing, and resolve ambiguities over id types r=chutten

Differential Revision: https://phabricator.services.mozilla.com/D237750
This commit is contained in:
Adam Brouwers-Harries
2025-04-01 17:22:22 +00:00
parent 6e90ce0ab2
commit 4a16a85d2e
31 changed files with 431 additions and 435 deletions

View File

@@ -4,7 +4,7 @@
//! IPC Implementation, Rust part
use crate::private::MetricId;
use crate::private::BaseMetricId;
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
@@ -23,21 +23,21 @@ type EventRecord = (u64, HashMap<String, String>);
/// process.
#[derive(Debug, Default, Deserialize, Serialize)]
pub struct IPCPayload {
pub booleans: HashMap<MetricId, bool>,
pub labeled_booleans: HashMap<MetricId, HashMap<String, bool>>,
pub counters: HashMap<MetricId, i32>,
pub custom_samples: HashMap<MetricId, Vec<i64>>,
pub labeled_custom_samples: HashMap<MetricId, HashMap<String, Vec<i64>>>,
pub denominators: HashMap<MetricId, i32>,
pub events: HashMap<MetricId, Vec<EventRecord>>,
pub labeled_counters: HashMap<MetricId, HashMap<String, i32>>,
pub memory_samples: HashMap<MetricId, Vec<u64>>,
pub labeled_memory_samples: HashMap<MetricId, HashMap<String, Vec<u64>>>,
pub numerators: HashMap<MetricId, i32>,
pub rates: HashMap<MetricId, (i32, i32)>,
pub string_lists: HashMap<MetricId, Vec<String>>,
pub timing_samples: HashMap<MetricId, Vec<u64>>,
pub labeled_timing_samples: HashMap<MetricId, HashMap<String, Vec<u64>>>,
pub booleans: HashMap<BaseMetricId, bool>,
pub labeled_booleans: HashMap<BaseMetricId, HashMap<String, bool>>,
pub counters: HashMap<BaseMetricId, i32>,
pub custom_samples: HashMap<BaseMetricId, Vec<i64>>,
pub labeled_custom_samples: HashMap<BaseMetricId, HashMap<String, Vec<i64>>>,
pub denominators: HashMap<BaseMetricId, i32>,
pub events: HashMap<BaseMetricId, Vec<EventRecord>>,
pub labeled_counters: HashMap<BaseMetricId, HashMap<String, i32>>,
pub memory_samples: HashMap<BaseMetricId, Vec<u64>>,
pub labeled_memory_samples: HashMap<BaseMetricId, HashMap<String, Vec<u64>>>,
pub numerators: HashMap<BaseMetricId, i32>,
pub rates: HashMap<BaseMetricId, (i32, i32)>,
pub string_lists: HashMap<BaseMetricId, Vec<String>>,
pub timing_samples: HashMap<BaseMetricId, Vec<u64>>,
pub labeled_timing_samples: HashMap<BaseMetricId, HashMap<String, Vec<u64>>>,
}
/// Global singleton: pending IPC payload.

View File

@@ -7,7 +7,7 @@ use std::sync::Arc;
use glean::traits::Boolean;
use super::{CommonMetricData, MetricGetter, MetricId};
use super::{BaseMetricId, CommonMetricData, MetricId};
use crate::ipc::{need_ipc, with_ipc_payload};
@@ -20,18 +20,18 @@ pub enum BooleanMetric {
/// The metric's ID. Used for testing and profiler markers. Boolean
/// metrics can be labeled, so we may have either a metric ID or
/// sub-metric ID.
id: MetricGetter,
id: MetricId,
inner: Arc<glean::private::BooleanMetric>,
},
Child(BooleanMetricIpc),
UnorderedChild(MetricId),
UnorderedChild(BaseMetricId),
}
#[derive(Clone, Debug)]
pub struct BooleanMetricIpc;
impl BooleanMetric {
/// Create a new boolean metric.
pub fn new(id: MetricId, meta: CommonMetricData) -> Self {
pub fn new(id: BaseMetricId, meta: CommonMetricData) -> Self {
if need_ipc() {
BooleanMetric::Child(BooleanMetricIpc)
} else {
@@ -42,7 +42,7 @@ impl BooleanMetric {
}
}
pub fn with_unordered_ipc(id: MetricId, meta: CommonMetricData) -> Self {
pub fn with_unordered_ipc(id: BaseMetricId, meta: CommonMetricData) -> Self {
if need_ipc() {
BooleanMetric::UnorderedChild(id)
} else {
@@ -51,7 +51,7 @@ impl BooleanMetric {
}
#[cfg(test)]
pub(crate) fn metric_id(&self) -> MetricGetter {
pub(crate) fn metric_id(&self) -> MetricId {
match self {
BooleanMetric::Parent { id, .. } => *id,
BooleanMetric::UnorderedChild(id) => (*id).into(),

View File

@@ -6,7 +6,7 @@ use glean::traits::Counter;
use inherent::inherent;
use std::sync::Arc;
use super::{CommonMetricData, MetricGetter, MetricId};
use super::{BaseMetricId, CommonMetricData, MetricId};
use crate::ipc::{need_ipc, with_ipc_payload};
/// A counter metric.
@@ -19,17 +19,17 @@ pub enum CounterMetric {
/// The metric's ID. Used for testing and profiler markers. Counter
/// metrics can be labeled, so we may have either a metric ID or
/// sub-metric ID.
id: MetricGetter,
id: MetricId,
inner: Arc<glean::private::CounterMetric>,
},
Child(CounterMetricIpc),
}
#[derive(Clone, Debug)]
pub struct CounterMetricIpc(MetricId);
pub struct CounterMetricIpc(BaseMetricId);
impl CounterMetric {
/// Create a new counter metric.
pub fn new(id: MetricId, meta: CommonMetricData) -> Self {
pub fn new(id: BaseMetricId, meta: CommonMetricData) -> Self {
if need_ipc() {
CounterMetric::Child(CounterMetricIpc(id))
} else {
@@ -48,7 +48,7 @@ impl CounterMetric {
/// * and is sent in precisely one ping.
pub fn codegen_new(id: u32, category: &str, name: &str, ping: &str) -> Self {
if need_ipc() {
CounterMetric::Child(CounterMetricIpc(MetricId(id)))
CounterMetric::Child(CounterMetricIpc(BaseMetricId(id)))
} else {
let inner = Arc::new(glean::private::CounterMetric::new(CommonMetricData {
category: category.into(),
@@ -57,7 +57,7 @@ impl CounterMetric {
..Default::default()
}));
CounterMetric::Parent {
id: MetricId(id).into(),
id: BaseMetricId(id).into(),
inner,
}
}
@@ -70,7 +70,7 @@ impl CounterMetric {
/// * and is sent in precisely one ping.
pub fn codegen_disabled_new(id: u32, category: &str, name: &str, ping: &str) -> Self {
if need_ipc() {
CounterMetric::Child(CounterMetricIpc(MetricId(id)))
CounterMetric::Child(CounterMetricIpc(BaseMetricId(id)))
} else {
let inner = Arc::new(glean::private::CounterMetric::new(CommonMetricData {
category: category.into(),
@@ -80,14 +80,14 @@ impl CounterMetric {
..Default::default()
}));
CounterMetric::Parent {
id: MetricId(id).into(),
id: BaseMetricId(id).into(),
inner,
}
}
}
#[cfg(test)]
pub(crate) fn metric_id(&self) -> MetricGetter {
pub(crate) fn metric_id(&self) -> MetricId {
match self {
CounterMetric::Parent { id, .. } => *id,
CounterMetric::Child(c) => c.0.into(),
@@ -102,7 +102,7 @@ impl CounterMetric {
// context of a test. If this code is used elsewhere, the
// `unwrap` should be replaced with proper error handling of
// the `None` case.
CounterMetric::Child(CounterMetricIpc((*id).metric_id().unwrap()))
CounterMetric::Child(CounterMetricIpc((*id).base_metric_id().unwrap()))
}
CounterMetric::Child(_) => panic!("Can't get a child metric from a child metric"),
}
@@ -135,7 +135,7 @@ impl Counter for CounterMetric {
payload.counters.insert(c.0, amount);
}
});
MetricGetter::Id(c.0)
MetricId::Id(c.0)
}
};
@@ -224,8 +224,8 @@ mod test {
let _raii = ipc::test_set_need_ipc(true);
let metric_id = child_metric
.metric_id()
.metric_id()
.expect("Cannot perform IPC calls without a MetricId");
.base_metric_id()
.expect("Cannot perform IPC calls without a BaseMetricId");
child_metric.add(42);

View File

@@ -5,7 +5,7 @@
use inherent::inherent;
use std::sync::Arc;
use super::{CommonMetricData, MetricGetter, MetricId};
use super::{BaseMetricId, CommonMetricData, MetricId};
use glean::{DistributionData, ErrorType, HistogramType};
use crate::ipc::{need_ipc, with_ipc_payload};
@@ -26,18 +26,18 @@ pub enum CustomDistributionMetric {
/// The metric's ID. Used for testing and profiler markers. Custom
/// distribution metrics can be labeled, so we may have either a
/// metric ID or sub-metric ID.
id: MetricGetter,
id: MetricId,
inner: Arc<glean::private::CustomDistributionMetric>,
},
Child(CustomDistributionMetricIpc),
}
#[derive(Debug, Clone)]
pub struct CustomDistributionMetricIpc(pub MetricId);
pub struct CustomDistributionMetricIpc(pub BaseMetricId);
impl CustomDistributionMetric {
/// Create a new custom distribution metric.
pub fn new(
id: MetricId,
id: BaseMetricId,
meta: CommonMetricData,
range_min: i64,
range_max: i64,
@@ -62,7 +62,7 @@ impl CustomDistributionMetric {
}
#[cfg(test)]
pub(crate) fn metric_id(&self) -> MetricGetter {
pub(crate) fn metric_id(&self) -> MetricId {
match self {
CustomDistributionMetric::Parent { id, .. } => *id,
CustomDistributionMetric::Child(c) => c.0.into(),
@@ -77,7 +77,7 @@ impl CustomDistributionMetric {
// context of a test. If this code is used elsewhere, the
// `unwrap` should be replaced with proper error handling of
// the `None` case.
CustomDistributionMetricIpc(id.metric_id().unwrap()),
CustomDistributionMetricIpc(id.base_metric_id().unwrap()),
),
CustomDistributionMetric::Child(_) => {
panic!("Can't get a child metric from a child metric")
@@ -136,7 +136,7 @@ impl CustomDistribution for CustomDistributionMetric {
payload.custom_samples.insert(c.0, samples);
}
});
MetricGetter::Id(c.0)
MetricId::Id(c.0)
}
};
@@ -163,7 +163,7 @@ impl CustomDistribution for CustomDistributionMetric {
payload.custom_samples.insert(c.0, vec![sample]);
}
});
MetricGetter::Id(c.0)
MetricId::Id(c.0)
}
};
#[cfg(feature = "with_gecko")]

View File

@@ -4,7 +4,7 @@
use inherent::inherent;
use super::{CommonMetricData, MetricId};
use super::{BaseMetricId, CommonMetricData};
use super::TimeUnit;
use crate::ipc::need_ipc;
@@ -19,7 +19,7 @@ use super::profiler_utils::{
#[cfg(feature = "with_gecko")]
#[derive(serde::Serialize, serde::Deserialize, Debug)]
struct DatetimeMetricMarker {
id: MetricId,
id: BaseMetricId,
time: chrono::DateTime<FixedOffset>,
}
@@ -79,9 +79,9 @@ impl gecko_profiler::ProfilerMarker for DatetimeMetricMarker {
pub enum DatetimeMetric {
Parent {
/// The metric's ID. Date time metrics canot be labeled, so we only
/// store a MetricId. If this changes, this should be changed to a
/// MetricGetter to distinguish between metrics and sub-metrics.
id: MetricId,
/// store a BaseMetricId. If this changes, this should be changed to a
/// MetricId to distinguish between metrics and sub-metrics.
id: BaseMetricId,
inner: glean::private::DatetimeMetric,
},
Child(DatetimeMetricIpc),
@@ -91,7 +91,7 @@ pub struct DatetimeMetricIpc;
impl DatetimeMetric {
/// Create a new datetime metric.
pub fn new(id: MetricId, meta: CommonMetricData, time_unit: TimeUnit) -> Self {
pub fn new(id: BaseMetricId, meta: CommonMetricData, time_unit: TimeUnit) -> Self {
if need_ipc() {
DatetimeMetric::Child(DatetimeMetricIpc)
} else {

View File

@@ -9,7 +9,7 @@ use super::CommonMetricData;
use glean::traits::Counter;
use crate::ipc::{need_ipc, with_ipc_payload};
use crate::private::MetricId;
use crate::private::BaseMetricId;
/// Developer-facing API for recording counter metrics that are acting as
/// external denominators for rate metrics.
@@ -22,19 +22,23 @@ pub enum DenominatorMetric {
Parent {
/// The metric's ID. Used for testing and profiler markers.
/// Denominator metrics canot be labeled, so we only store a
/// MetricId. If this changes, this should be changed to a
/// MetricGetter to distinguish between metrics and sub-metrics.
id: MetricId,
/// BaseMetricId. If this changes, this should be changed to a
/// MetricId to distinguish between metrics and sub-metrics.
id: BaseMetricId,
inner: glean::private::DenominatorMetric,
},
Child(DenominatorMetricIpc),
}
#[derive(Clone, Debug)]
pub struct DenominatorMetricIpc(MetricId);
pub struct DenominatorMetricIpc(BaseMetricId);
impl DenominatorMetric {
/// The constructor used by automatically generated metrics.
pub fn new(id: MetricId, meta: CommonMetricData, numerators: Vec<CommonMetricData>) -> Self {
pub fn new(
id: BaseMetricId,
meta: CommonMetricData,
numerators: Vec<CommonMetricData>,
) -> Self {
if need_ipc() {
DenominatorMetric::Child(DenominatorMetricIpc(id))
} else {
@@ -44,7 +48,7 @@ impl DenominatorMetric {
}
#[cfg(test)]
pub(crate) fn metric_id(&self) -> MetricId {
pub(crate) fn metric_id(&self) -> BaseMetricId {
match self {
DenominatorMetric::Parent { id, .. } => *id,
DenominatorMetric::Child(c) => c.0,

View File

@@ -6,7 +6,7 @@ use std::collections::HashMap;
use inherent::inherent;
use super::{CommonMetricData, MetricId, RecordedEvent};
use super::{BaseMetricId, CommonMetricData, RecordedEvent};
use crate::ipc::{need_ipc, with_ipc_payload};
@@ -19,7 +19,7 @@ use super::profiler_utils::TelemetryProfilerCategory;
#[cfg(feature = "with_gecko")]
#[derive(serde::Serialize, serde::Deserialize, Debug)]
struct EventMetricMarker {
id: MetricId,
id: BaseMetricId,
extra: HashMap<String, String>,
}
@@ -72,21 +72,21 @@ impl gecko_profiler::ProfilerMarker for EventMetricMarker {
pub enum EventMetric<K> {
Parent {
/// The metric's ID. Used for testing and profiler markers. Event
/// metrics canot be labeled, so we only store a MetricId. If this
/// changes, this should be changed to a MetricGetter to distinguish
/// metrics canot be labeled, so we only store a BaseMetricId. If this
/// changes, this should be changed to a MetricId to distinguish
/// between metrics and sub-metrics.
id: MetricId,
id: BaseMetricId,
inner: glean::private::EventMetric<K>,
},
Child(EventMetricIpc),
}
#[derive(Debug)]
pub struct EventMetricIpc(MetricId);
pub struct EventMetricIpc(BaseMetricId);
impl<K: 'static + ExtraKeys + Send + Sync + Clone> EventMetric<K> {
/// Create a new event metric.
pub fn new(id: MetricId, meta: CommonMetricData) -> Self {
pub fn new(id: BaseMetricId, meta: CommonMetricData) -> Self {
if need_ipc() {
EventMetric::Child(EventMetricIpc(id))
} else {
@@ -96,7 +96,7 @@ impl<K: 'static + ExtraKeys + Send + Sync + Clone> EventMetric<K> {
}
pub fn with_runtime_extra_keys(
id: MetricId,
id: BaseMetricId,
meta: CommonMetricData,
allowed_extra_keys: Vec<String>,
) -> Self {
@@ -234,7 +234,7 @@ mod test {
let _lock = lock_test();
let metric = EventMetric::<NoExtraKeys>::new(
MetricId(0),
BaseMetricId(0),
CommonMetricData {
name: "event_metric".into(),
category: "telemetry".into(),

View File

@@ -5,9 +5,9 @@
use inherent::inherent;
use super::{
ErrorType, LabeledBooleanMetric, LabeledCounterMetric, LabeledCustomDistributionMetric,
LabeledMemoryDistributionMetric, LabeledMetricData, LabeledQuantityMetric, LabeledStringMetric,
LabeledTimingDistributionMetric, MetricId, SubMetricId,
BaseMetricId, ErrorType, LabeledBooleanMetric, LabeledCounterMetric,
LabeledCustomDistributionMetric, LabeledMemoryDistributionMetric, LabeledMetricData,
LabeledQuantityMetric, LabeledStringMetric, LabeledTimingDistributionMetric, SubMetricId,
};
use crate::ipc::need_ipc;
use crate::metrics::__glean_metric_maps::submetric_maps;
@@ -20,9 +20,9 @@ use std::sync::Arc;
/// We wrap it in a private module that is inaccessible outside of this module.
mod private {
use super::{
need_ipc, submetric_maps, LabeledBooleanMetric, LabeledCounterMetric,
need_ipc, submetric_maps, BaseMetricId, LabeledBooleanMetric, LabeledCounterMetric,
LabeledCustomDistributionMetric, LabeledMemoryDistributionMetric, LabeledQuantityMetric,
LabeledStringMetric, LabeledTimingDistributionMetric, MetricId, SubMetricId,
LabeledStringMetric, LabeledTimingDistributionMetric, SubMetricId,
};
use crate::private::labeled_timing_distribution::LabeledTimingDistributionMetricKind;
use crate::private::{
@@ -38,14 +38,14 @@ mod private {
pub trait Sealed {
type GleanMetric: glean::private::AllowLabeled + Clone;
fn from_glean_metric(
id: MetricId,
id: BaseMetricId,
metric: &glean::private::LabeledMetric<Self::GleanMetric>,
label: &str,
permit_unordered_ipc: bool,
) -> (Arc<Self>, SubMetricId);
}
fn submetric_id_for(id: MetricId, label: &str) -> SubMetricId {
fn submetric_id_for(id: BaseMetricId, label: &str) -> SubMetricId {
let label_owned = label.to_string();
let tuple = (id, label_owned);
let mut map = submetric_maps::LABELED_METRICS_TO_IDS
@@ -66,7 +66,7 @@ mod private {
impl Sealed for LabeledBooleanMetric {
type GleanMetric = glean::private::BooleanMetric;
fn from_glean_metric(
id: MetricId,
id: BaseMetricId,
metric: &glean::private::LabeledMetric<Self::GleanMetric>,
label: &str,
permit_unordered_ipc: bool,
@@ -104,7 +104,7 @@ mod private {
impl Sealed for LabeledStringMetric {
type GleanMetric = glean::private::StringMetric;
fn from_glean_metric(
id: MetricId,
id: BaseMetricId,
metric: &glean::private::LabeledMetric<Self::GleanMetric>,
label: &str,
_permit_unordered_ipc: bool,
@@ -135,7 +135,7 @@ mod private {
impl Sealed for LabeledCounterMetric {
type GleanMetric = glean::private::CounterMetric;
fn from_glean_metric(
id: MetricId,
id: BaseMetricId,
metric: &glean::private::LabeledMetric<Self::GleanMetric>,
label: &str,
_permit_unordered_ipc: bool,
@@ -168,7 +168,7 @@ mod private {
impl Sealed for LabeledCustomDistributionMetric {
type GleanMetric = glean::private::CustomDistributionMetric;
fn from_glean_metric(
id: MetricId,
id: BaseMetricId,
metric: &glean::private::LabeledMetric<Self::GleanMetric>,
label: &str,
_permit_unordered_ipc: bool,
@@ -201,7 +201,7 @@ mod private {
impl Sealed for LabeledMemoryDistributionMetric {
type GleanMetric = glean::private::MemoryDistributionMetric;
fn from_glean_metric(
id: MetricId,
id: BaseMetricId,
metric: &glean::private::LabeledMetric<Self::GleanMetric>,
label: &str,
_permit_unordered_ipc: bool,
@@ -234,7 +234,7 @@ mod private {
impl Sealed for LabeledTimingDistributionMetric {
type GleanMetric = glean::private::TimingDistributionMetric;
fn from_glean_metric(
id: MetricId,
id: BaseMetricId,
metric: &glean::private::LabeledMetric<Self::GleanMetric>,
label: &str,
_permit_unordered_ipc: bool,
@@ -278,7 +278,7 @@ mod private {
impl Sealed for LabeledQuantityMetric {
type GleanMetric = glean::private::QuantityMetric;
fn from_glean_metric(
id: MetricId,
id: BaseMetricId,
metric: &glean::private::LabeledMetric<Self::GleanMetric>,
label: &str,
_permit_unordered_ipc: bool,
@@ -343,7 +343,7 @@ impl<T> AllowLabeled for T where T: private::Sealed {}
/// ```
pub struct LabeledMetric<T: AllowLabeled, E> {
/// The metric ID of the underlying metric.
id: MetricId,
id: BaseMetricId,
/// Wrapping the underlying core metric.
///
@@ -365,7 +365,7 @@ where
///
/// See [`get`](#method.get) for information on how static or dynamic labels are handled.
pub fn new(
id: MetricId,
id: BaseMetricId,
meta: LabeledMetricData,
labels: Option<Vec<Cow<'static, str>>>,
) -> LabeledMetric<T, E> {
@@ -379,7 +379,7 @@ where
}
pub fn with_unordered_ipc(
id: MetricId,
id: BaseMetricId,
meta: LabeledMetricData,
labels: Option<Vec<Cow<'static, str>>>,
) -> LabeledMetric<T, E> {

View File

@@ -10,10 +10,10 @@ use crate::ipc::with_ipc_payload;
use crate::private::BooleanMetric;
use std::collections::HashMap;
use super::MetricId;
use super::BaseMetricId;
#[allow(unused)]
use super::MetricGetter;
use super::MetricId;
/// A boolean metric that knows it's a labeled_boolean's submetric.
///
@@ -23,12 +23,12 @@ use super::MetricGetter;
pub enum LabeledBooleanMetric {
Parent(BooleanMetric),
Child,
UnorderedChild { id: MetricId, label: String },
UnorderedChild { id: BaseMetricId, label: String },
}
impl LabeledBooleanMetric {
#[cfg(test)]
pub(crate) fn metric_id(&self) -> MetricGetter {
pub(crate) fn metric_id(&self) -> MetricId {
match self {
LabeledBooleanMetric::Parent(p) => p.metric_id(),
LabeledBooleanMetric::UnorderedChild { id, .. } => (*id).into(),
@@ -144,8 +144,8 @@ mod test {
let metric_id = child_metric
.metric_id()
.metric_id()
.expect("Cannot perform IPC calls without a MetricId");
.base_metric_id()
.expect("Cannot perform IPC calls without a BaseMetricId");
child_metric.set(false);

View File

@@ -10,8 +10,8 @@ use super::CommonMetricData;
use crate::ipc::{need_ipc, with_ipc_payload};
#[cfg(test)]
use crate::private::MetricGetter;
use crate::private::{CounterMetric, MetricId};
use crate::private::MetricId;
use crate::private::{BaseMetricId, CounterMetric};
use std::collections::HashMap;
@@ -22,12 +22,12 @@ use std::collections::HashMap;
#[derive(Clone)]
pub enum LabeledCounterMetric {
Parent(CounterMetric),
Child { id: MetricId, label: String },
Child { id: BaseMetricId, label: String },
}
impl LabeledCounterMetric {
/// Create a new labeled counter submetric.
pub fn new(id: MetricId, meta: CommonMetricData, label: String) -> Self {
pub fn new(id: BaseMetricId, meta: CommonMetricData, label: String) -> Self {
if need_ipc() {
LabeledCounterMetric::Child { id, label }
} else {
@@ -36,7 +36,7 @@ impl LabeledCounterMetric {
}
#[cfg(test)]
pub(crate) fn metric_id(&self) -> MetricGetter {
pub(crate) fn metric_id(&self) -> MetricId {
match self {
LabeledCounterMetric::Parent(p) => p.metric_id(),
LabeledCounterMetric::Child { id, .. } => (*id).into(),
@@ -177,8 +177,8 @@ mod test {
let metric_id = child_metric
.metric_id()
.metric_id()
.expect("Cannot perform IPC calls without a MetricId");
.base_metric_id()
.expect("Cannot perform IPC calls without a BaseMetricId");
child_metric.add(42);

View File

@@ -7,7 +7,7 @@ use inherent::inherent;
use glean::traits::CustomDistribution;
use crate::ipc::with_ipc_payload;
use crate::private::{CustomDistributionMetric, DistributionData, MetricId};
use crate::private::{BaseMetricId, CustomDistributionMetric, DistributionData};
use std::collections::HashMap;
#[cfg(feature = "with_gecko")]
@@ -23,12 +23,12 @@ use super::profiler_utils::{
#[derive(Clone)]
pub enum LabeledCustomDistributionMetric {
Parent(CustomDistributionMetric),
Child { id: MetricId, label: String },
Child { id: BaseMetricId, label: String },
}
impl LabeledCustomDistributionMetric {
#[cfg(test)]
pub(crate) fn metric_id(&self) -> crate::private::MetricGetter {
pub(crate) fn metric_id(&self) -> crate::private::MetricId {
match self {
LabeledCustomDistributionMetric::Parent(p) => p.metric_id(),
LabeledCustomDistributionMetric::Child { id, .. } => (*id).into(),
@@ -166,8 +166,8 @@ mod test {
let metric_id = child_metric
.metric_id()
.metric_id()
.expect("Cannot perform IPC calls without a MetricId");
.base_metric_id()
.expect("Cannot perform IPC calls without a BaseMetricId");
child_metric.accumulate_single_sample_signed(42);

View File

@@ -7,7 +7,7 @@ use inherent::inherent;
use glean::traits::MemoryDistribution;
use crate::ipc::with_ipc_payload;
use crate::private::{DistributionData, MemoryDistributionMetric, MetricId};
use crate::private::{BaseMetricId, DistributionData, MemoryDistributionMetric};
use std::collections::HashMap;
#[cfg(feature = "with_gecko")]
@@ -23,12 +23,12 @@ use super::profiler_utils::{
#[derive(Clone)]
pub enum LabeledMemoryDistributionMetric {
Parent(MemoryDistributionMetric),
Child { id: MetricId, label: String },
Child { id: BaseMetricId, label: String },
}
impl LabeledMemoryDistributionMetric {
#[cfg(test)]
pub(crate) fn metric_id(&self) -> crate::private::MetricGetter {
pub(crate) fn metric_id(&self) -> crate::private::MetricId {
match self {
LabeledMemoryDistributionMetric::Parent(p) => p.metric_id(),
LabeledMemoryDistributionMetric::Child { id, .. } => (*id).into(),
@@ -180,8 +180,8 @@ mod test {
.get(
&child_metric
.metric_id()
.metric_id()
.expect("Cannot perform IPC calls without a MetricId")
.base_metric_id()
.expect("Cannot perform IPC calls without a BaseMetricId")
)
.unwrap()
.get(label)

View File

@@ -12,9 +12,7 @@ use std::convert::TryInto;
use std::sync::Arc;
use std::time::Duration;
use crate::private::{
DistributionData, ErrorType, MetricGetter, TimerId, TimingDistributionMetric,
};
use crate::private::{DistributionData, ErrorType, MetricId, TimerId, TimingDistributionMetric};
use crate::ipc::with_ipc_payload;
@@ -27,7 +25,7 @@ use super::timing_distribution::{TDMPayload, TimingDistributionMetricMarker};
#[derive(Clone)]
pub struct LabeledTimingDistributionMetric {
pub(crate) inner: Arc<TimingDistributionMetric>,
pub(crate) id: MetricGetter,
pub(crate) id: MetricId,
pub(crate) label: String,
pub(crate) kind: LabeledTimingDistributionMetricKind,
}
@@ -39,7 +37,7 @@ pub enum LabeledTimingDistributionMetricKind {
impl LabeledTimingDistributionMetric {
#[cfg(test)]
pub(crate) fn metric_id(&self) -> MetricGetter {
pub(crate) fn metric_id(&self) -> MetricId {
self.id
}
}
@@ -59,8 +57,8 @@ impl TimingDistribution for LabeledTimingDistributionMetric {
}
let id = &self
.id
.metric_id()
.expect("Cannot perform GIFFT calls without a MetricId");
.base_metric_id()
.expect("Cannot perform GIFFT calls without a BaseMetricId");
// SAFETY: We're only loaning to C++ data we don't later use.
unsafe {
GIFFT_LabeledTimingDistributionStart(
@@ -97,8 +95,8 @@ impl TimingDistribution for LabeledTimingDistributionMetric {
if let Some(sample) = self.inner.child_stop(timer_id) {
let id = &self
.id
.metric_id()
.expect("Cannot perform IPC calls without a MetricId");
.base_metric_id()
.expect("Cannot perform IPC calls without a BaseMetricId");
with_ipc_payload(move |payload| {
if let Some(map) = payload.labeled_timing_samples.get_mut(id) {
if let Some(v) = map.get_mut(&self.label) {
@@ -128,8 +126,8 @@ impl TimingDistribution for LabeledTimingDistributionMetric {
}
let id = &self
.id
.metric_id()
.expect("Cannot perform GIFFT calls without a MetricId");
.base_metric_id()
.expect("Cannot perform GIFFT calls without a BaseMetricId");
// SAFETY: We're only loaning to C++ data we don't later use.
unsafe {
GIFFT_LabeledTimingDistributionStopAndAccumulate(
@@ -169,8 +167,8 @@ impl TimingDistribution for LabeledTimingDistributionMetric {
}
let metric_id = &self
.id
.metric_id()
.expect("Cannot perform GIFFT calls without a MetricId");
.base_metric_id()
.expect("Cannot perform GIFFT calls without a BaseMetricId");
// SAFETY: We're only loaning to C++ data we don't later use.
unsafe {
GIFFT_LabeledTimingDistributionCancel(
@@ -321,8 +319,8 @@ impl TimingDistribution for LabeledTimingDistributionMetric {
with_ipc_payload(move |payload| {
let id = &self
.id
.metric_id()
.expect("Cannot perform IPC calls without a MetricId");
.base_metric_id()
.expect("Cannot perform IPC calls without a BaseMetricId");
if let Some(map) = payload.labeled_timing_samples.get_mut(id) {
if let Some(v) = map.get_mut(&self.label) {
v.push(sample);
@@ -355,8 +353,8 @@ impl TimingDistribution for LabeledTimingDistributionMetric {
}
let id = &self
.id
.metric_id()
.expect("Cannot perform GIFFT calls without a MetricId");
.base_metric_id()
.expect("Cannot perform GIFFT calls without a BaseMetricId");
// SAFETY: We're only loaning to C++ data we don't later use.
unsafe {
GIFFT_LabeledTimingDistributionAccumulateRawMillis(
@@ -458,8 +456,8 @@ mod test {
.get(
&child_metric
.metric_id()
.metric_id()
.expect("Cannot perform IPC calls without a MetricId")
.base_metric_id()
.expect("Cannot perform IPC calls without a BaseMetricId")
)
.unwrap()
.get(label)

View File

@@ -6,7 +6,7 @@ use inherent::inherent;
use std::convert::TryInto;
use std::sync::Arc;
use super::{CommonMetricData, DistributionData, MemoryUnit, MetricGetter, MetricId};
use super::{BaseMetricId, CommonMetricData, DistributionData, MemoryUnit, MetricId};
use glean::traits::MemoryDistribution;
@@ -27,17 +27,17 @@ pub enum MemoryDistributionMetric {
/// The metric's ID. Used for testing and profiler markers. Memory
/// distribution metrics can be labeled, so we may have either a
/// metric ID or sub-metric ID.
id: MetricGetter,
id: MetricId,
inner: Arc<glean::private::MemoryDistributionMetric>,
},
Child(MemoryDistributionMetricIpc),
}
#[derive(Clone, Debug)]
pub struct MemoryDistributionMetricIpc(pub MetricId);
pub struct MemoryDistributionMetricIpc(pub BaseMetricId);
impl MemoryDistributionMetric {
/// Create a new memory distribution metric.
pub fn new(id: MetricId, meta: CommonMetricData, memory_unit: MemoryUnit) -> Self {
pub fn new(id: BaseMetricId, meta: CommonMetricData, memory_unit: MemoryUnit) -> Self {
if need_ipc() {
MemoryDistributionMetric::Child(MemoryDistributionMetricIpc(id))
} else {
@@ -57,7 +57,7 @@ impl MemoryDistributionMetric {
// context of a test. If this code is used elsewhere, the
// `unwrap` should be replaced with proper error handling of
// the `None` case.
MemoryDistributionMetricIpc((*id).metric_id().unwrap()),
MemoryDistributionMetricIpc((*id).base_metric_id().unwrap()),
),
MemoryDistributionMetric::Child(_) => {
panic!("Can't get a child metric from a child metric")
@@ -66,7 +66,7 @@ impl MemoryDistributionMetric {
}
#[cfg(test)]
pub(crate) fn metric_id(&self) -> MetricGetter {
pub(crate) fn metric_id(&self) -> MetricId {
match self {
MemoryDistributionMetric::Parent { id, .. } => *id,
MemoryDistributionMetric::Child(c) => c.0.into(),
@@ -91,7 +91,7 @@ impl MemoryDistributionMetric {
payload.memory_samples.insert(c.0, samples);
}
});
MetricGetter::Id(c.0)
MetricId::Id(c.0)
}
};
#[cfg(feature = "with_gecko")]
@@ -171,7 +171,7 @@ impl MemoryDistribution for MemoryDistributionMetric {
payload.memory_samples.insert(c.0, vec![sample]);
}
});
MetricGetter::Id(c.0)
MetricId::Id(c.0)
}
};
#[cfg(feature = "with_gecko")]
@@ -243,7 +243,7 @@ mod test {
let _lock = lock_test();
let metric = MemoryDistributionMetric::new(
MetricId(0),
BaseMetricId(0),
CommonMetricData {
name: "memory_distribution_metric".into(),
category: "telemetry".into(),

View File

@@ -7,16 +7,16 @@ use serde::{Deserialize, Serialize};
/// Uniquely identify a metric so that we can look up names, labels (etc) and
/// perform IPC
#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, Deserialize, Serialize)]
pub enum MetricGetter {
Id(MetricId),
pub enum MetricId {
Id(BaseMetricId),
SubId(SubMetricId),
}
impl MetricGetter {
impl MetricId {
/// Extract the underlying metric_id, if there is one.
pub fn metric_id(self) -> Option<MetricId> {
pub fn base_metric_id(self) -> Option<BaseMetricId> {
match self {
MetricGetter::Id(metric_id) => Some(metric_id),
MetricId::Id(base_metric_id) => Some(base_metric_id),
_ => None,
}
}
@@ -27,7 +27,7 @@ impl MetricGetter {
}
#[cfg(feature = "with_gecko")]
impl MetricGetter {
impl MetricId {
/// Given a metric getter, retrieve the name and (optionally) label of the
/// underlying metric. Note, this currently returns the name of the
/// metric in the so-called "JavaScript conjugation", while labels are
@@ -36,8 +36,8 @@ impl MetricGetter {
/// will allow us to get both in the yaml conjugation.
pub fn get_identifiers(&self) -> (String, Option<String>) {
match self {
MetricGetter::Id(id) => (id.get_name(), None),
MetricGetter::SubId(sid) => match sid.lookup_metric_id_and_label() {
MetricId::Id(id) => (id.get_name(), None),
MetricId::SubId(sid) => match sid.lookup_metric_id_and_label() {
Some((id, label)) => (id.get_name(), Some(label)),
None => (String::from("Could not find submetric in maps"), None),
},
@@ -45,25 +45,25 @@ impl MetricGetter {
}
}
impl From<MetricId> for MetricGetter {
fn from(metric_id: MetricId) -> MetricGetter {
MetricGetter::Id(metric_id)
impl From<BaseMetricId> for MetricId {
fn from(base_metric_id: BaseMetricId) -> MetricId {
MetricId::Id(base_metric_id)
}
}
impl From<SubMetricId> for MetricGetter {
fn from(submetric_id: SubMetricId) -> MetricGetter {
MetricGetter::SubId(submetric_id)
impl From<SubMetricId> for MetricId {
fn from(submetric_id: SubMetricId) -> MetricId {
MetricId::SubId(submetric_id)
}
}
impl std::ops::Deref for MetricGetter {
impl std::ops::Deref for MetricId {
type Target = u32;
fn deref(&self) -> &Self::Target {
match self {
MetricGetter::Id(MetricId(m)) => m,
MetricGetter::SubId(SubMetricId(m)) => m,
MetricId::Id(BaseMetricId(m)) => m,
MetricId::SubId(SubMetricId(m)) => m,
}
}
}
@@ -71,9 +71,9 @@ impl std::ops::Deref for MetricGetter {
/// Uniquely identifies a single metric across all metric types.
#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, Deserialize, Serialize)]
#[repr(transparent)]
pub struct MetricId(pub(crate) u32);
pub struct BaseMetricId(pub(crate) u32);
impl MetricId {
impl BaseMetricId {
pub fn new(id: u32) -> Self {
Self(id)
}
@@ -84,7 +84,7 @@ impl MetricId {
}
#[cfg(feature = "with_gecko")]
impl MetricId {
impl BaseMetricId {
// Wraps the result of `lookup_canonical_metric_name` so that it's
// slightly easier for consumers to use. Also provides a slightly more
// abstracted interface, so that in future we can use other ways to get
@@ -120,13 +120,13 @@ impl MetricId {
}
}
impl From<u32> for MetricId {
impl From<u32> for BaseMetricId {
fn from(id: u32) -> Self {
Self(id)
}
}
impl std::ops::Deref for MetricId {
impl std::ops::Deref for BaseMetricId {
type Target = u32;
fn deref(&self) -> &Self::Target {
@@ -154,7 +154,7 @@ impl SubMetricId {
/// Given a submetric id, use the glean submetric maps to look up the
/// underlying metric id, and label. Note that this essentially performs
/// the reverse of `private::submetric_id_for`.
pub(crate) fn lookup_metric_id_and_label(&self) -> Option<(MetricId, String)> {
pub(crate) fn lookup_metric_id_and_label(&self) -> Option<(BaseMetricId, String)> {
let map = crate::metrics::__glean_metric_maps::submetric_maps::LABELED_METRICS_TO_IDS
.read()
.expect("read lock of submetric ids was poisoned");

View File

@@ -52,7 +52,7 @@ pub use self::labeled_custom_distribution::LabeledCustomDistributionMetric;
pub use self::labeled_memory_distribution::LabeledMemoryDistributionMetric;
pub use self::labeled_timing_distribution::LabeledTimingDistributionMetric;
pub use self::memory_distribution::{LocalMemoryDistribution, MemoryDistributionMetric};
pub use self::metric_getter::{MetricGetter, MetricId, SubMetricId};
pub use self::metric_getter::{BaseMetricId, MetricId, SubMetricId};
pub use self::numerator::NumeratorMetric;
pub use self::object::{ObjectMetric, RuntimeObject};
pub use self::ping::Ping;
@@ -175,19 +175,19 @@ pub(crate) mod profiler_utils {
#[derive(serde::Serialize, serde::Deserialize, Debug)]
pub(crate) struct StringLikeMetricMarker {
id: super::MetricGetter,
id: super::MetricId,
val: String,
}
impl StringLikeMetricMarker {
pub fn new(id: super::MetricGetter, val: &String) -> StringLikeMetricMarker {
pub fn new(id: super::MetricId, val: &String) -> StringLikeMetricMarker {
StringLikeMetricMarker {
id: id,
val: truncate_string_for_marker(val.clone()),
}
}
pub fn new_owned(id: super::MetricGetter, val: String) -> StringLikeMetricMarker {
pub fn new_owned(id: super::MetricId, val: String) -> StringLikeMetricMarker {
StringLikeMetricMarker {
id: id,
val: truncate_string_for_marker(val),
@@ -237,7 +237,7 @@ pub(crate) mod profiler_utils {
where
T: Into<i64>,
{
id: super::MetricGetter,
id: super::MetricId,
label: Option<String>,
val: T,
}
@@ -246,11 +246,7 @@ pub(crate) mod profiler_utils {
where
T: Into<i64>,
{
pub fn new(
id: super::MetricGetter,
label: Option<String>,
val: T,
) -> IntLikeMetricMarker<T> {
pub fn new(id: super::MetricId, label: Option<String>, val: T) -> IntLikeMetricMarker<T> {
IntLikeMetricMarker { id, label, val }
}
}
@@ -312,14 +308,14 @@ pub(crate) mod profiler_utils {
#[derive(serde::Serialize, serde::Deserialize, Debug)]
pub(crate) struct DistributionMetricMarker<T> {
id: super::MetricGetter,
id: super::MetricId,
label: Option<String>,
value: DistributionValues<T>,
}
impl<T> DistributionMetricMarker<T> {
pub fn new(
id: super::MetricGetter,
id: super::MetricId,
label: Option<String>,
value: DistributionValues<T>,
) -> DistributionMetricMarker<T> {
@@ -389,17 +385,13 @@ pub(crate) mod profiler_utils {
#[derive(serde::Serialize, serde::Deserialize, Debug)]
pub(crate) struct BooleanMetricMarker {
id: super::MetricGetter,
id: super::MetricId,
label: Option<String>,
val: bool,
}
impl BooleanMetricMarker {
pub fn new(
id: super::MetricGetter,
label: Option<String>,
val: bool,
) -> BooleanMetricMarker {
pub fn new(id: super::MetricId, label: Option<String>, val: bool) -> BooleanMetricMarker {
BooleanMetricMarker { id, label, val }
}
}

View File

@@ -10,7 +10,7 @@ use glean::traits::Numerator;
use glean::Rate;
use crate::ipc::{need_ipc, with_ipc_payload};
use crate::private::MetricId;
use crate::private::BaseMetricId;
/// Developer-facing API for recording rate metrics with external denominators.
///
@@ -21,20 +21,20 @@ use crate::private::MetricId;
pub enum NumeratorMetric {
Parent {
/// The metric's ID. Used for testing and profiler markers. Numerator
/// metrics canot be labeled, so we only store a MetricId. If this
/// changes, this should be changed to a MetricGetter to distinguish
/// metrics canot be labeled, so we only store a BaseMetricId. If this
/// changes, this should be changed to a MetricId to distinguish
/// between metrics and sub-metrics.
id: MetricId,
id: BaseMetricId,
inner: glean::private::NumeratorMetric,
},
Child(NumeratorMetricIpc),
}
#[derive(Clone, Debug)]
pub struct NumeratorMetricIpc(MetricId);
pub struct NumeratorMetricIpc(BaseMetricId);
impl NumeratorMetric {
/// The public constructor used by automatically generated metrics.
pub fn new(id: MetricId, meta: CommonMetricData) -> Self {
pub fn new(id: BaseMetricId, meta: CommonMetricData) -> Self {
if need_ipc() {
NumeratorMetric::Child(NumeratorMetricIpc(id))
} else {
@@ -44,7 +44,7 @@ impl NumeratorMetric {
}
#[cfg(test)]
pub(crate) fn metric_id(&self) -> MetricId {
pub(crate) fn metric_id(&self) -> BaseMetricId {
match self {
NumeratorMetric::Parent { id, .. } => *id,
NumeratorMetric::Child(c) => c.0,

View File

@@ -2,7 +2,7 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
use super::{CommonMetricData, MetricId};
use super::{BaseMetricId, CommonMetricData};
use crate::ipc::need_ipc;
@@ -14,7 +14,7 @@ use super::profiler_utils::{truncate_string_for_marker, TelemetryProfilerCategor
#[cfg(feature = "with_gecko")]
#[derive(serde::Serialize, serde::Deserialize, Debug)]
struct ObjectMetricMarker {
id: MetricId,
id: BaseMetricId,
value: String,
}
@@ -70,10 +70,10 @@ impl ObjectSerialize for RuntimeObject {
pub enum ObjectMetric<K> {
Parent {
/// The metric's ID. Used for testing and profiler markers. Object
/// metrics canot be labeled, so we only store a MetricId. If this
/// changes, this should be changed to a MetricGetter to distinguish
/// metrics canot be labeled, so we only store a BaseMetricId. If this
/// changes, this should be changed to a MetricId to distinguish
/// between metrics and sub-metrics.
id: MetricId,
id: BaseMetricId,
inner: glean::private::ObjectMetric<K>,
},
Child,
@@ -81,7 +81,7 @@ pub enum ObjectMetric<K> {
impl<K: ObjectSerialize + Clone> ObjectMetric<K> {
/// Create a new object metric.
pub fn new(id: MetricId, meta: CommonMetricData) -> Self {
pub fn new(id: BaseMetricId, meta: CommonMetricData) -> Self {
if need_ipc() {
ObjectMetric::Child
} else {

View File

@@ -9,7 +9,7 @@ use glean::traits::Quantity;
use super::CommonMetricData;
use super::{MetricGetter, MetricId};
use super::{BaseMetricId, MetricId};
use crate::ipc::need_ipc;
/// A quantity metric.
@@ -21,7 +21,7 @@ pub enum QuantityMetric {
/// The metric's ID. Used for testing and profiler markers. Quantity
/// metrics can be labeled, so we may have either a metric ID or
/// sub-metric ID.
id: MetricGetter,
id: MetricId,
inner: Arc<glean::private::QuantityMetric>,
},
Child(QuantityMetricIpc),
@@ -31,7 +31,7 @@ pub struct QuantityMetricIpc;
impl QuantityMetric {
/// Create a new quantity metric.
pub fn new(id: MetricId, meta: CommonMetricData) -> Self {
pub fn new(id: BaseMetricId, meta: CommonMetricData) -> Self {
if need_ipc() {
QuantityMetric::Child(QuantityMetricIpc)
} else {

View File

@@ -9,7 +9,7 @@ use super::CommonMetricData;
use glean::traits::Rate;
use crate::ipc::{need_ipc, with_ipc_payload};
use crate::private::MetricId;
use crate::private::BaseMetricId;
/// Developer-facing API for recording rate metrics.
///
@@ -20,20 +20,20 @@ use crate::private::MetricId;
pub enum RateMetric {
Parent {
/// The metric's ID. Used for testing and profiler markers. Rate
/// metrics canot be labeled, so we only store a MetricId. If this
/// changes, this should be changed to a MetricGetter to distinguish
/// metrics canot be labeled, so we only store a BaseMetricId. If this
/// changes, this should be changed to a MetricId to distinguish
/// between metrics and sub-metrics.
id: MetricId,
id: BaseMetricId,
inner: glean::private::RateMetric,
},
Child(RateMetricIpc),
}
#[derive(Clone, Debug)]
pub struct RateMetricIpc(MetricId);
pub struct RateMetricIpc(BaseMetricId);
impl RateMetric {
/// The public constructor used by automatically generated metrics.
pub fn new(id: MetricId, meta: CommonMetricData) -> Self {
pub fn new(id: BaseMetricId, meta: CommonMetricData) -> Self {
if need_ipc() {
RateMetric::Child(RateMetricIpc(id))
} else {
@@ -43,7 +43,7 @@ impl RateMetric {
}
#[cfg(test)]
pub(crate) fn metric_id(&self) -> MetricId {
pub(crate) fn metric_id(&self) -> BaseMetricId {
match self {
RateMetric::Parent { id, .. } => *id,
RateMetric::Child(c) => c.0,

View File

@@ -5,7 +5,7 @@
use inherent::inherent;
use std::sync::Arc;
use super::{CommonMetricData, MetricGetter, MetricId};
use super::{BaseMetricId, CommonMetricData, MetricId};
use crate::ipc::need_ipc;
/// A string metric.
@@ -43,7 +43,7 @@ pub enum StringMetric {
/// The metric's ID. Used for testing and profiler markers. String
/// metrics can be labeled, so we may have either a metric ID or
/// sub-metric ID.
id: MetricGetter,
id: MetricId,
inner: Arc<glean::private::StringMetric>,
},
Child(StringMetricIpc),
@@ -53,7 +53,7 @@ pub struct StringMetricIpc;
impl StringMetric {
/// Create a new string metric.
pub fn new(id: MetricId, meta: CommonMetricData) -> Self {
pub fn new(id: BaseMetricId, meta: CommonMetricData) -> Self {
if need_ipc() {
StringMetric::Child(StringMetricIpc)
} else {

View File

@@ -4,7 +4,7 @@
use inherent::inherent;
use super::{CommonMetricData, MetricId};
use super::{BaseMetricId, CommonMetricData};
use glean::traits::StringList;
@@ -17,20 +17,20 @@ use crate::ipc::{need_ipc, with_ipc_payload};
pub enum StringListMetric {
Parent {
/// The metric's ID. Used for testing and profiler markers. String
/// list metrics canot be labeled, so we only store a MetricId. If
/// this changes, this should be changed to a MetricGetter to
/// list metrics canot be labeled, so we only store a BaseMetricId. If
/// this changes, this should be changed to a MetricId to
/// distinguish between metrics and sub-metrics.
id: MetricId,
id: BaseMetricId,
inner: glean::private::StringListMetric,
},
Child(StringListMetricIpc),
}
#[derive(Clone, Debug)]
pub struct StringListMetricIpc(MetricId);
pub struct StringListMetricIpc(BaseMetricId);
impl StringListMetric {
/// Create a new string list metric.
pub fn new(id: MetricId, meta: CommonMetricData) -> Self {
pub fn new(id: BaseMetricId, meta: CommonMetricData) -> Self {
if need_ipc() {
StringListMetric::Child(StringListMetricIpc(id))
} else {

View File

@@ -5,7 +5,7 @@
use inherent::inherent;
use std::sync::Arc;
use super::{CommonMetricData, MetricId};
use super::{BaseMetricId, CommonMetricData};
use crate::ipc::need_ipc;
/// A text metric.
@@ -41,10 +41,10 @@ use crate::ipc::need_ipc;
pub enum TextMetric {
Parent {
/// The metric's ID. Used for testing and profiler markers. Text
/// metrics canot be labeled, so we only store a MetricId. If this
/// changes, this should be changed to a MetricGetter to distinguish
/// metrics canot be labeled, so we only store a BaseMetricId. If this
/// changes, this should be changed to a MetricId to distinguish
/// between metrics and sub-metrics.
id: MetricId,
id: BaseMetricId,
inner: Arc<glean::private::TextMetric>,
},
Child(TextMetricIpc),
@@ -55,7 +55,7 @@ pub struct TextMetricIpc;
impl TextMetric {
/// Create a new text metric.
pub fn new(id: MetricId, meta: CommonMetricData) -> Self {
pub fn new(id: BaseMetricId, meta: CommonMetricData) -> Self {
if need_ipc() {
TextMetric::Child(TextMetricIpc)
} else {

View File

@@ -4,7 +4,7 @@
use inherent::inherent;
use super::{CommonMetricData, MetricId, TimeUnit};
use super::{BaseMetricId, CommonMetricData, TimeUnit};
use std::convert::TryInto;
use std::time::Duration;
@@ -18,7 +18,7 @@ use super::profiler_utils::TelemetryProfilerCategory;
#[cfg(feature = "with_gecko")]
#[derive(serde::Serialize, serde::Deserialize, Debug)]
struct TimespanMetricMarker {
id: MetricId,
id: BaseMetricId,
value: Option<u64>,
}
@@ -76,10 +76,10 @@ impl gecko_profiler::ProfilerMarker for TimespanMetricMarker {
pub enum TimespanMetric {
Parent {
/// The metric's ID. Used for testing and profiler markers. Time span
/// metrics canot be labeled, so we only store a MetricId. If this
/// changes, this should be changed to a MetricGetter to distinguish
/// metrics canot be labeled, so we only store a BaseMetricId. If this
/// changes, this should be changed to a MetricId to distinguish
/// between metrics and sub-metrics.
id: MetricId,
id: BaseMetricId,
inner: glean::private::TimespanMetric,
time_unit: TimeUnit,
},
@@ -88,7 +88,7 @@ pub enum TimespanMetric {
impl TimespanMetric {
/// Create a new timespan metric.
pub fn new(id: MetricId, meta: CommonMetricData, time_unit: TimeUnit) -> Self {
pub fn new(id: BaseMetricId, meta: CommonMetricData, time_unit: TimeUnit) -> Self {
if need_ipc() {
TimespanMetric::Child
} else {
@@ -298,7 +298,7 @@ impl Timespan for TimespanMetric {
#[cfg(test)]
mod test {
use super::*;
use crate::private::MetricId;
use crate::private::BaseMetricId;
use crate::{common_test::*, ipc, metrics};
#[test]
@@ -306,7 +306,7 @@ mod test {
let _lock = lock_test();
let metric = TimespanMetric::new(
MetricId(0),
BaseMetricId(0),
CommonMetricData {
name: "timespan_metric".into(),
category: "telemetry".into(),

View File

@@ -13,7 +13,7 @@ use std::time::{Duration, Instant};
#[cfg(feature = "with_gecko")]
use thin_vec::ThinVec;
use super::{CommonMetricData, MetricGetter, MetricId, TimeUnit};
use super::{BaseMetricId, CommonMetricData, MetricId, TimeUnit};
use glean::{DistributionData, ErrorType, TimerId};
use crate::ipc::{need_ipc, with_ipc_payload};
@@ -44,7 +44,7 @@ impl TDMPayload {
#[cfg(feature = "with_gecko")]
#[derive(serde::Serialize, serde::Deserialize, Debug)]
pub(crate) struct TimingDistributionMetricMarker {
id: MetricGetter,
id: MetricId,
label: Option<String>,
timer_id: Option<u64>,
value: Option<TDMPayload>,
@@ -53,7 +53,7 @@ pub(crate) struct TimingDistributionMetricMarker {
#[cfg(feature = "with_gecko")]
impl TimingDistributionMetricMarker {
pub fn new(
id: MetricGetter,
id: MetricId,
label: Option<String>,
timer_id: Option<u64>,
value: Option<TDMPayload>,
@@ -168,7 +168,7 @@ pub enum TimingDistributionMetric {
/// The metric's ID. Used for testing, GIFFT, and profiler markers.
/// Timing distribution metrics can be labeled, so we may have either
/// a metric ID or sub-metric ID.
id: MetricGetter,
id: MetricId,
gifft_time_unit: TimeUnit,
inner: Arc<glean::private::TimingDistributionMetric>,
},
@@ -176,7 +176,7 @@ pub enum TimingDistributionMetric {
}
#[derive(Debug)]
pub struct TimingDistributionMetricIpc {
metric_id: MetricId,
metric_id: BaseMetricId,
#[allow(unused)]
gifft_time_unit: TimeUnit,
next_timer_id: AtomicUsize,
@@ -185,7 +185,7 @@ pub struct TimingDistributionMetricIpc {
impl TimingDistributionMetric {
/// Create a new timing distribution metric, _child process only_.
pub(crate) fn new_child(id: MetricId, time_unit: TimeUnit) -> Self {
pub(crate) fn new_child(id: BaseMetricId, time_unit: TimeUnit) -> Self {
debug_assert!(need_ipc());
TimingDistributionMetric::Child(TimingDistributionMetricIpc {
metric_id: id,
@@ -196,7 +196,7 @@ impl TimingDistributionMetric {
}
/// Create a new timing distribution metric.
pub fn new(id: MetricId, meta: CommonMetricData, time_unit: TimeUnit) -> Self {
pub fn new(id: BaseMetricId, meta: CommonMetricData, time_unit: TimeUnit) -> Self {
if need_ipc() {
Self::new_child(id, time_unit)
} else {
@@ -221,7 +221,7 @@ impl TimingDistributionMetric {
// the context of a test. If this code is used elsewhere,
// the `unwrap` should be replaced with proper error
// handling of the `None` case.
metric_id: (*id).metric_id().unwrap(),
metric_id: (*id).base_metric_id().unwrap(),
gifft_time_unit: *gifft_time_unit,
next_timer_id: AtomicUsize::new(0),
instants: RwLock::new(HashMap::new()),
@@ -358,7 +358,7 @@ impl TimingDistributionMetric {
match self {
#[allow(unused)]
TimingDistributionMetric::Parent {
id: id @ MetricGetter::Id(_),
id: id @ MetricId::Id(_),
inner,
..
} => {
@@ -392,7 +392,7 @@ impl TimingDistributionMetric {
match self {
#[allow(unused)]
TimingDistributionMetric::Parent {
id: id @ MetricGetter::Id(_),
id: id @ MetricId::Id(_),
inner,
..
} => {
@@ -438,9 +438,9 @@ impl TimingDistribution for TimingDistributionMetric {
let timer_id = self.inner_start();
#[cfg(feature = "with_gecko")]
{
let metric_id: MetricId = match self {
let metric_id: BaseMetricId = match self {
TimingDistributionMetric::Parent { id, .. } => id
.metric_id()
.base_metric_id()
.expect("Cannot perform GIFFT calls without a metric id."),
TimingDistributionMetric::Child(c) => c.metric_id,
};
@@ -499,7 +499,7 @@ impl TimingDistribution for TimingDistributionMetric {
gifft_time_unit,
..
} => (
id.metric_id()
id.base_metric_id()
.expect("Cannot perform GIFFT calls without a metric id."),
gifft_time_unit,
),
@@ -544,9 +544,9 @@ impl TimingDistribution for TimingDistributionMetric {
self.inner_cancel(id);
#[cfg(feature = "with_gecko")]
{
let metric_id: MetricId = match self {
let metric_id: BaseMetricId = match self {
TimingDistributionMetric::Parent { id, .. } => id
.metric_id()
.base_metric_id()
.expect("Cannot perform GIFFT calls without a metric id."),
TimingDistributionMetric::Child(c) => c.metric_id,
};
@@ -607,7 +607,7 @@ impl TimingDistribution for TimingDistributionMetric {
.collect();
let metric_id = match self {
TimingDistributionMetric::Parent { id, .. } => id
.metric_id()
.base_metric_id()
.expect("Cannot perform GIFFT calls without a metric id."),
TimingDistributionMetric::Child(c) => c.metric_id,
};
@@ -639,7 +639,7 @@ impl TimingDistribution for TimingDistributionMetric {
match self {
#[allow(unused)]
TimingDistributionMetric::Parent {
id: id @ MetricGetter::Id(_),
id: id @ MetricId::Id(_),
inner,
..
} => {
@@ -674,7 +674,7 @@ impl TimingDistribution for TimingDistributionMetric {
{
let metric_id = match self {
TimingDistributionMetric::Parent { id, .. } => id
.metric_id()
.base_metric_id()
.expect("Cannot perform GIFFT calls without a metric id."),
TimingDistributionMetric::Child(c) => c.metric_id,
};
@@ -716,7 +716,7 @@ impl TimingDistribution for TimingDistributionMetric {
gifft_time_unit,
..
} => (
id.metric_id()
id.base_metric_id()
.expect("Cannot perform GIFFT calls without a metric id."),
gifft_time_unit,
),

View File

@@ -4,7 +4,7 @@
use inherent::inherent;
use super::{CommonMetricData, MetricId};
use super::{BaseMetricId, CommonMetricData};
use crate::ipc::need_ipc;
@@ -14,7 +14,7 @@ use super::profiler_utils::{truncate_string_for_marker, TelemetryProfilerCategor
#[cfg(feature = "with_gecko")]
#[derive(serde::Serialize, serde::Deserialize, Debug)]
struct UrlMetricMarker {
id: MetricId,
id: BaseMetricId,
val: String,
}
@@ -55,10 +55,10 @@ impl gecko_profiler::ProfilerMarker for UrlMetricMarker {
pub enum UrlMetric {
Parent {
/// The metric's ID. Used for testing and profiler markers. URL
/// metrics canot be labeled, so we only store a MetricId. If this
/// changes, this should be changed to a MetricGetter to distinguish
/// metrics canot be labeled, so we only store a BaseMetricId. If this
/// changes, this should be changed to a MetricId to distinguish
/// between metrics and sub-metrics.
id: MetricId,
id: BaseMetricId,
inner: glean::private::UrlMetric,
},
Child(UrlMetricIpc),
@@ -68,7 +68,7 @@ pub struct UrlMetricIpc;
impl UrlMetric {
/// Create a new Url metric.
pub fn new(id: MetricId, meta: CommonMetricData) -> Self {
pub fn new(id: BaseMetricId, meta: CommonMetricData) -> Self {
if need_ipc() {
UrlMetric::Child(UrlMetricIpc)
} else {

View File

@@ -6,7 +6,7 @@ use inherent::inherent;
use uuid::Uuid;
use super::{CommonMetricData, MetricId};
use super::{BaseMetricId, CommonMetricData};
use crate::ipc::need_ipc;
@@ -16,10 +16,10 @@ use crate::ipc::need_ipc;
pub enum UuidMetric {
Parent {
/// The metric's ID. Used for testing and profiler markers. UUID
/// metrics canot be labeled, so we only store a MetricId. If this
/// changes, this should be changed to a MetricGetter to distinguish
/// metrics canot be labeled, so we only store a BaseMetricId. If this
/// changes, this should be changed to a MetricId to distinguish
/// between metrics and sub-metrics.
id: MetricId,
id: BaseMetricId,
inner: glean::private::UuidMetric,
},
Child(UuidMetricIpc),
@@ -30,7 +30,7 @@ pub struct UuidMetricIpc;
impl UuidMetric {
/// Create a new UUID metric.
pub fn new(id: MetricId, meta: CommonMetricData) -> Self {
pub fn new(id: BaseMetricId, meta: CommonMetricData) -> Self {
if need_ipc() {
UuidMetric::Child(UuidMetricIpc)
} else {

View File

@@ -23,7 +23,7 @@ CommonMetricData {
{%- endmacro -%}
{% macro metric_ctor(metric_type_name, metric_type, ctor='new') %}
{{ metric_type_name|Camelize if not metric_type_name.startswith('labeled_') else "Labeled"}}Metric::{% if metric_type_name == 'event' %}with_runtime_extra_keys{% else %}{{ ctor }}{% endif %}(MetricId(metric_id), meta
{{ metric_type_name|Camelize if not metric_type_name.startswith('labeled_') else "Labeled"}}Metric::{% if metric_type_name == 'event' %}with_runtime_extra_keys{% else %}{{ ctor }}{% endif %}(BaseMetricId(metric_id), meta
{%- for arg_name in metric_type.args if not metric_type_name.startswith('labeled_') and arg_name not in common_metric_data_args -%}
, {{ arg_name }}.unwrap()
{%- endfor -%}
@@ -43,7 +43,7 @@ use crate::private::{
TimeUnit,
Ping,
LabeledMetric,
MetricId,
BaseMetricId,
{% for metric_type_name in metric_types.keys() if not metric_type_name.startswith('labeled_') %}
{{ metric_type_name|Camelize }}Metric,
{% endfor %}};
@@ -74,7 +74,7 @@ pub fn id_and_map_reset() {
pub(crate) mod __jog_metric_maps {
use crate::metrics::DynamicLabel;
use crate::private::MetricId;
use crate::private::BaseMetricId;
use crate::private::{
Ping,
LabeledMetric,
@@ -89,13 +89,13 @@ pub(crate) mod __jog_metric_maps {
use std::sync::{Arc, RwLock};
{% for metric_type_name in metric_types.keys() if metric_type_name != "event" and not metric_type_name.startswith('labeled_') and metric_type_name != "object" %}
pub static {{ metric_type_name.upper() }}_MAP: Lazy<Arc<RwLock<HashMap<MetricId, {{ metric_type_name|Camelize }}Metric>>>> =
pub static {{ metric_type_name.upper() }}_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, {{ metric_type_name|Camelize }}Metric>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
{% endfor %}
{# Labeled metrics are special because they're LabeledMetric<Labeled{Counter|Boolean|...}Metric> #}
{% for metric_type_name in metric_types.keys() if metric_type_name.startswith('labeled_') %}
pub static {{ metric_type_name.upper() }}_MAP: Lazy<Arc<RwLock<HashMap<MetricId, LabeledMetric<{{ metric_type_name|Camelize }}Metric, DynamicLabel>>>>> =
pub static {{ metric_type_name.upper() }}_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, LabeledMetric<{{ metric_type_name|Camelize }}Metric, DynamicLabel>>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
{% endfor %}
@@ -103,10 +103,11 @@ pub(crate) mod __jog_metric_maps {
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
{# Event metrics are special because they're EventMetric<K> #}
pub static EVENT_MAP: Lazy<Arc<RwLock<HashMap<MetricId, EventMetric<NoExtraKeys>>>>> =
pub static EVENT_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, EventMetric<NoExtraKeys>>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
{# Object metrics are special because they're ObjectMetric<K> #}
pub static OBJECT_MAP: Lazy<Arc<RwLock<HashMap<MetricId, ObjectMetric<RuntimeObject>>>>> =
#[allow(dead_code)]
pub static OBJECT_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, ObjectMetric<RuntimeObject>>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
}
@@ -187,7 +188,7 @@ map of argument name to argument type. I may regret this if I need it again. #}
{% endif %}
let metric32: u32 = ({{metric_type.id}} << {{ID_BITS}}) | metric_id;
assert!(
__jog_metric_maps::{{metric_type_name.upper()}}_MAP.write()?.insert(MetricId(metric_id), metric).is_none(),
__jog_metric_maps::{{metric_type_name.upper()}}_MAP.write()?.insert(BaseMetricId(metric_id), metric).is_none(),
"We should never insert a runtime metric with an already-used id."
);
metric32

View File

@@ -188,7 +188,7 @@ pub mod {{ category_name|snake_case }} {
{% else %}
{{ common_metric_data(obj)|indent(12) }};
{% endif %}
{{ obj|ctor }}(MetricId({{obj|metric_id}}), meta
{{ obj|ctor }}(BaseMetricId({{obj|metric_id}}), meta
{%- for arg_name in extra_args if not obj.labeled and obj[arg_name] is defined and arg_name not in common_metric_data_args and arg_name != 'allowed_extra_keys' -%}
, {{ obj[arg_name]|rust }}
{%- endfor -%}
@@ -218,10 +218,10 @@ pub(crate) mod __glean_metric_maps {
use once_cell::sync::Lazy;
{% for typ, metrics in metric_by_type.items() %}
pub static {{typ.0}}: Lazy<HashMap<MetricId, &Lazy<{{typ.1}}>>> = Lazy::new(|| {
pub static {{typ.0}}: Lazy<HashMap<BaseMetricId, &Lazy<{{typ.1}}>>> = Lazy::new(|| {
let mut map = HashMap::with_capacity({{metrics|length}});
{% for metric in metrics %}
map.insert(MetricId({{metric.0}}), &super::{{metric.1}});
map.insert(BaseMetricId({{metric.0}}), &super::{{metric.1}});
{% endfor %}
map
});
@@ -331,10 +331,10 @@ pub(crate) mod __glean_metric_maps {
/// or an `EventRecordingError::InvalidId` if no event by that ID exists
/// or an `EventRecordingError::InvalidExtraKey` if the event doesn't take extra pairs,
/// but some are passed in.
pub(crate) fn record_event_by_id_with_time(metric_id: MetricId, timestamp: u64, extra: HashMap<String, String>) -> Result<(), EventRecordingError> {
pub(crate) fn record_event_by_id_with_time(metric_id: BaseMetricId, timestamp: u64, extra: HashMap<String, String>) -> Result<(), EventRecordingError> {
match metric_id {
{% for metric_id, event in events_by_id.items() %}
MetricId({{metric_id}}) => {
BaseMetricId({{metric_id}}) => {
if extra_keys_len(&super::{{event}}) == 0 && !extra.is_empty() {
return Err(EventRecordingError::InvalidExtraKey);
}
@@ -464,7 +464,7 @@ pub(crate) mod __glean_metric_maps {
pub(crate) const SUBMETRIC_BIT: u32 = {{submetric_bit}};
pub(crate) static NEXT_LABELED_SUBMETRIC_ID: AtomicU32 = AtomicU32::new((1 << SUBMETRIC_BIT) + 1);
pub(crate) static LABELED_METRICS_TO_IDS: Lazy<RwLock<HashMap<(MetricId, String), SubMetricId>>> = Lazy::new(||
pub(crate) static LABELED_METRICS_TO_IDS: Lazy<RwLock<HashMap<(BaseMetricId, String), SubMetricId>>> = Lazy::new(||
RwLock::new(HashMap::new())
);
pub(crate) static LABELED_ENUMS_TO_IDS: Lazy<RwLock<HashMap<(u32, u16), u32>>> = Lazy::new(||

View File

@@ -21,7 +21,7 @@ use crate::private::{
TimeUnit,
Ping,
LabeledMetric,
MetricId,
BaseMetricId,
BooleanMetric,
CounterMetric,
CustomDistributionMetric,
@@ -84,7 +84,7 @@ pub fn id_and_map_reset() {
pub(crate) mod __jog_metric_maps {
use crate::metrics::DynamicLabel;
use crate::private::MetricId;
use crate::private::BaseMetricId;
use crate::private::{
Ping,
LabeledMetric,
@@ -115,66 +115,67 @@ pub(crate) mod __jog_metric_maps {
use std::collections::HashMap;
use std::sync::{Arc, RwLock};
pub static BOOLEAN_MAP: Lazy<Arc<RwLock<HashMap<MetricId, BooleanMetric>>>> =
pub static BOOLEAN_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, BooleanMetric>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
pub static COUNTER_MAP: Lazy<Arc<RwLock<HashMap<MetricId, CounterMetric>>>> =
pub static COUNTER_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, CounterMetric>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
pub static CUSTOM_DISTRIBUTION_MAP: Lazy<Arc<RwLock<HashMap<MetricId, CustomDistributionMetric>>>> =
pub static CUSTOM_DISTRIBUTION_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, CustomDistributionMetric>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
pub static DATETIME_MAP: Lazy<Arc<RwLock<HashMap<MetricId, DatetimeMetric>>>> =
pub static DATETIME_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, DatetimeMetric>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
pub static DENOMINATOR_MAP: Lazy<Arc<RwLock<HashMap<MetricId, DenominatorMetric>>>> =
pub static DENOMINATOR_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, DenominatorMetric>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
pub static MEMORY_DISTRIBUTION_MAP: Lazy<Arc<RwLock<HashMap<MetricId, MemoryDistributionMetric>>>> =
pub static MEMORY_DISTRIBUTION_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, MemoryDistributionMetric>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
pub static NUMERATOR_MAP: Lazy<Arc<RwLock<HashMap<MetricId, NumeratorMetric>>>> =
pub static NUMERATOR_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, NumeratorMetric>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
pub static QUANTITY_MAP: Lazy<Arc<RwLock<HashMap<MetricId, QuantityMetric>>>> =
pub static QUANTITY_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, QuantityMetric>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
pub static RATE_MAP: Lazy<Arc<RwLock<HashMap<MetricId, RateMetric>>>> =
pub static RATE_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, RateMetric>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
pub static STRING_MAP: Lazy<Arc<RwLock<HashMap<MetricId, StringMetric>>>> =
pub static STRING_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, StringMetric>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
pub static STRING_LIST_MAP: Lazy<Arc<RwLock<HashMap<MetricId, StringListMetric>>>> =
pub static STRING_LIST_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, StringListMetric>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
pub static TEXT_MAP: Lazy<Arc<RwLock<HashMap<MetricId, TextMetric>>>> =
pub static TEXT_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, TextMetric>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
pub static TIMESPAN_MAP: Lazy<Arc<RwLock<HashMap<MetricId, TimespanMetric>>>> =
pub static TIMESPAN_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, TimespanMetric>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
pub static TIMING_DISTRIBUTION_MAP: Lazy<Arc<RwLock<HashMap<MetricId, TimingDistributionMetric>>>> =
pub static TIMING_DISTRIBUTION_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, TimingDistributionMetric>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
pub static UUID_MAP: Lazy<Arc<RwLock<HashMap<MetricId, UuidMetric>>>> =
pub static UUID_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, UuidMetric>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
pub static LABELED_BOOLEAN_MAP: Lazy<Arc<RwLock<HashMap<MetricId, LabeledMetric<LabeledBooleanMetric, DynamicLabel>>>>> =
pub static LABELED_BOOLEAN_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, LabeledMetric<LabeledBooleanMetric, DynamicLabel>>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
pub static LABELED_COUNTER_MAP: Lazy<Arc<RwLock<HashMap<MetricId, LabeledMetric<LabeledCounterMetric, DynamicLabel>>>>> =
pub static LABELED_COUNTER_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, LabeledMetric<LabeledCounterMetric, DynamicLabel>>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
pub static LABELED_STRING_MAP: Lazy<Arc<RwLock<HashMap<MetricId, LabeledMetric<LabeledStringMetric, DynamicLabel>>>>> =
pub static LABELED_STRING_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, LabeledMetric<LabeledStringMetric, DynamicLabel>>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
pub static PING_MAP: Lazy<Arc<RwLock<HashMap<u32, Ping>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
pub static EVENT_MAP: Lazy<Arc<RwLock<HashMap<MetricId, EventMetric<NoExtraKeys>>>>> =
pub static EVENT_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, EventMetric<NoExtraKeys>>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
pub static OBJECT_MAP: Lazy<Arc<RwLock<HashMap<MetricId, ObjectMetric<RuntimeObject>>>>> =
#[allow(dead_code)]
pub static OBJECT_MAP: Lazy<Arc<RwLock<HashMap<BaseMetricId, ObjectMetric<RuntimeObject>>>>> =
Lazy::new(|| Arc::new(RwLock::new(HashMap::new())));
}
@@ -218,13 +219,13 @@ pub fn create_and_register_metric(
..Default::default()
};
let metric = if permit_non_commutative_operations_over_ipc.unwrap_or(false) {
BooleanMetric::with_unordered_ipc(MetricId(metric_id), meta)
BooleanMetric::with_unordered_ipc(BaseMetricId(metric_id), meta)
} else {
BooleanMetric::new(MetricId(metric_id), meta)
BooleanMetric::new(BaseMetricId(metric_id), meta)
};
let metric32: u32 = (1 << 27) | metric_id;
assert!(
__jog_metric_maps::BOOLEAN_MAP.write()?.insert(MetricId(metric_id), metric).is_none(),
__jog_metric_maps::BOOLEAN_MAP.write()?.insert(BaseMetricId(metric_id), metric).is_none(),
"We should never insert a runtime metric with an already-used id."
);
metric32
@@ -238,10 +239,10 @@ pub fn create_and_register_metric(
disabled,
..Default::default()
};
let metric = CounterMetric::new(MetricId(metric_id), meta);
let metric = CounterMetric::new(BaseMetricId(metric_id), meta);
let metric32: u32 = (2 << 27) | metric_id;
assert!(
__jog_metric_maps::COUNTER_MAP.write()?.insert(MetricId(metric_id), metric).is_none(),
__jog_metric_maps::COUNTER_MAP.write()?.insert(BaseMetricId(metric_id), metric).is_none(),
"We should never insert a runtime metric with an already-used id."
);
metric32
@@ -255,10 +256,10 @@ pub fn create_and_register_metric(
disabled,
..Default::default()
};
let metric = CustomDistributionMetric::new(MetricId(metric_id), meta, range_min.unwrap(), range_max.unwrap(), bucket_count.unwrap(), histogram_type.unwrap());
let metric = CustomDistributionMetric::new(BaseMetricId(metric_id), meta, range_min.unwrap(), range_max.unwrap(), bucket_count.unwrap(), histogram_type.unwrap());
let metric32: u32 = (3 << 27) | metric_id;
assert!(
__jog_metric_maps::CUSTOM_DISTRIBUTION_MAP.write()?.insert(MetricId(metric_id), metric).is_none(),
__jog_metric_maps::CUSTOM_DISTRIBUTION_MAP.write()?.insert(BaseMetricId(metric_id), metric).is_none(),
"We should never insert a runtime metric with an already-used id."
);
metric32
@@ -272,10 +273,10 @@ pub fn create_and_register_metric(
disabled,
..Default::default()
};
let metric = DatetimeMetric::new(MetricId(metric_id), meta, time_unit.unwrap());
let metric = DatetimeMetric::new(BaseMetricId(metric_id), meta, time_unit.unwrap());
let metric32: u32 = (14 << 27) | metric_id;
assert!(
__jog_metric_maps::DATETIME_MAP.write()?.insert(MetricId(metric_id), metric).is_none(),
__jog_metric_maps::DATETIME_MAP.write()?.insert(BaseMetricId(metric_id), metric).is_none(),
"We should never insert a runtime metric with an already-used id."
);
metric32
@@ -289,10 +290,10 @@ pub fn create_and_register_metric(
disabled,
..Default::default()
};
let metric = DenominatorMetric::new(MetricId(metric_id), meta, numerators.unwrap());
let metric = DenominatorMetric::new(BaseMetricId(metric_id), meta, numerators.unwrap());
let metric32: u32 = (16 << 27) | metric_id;
assert!(
__jog_metric_maps::DENOMINATOR_MAP.write()?.insert(MetricId(metric_id), metric).is_none(),
__jog_metric_maps::DENOMINATOR_MAP.write()?.insert(BaseMetricId(metric_id), metric).is_none(),
"We should never insert a runtime metric with an already-used id."
);
metric32
@@ -306,10 +307,10 @@ pub fn create_and_register_metric(
disabled,
..Default::default()
};
let metric = EventMetric::with_runtime_extra_keys(MetricId(metric_id), meta, allowed_extra_keys.unwrap());
let metric = EventMetric::with_runtime_extra_keys(BaseMetricId(metric_id), meta, allowed_extra_keys.unwrap());
let metric32: u32 = (15 << 27) | metric_id;
assert!(
__jog_metric_maps::EVENT_MAP.write()?.insert(MetricId(metric_id), metric).is_none(),
__jog_metric_maps::EVENT_MAP.write()?.insert(BaseMetricId(metric_id), metric).is_none(),
"We should never insert a runtime metric with an already-used id."
);
metric32
@@ -325,13 +326,13 @@ pub fn create_and_register_metric(
..Default::default()
}
}; let metric = if permit_non_commutative_operations_over_ipc.unwrap_or(false) {
LabeledMetric::with_unordered_ipc(MetricId(metric_id), meta, labels)
LabeledMetric::with_unordered_ipc(BaseMetricId(metric_id), meta, labels)
} else {
LabeledMetric::new(MetricId(metric_id), meta, labels)
LabeledMetric::new(BaseMetricId(metric_id), meta, labels)
};
let metric32: u32 = (4 << 27) | metric_id;
assert!(
__jog_metric_maps::LABELED_BOOLEAN_MAP.write()?.insert(MetricId(metric_id), metric).is_none(),
__jog_metric_maps::LABELED_BOOLEAN_MAP.write()?.insert(BaseMetricId(metric_id), metric).is_none(),
"We should never insert a runtime metric with an already-used id."
);
metric32
@@ -346,10 +347,10 @@ pub fn create_and_register_metric(
disabled,
..Default::default()
}
}; let metric = LabeledMetric::new(MetricId(metric_id), meta, labels);
}; let metric = LabeledMetric::new(BaseMetricId(metric_id), meta, labels);
let metric32: u32 = (5 << 27) | metric_id;
assert!(
__jog_metric_maps::LABELED_COUNTER_MAP.write()?.insert(MetricId(metric_id), metric).is_none(),
__jog_metric_maps::LABELED_COUNTER_MAP.write()?.insert(BaseMetricId(metric_id), metric).is_none(),
"We should never insert a runtime metric with an already-used id."
);
metric32
@@ -364,10 +365,10 @@ pub fn create_and_register_metric(
disabled,
..Default::default()
}
}; let metric = LabeledMetric::new(MetricId(metric_id), meta, labels);
}; let metric = LabeledMetric::new(BaseMetricId(metric_id), meta, labels);
let metric32: u32 = (6 << 27) | metric_id;
assert!(
__jog_metric_maps::LABELED_STRING_MAP.write()?.insert(MetricId(metric_id), metric).is_none(),
__jog_metric_maps::LABELED_STRING_MAP.write()?.insert(BaseMetricId(metric_id), metric).is_none(),
"We should never insert a runtime metric with an already-used id."
);
metric32
@@ -381,10 +382,10 @@ pub fn create_and_register_metric(
disabled,
..Default::default()
};
let metric = MemoryDistributionMetric::new(MetricId(metric_id), meta, memory_unit.unwrap());
let metric = MemoryDistributionMetric::new(BaseMetricId(metric_id), meta, memory_unit.unwrap());
let metric32: u32 = (7 << 27) | metric_id;
assert!(
__jog_metric_maps::MEMORY_DISTRIBUTION_MAP.write()?.insert(MetricId(metric_id), metric).is_none(),
__jog_metric_maps::MEMORY_DISTRIBUTION_MAP.write()?.insert(BaseMetricId(metric_id), metric).is_none(),
"We should never insert a runtime metric with an already-used id."
);
metric32
@@ -398,10 +399,10 @@ pub fn create_and_register_metric(
disabled,
..Default::default()
};
let metric = NumeratorMetric::new(MetricId(metric_id), meta);
let metric = NumeratorMetric::new(BaseMetricId(metric_id), meta);
let metric32: u32 = (19 << 27) | metric_id;
assert!(
__jog_metric_maps::NUMERATOR_MAP.write()?.insert(MetricId(metric_id), metric).is_none(),
__jog_metric_maps::NUMERATOR_MAP.write()?.insert(BaseMetricId(metric_id), metric).is_none(),
"We should never insert a runtime metric with an already-used id."
);
metric32
@@ -415,10 +416,10 @@ pub fn create_and_register_metric(
disabled,
..Default::default()
};
let metric = ObjectMetric::new(MetricId(metric_id), meta);
let metric = ObjectMetric::new(BaseMetricId(metric_id), meta);
let metric32: u32 = (13 << 27) | metric_id;
assert!(
__jog_metric_maps::OBJECT_MAP.write()?.insert(MetricId(metric_id), metric).is_none(),
__jog_metric_maps::OBJECT_MAP.write()?.insert(BaseMetricId(metric_id), metric).is_none(),
"We should never insert a runtime metric with an already-used id."
);
metric32
@@ -432,10 +433,10 @@ pub fn create_and_register_metric(
disabled,
..Default::default()
};
let metric = QuantityMetric::new(MetricId(metric_id), meta);
let metric = QuantityMetric::new(BaseMetricId(metric_id), meta);
let metric32: u32 = (17 << 27) | metric_id;
assert!(
__jog_metric_maps::QUANTITY_MAP.write()?.insert(MetricId(metric_id), metric).is_none(),
__jog_metric_maps::QUANTITY_MAP.write()?.insert(BaseMetricId(metric_id), metric).is_none(),
"We should never insert a runtime metric with an already-used id."
);
metric32
@@ -449,10 +450,10 @@ pub fn create_and_register_metric(
disabled,
..Default::default()
};
let metric = RateMetric::new(MetricId(metric_id), meta);
let metric = RateMetric::new(BaseMetricId(metric_id), meta);
let metric32: u32 = (18 << 27) | metric_id;
assert!(
__jog_metric_maps::RATE_MAP.write()?.insert(MetricId(metric_id), metric).is_none(),
__jog_metric_maps::RATE_MAP.write()?.insert(BaseMetricId(metric_id), metric).is_none(),
"We should never insert a runtime metric with an already-used id."
);
metric32
@@ -466,10 +467,10 @@ pub fn create_and_register_metric(
disabled,
..Default::default()
};
let metric = StringMetric::new(MetricId(metric_id), meta);
let metric = StringMetric::new(BaseMetricId(metric_id), meta);
let metric32: u32 = (9 << 27) | metric_id;
assert!(
__jog_metric_maps::STRING_MAP.write()?.insert(MetricId(metric_id), metric).is_none(),
__jog_metric_maps::STRING_MAP.write()?.insert(BaseMetricId(metric_id), metric).is_none(),
"We should never insert a runtime metric with an already-used id."
);
metric32
@@ -483,10 +484,10 @@ pub fn create_and_register_metric(
disabled,
..Default::default()
};
let metric = StringListMetric::new(MetricId(metric_id), meta);
let metric = StringListMetric::new(BaseMetricId(metric_id), meta);
let metric32: u32 = (8 << 27) | metric_id;
assert!(
__jog_metric_maps::STRING_LIST_MAP.write()?.insert(MetricId(metric_id), metric).is_none(),
__jog_metric_maps::STRING_LIST_MAP.write()?.insert(BaseMetricId(metric_id), metric).is_none(),
"We should never insert a runtime metric with an already-used id."
);
metric32
@@ -500,10 +501,10 @@ pub fn create_and_register_metric(
disabled,
..Default::default()
};
let metric = TextMetric::new(MetricId(metric_id), meta);
let metric = TextMetric::new(BaseMetricId(metric_id), meta);
let metric32: u32 = (10 << 27) | metric_id;
assert!(
__jog_metric_maps::TEXT_MAP.write()?.insert(MetricId(metric_id), metric).is_none(),
__jog_metric_maps::TEXT_MAP.write()?.insert(BaseMetricId(metric_id), metric).is_none(),
"We should never insert a runtime metric with an already-used id."
);
metric32
@@ -517,10 +518,10 @@ pub fn create_and_register_metric(
disabled,
..Default::default()
};
let metric = TimespanMetric::new(MetricId(metric_id), meta, time_unit.unwrap());
let metric = TimespanMetric::new(BaseMetricId(metric_id), meta, time_unit.unwrap());
let metric32: u32 = (11 << 27) | metric_id;
assert!(
__jog_metric_maps::TIMESPAN_MAP.write()?.insert(MetricId(metric_id), metric).is_none(),
__jog_metric_maps::TIMESPAN_MAP.write()?.insert(BaseMetricId(metric_id), metric).is_none(),
"We should never insert a runtime metric with an already-used id."
);
metric32
@@ -534,10 +535,10 @@ pub fn create_and_register_metric(
disabled,
..Default::default()
};
let metric = TimingDistributionMetric::new(MetricId(metric_id), meta, time_unit.unwrap());
let metric = TimingDistributionMetric::new(BaseMetricId(metric_id), meta, time_unit.unwrap());
let metric32: u32 = (12 << 27) | metric_id;
assert!(
__jog_metric_maps::TIMING_DISTRIBUTION_MAP.write()?.insert(MetricId(metric_id), metric).is_none(),
__jog_metric_maps::TIMING_DISTRIBUTION_MAP.write()?.insert(BaseMetricId(metric_id), metric).is_none(),
"We should never insert a runtime metric with an already-used id."
);
metric32
@@ -551,10 +552,10 @@ pub fn create_and_register_metric(
disabled,
..Default::default()
};
let metric = UuidMetric::new(MetricId(metric_id), meta);
let metric = UuidMetric::new(BaseMetricId(metric_id), meta);
let metric32: u32 = (20 << 27) | metric_id;
assert!(
__jog_metric_maps::UUID_MAP.write()?.insert(MetricId(metric_id), metric).is_none(),
__jog_metric_maps::UUID_MAP.write()?.insert(BaseMetricId(metric_id), metric).is_none(),
"We should never insert a runtime metric with an already-used id."
);
metric32

View File

@@ -35,7 +35,7 @@ pub mod test {
disabled: false,
..Default::default()
};
BooleanMetric::new(MetricId(1), meta)
BooleanMetric::new(BaseMetricId(1), meta)
});
#[allow(non_upper_case_globals)]
@@ -53,7 +53,7 @@ pub mod test {
disabled: false,
..Default::default()
};
CounterMetric::new(MetricId(2), meta)
CounterMetric::new(BaseMetricId(2), meta)
});
#[allow(non_upper_case_globals)]
@@ -71,7 +71,7 @@ pub mod test {
disabled: false,
..Default::default()
};
CustomDistributionMetric::new(MetricId(3), meta, 0, 100, 100, HistogramType::Linear)
CustomDistributionMetric::new(BaseMetricId(3), meta, 0, 100, 100, HistogramType::Linear)
});
#[allow(non_upper_case_globals)]
@@ -91,7 +91,7 @@ pub mod test {
..Default::default()
},
};
LabeledMetric::new(MetricId(4), meta, None)
LabeledMetric::new(BaseMetricId(4), meta, None)
});
#[repr(u16)]
@@ -159,7 +159,7 @@ pub mod test {
..Default::default()
},
};
LabeledMetric::new(MetricId(5), meta, Some(vec![::std::borrow::Cow::from("eight_labels"), ::std::borrow::Cow::from("five_labels"), ::std::borrow::Cow::from("four_labels"), ::std::borrow::Cow::from("nine_labels"), ::std::borrow::Cow::from("one_label"), ::std::borrow::Cow::from("seven_labels"), ::std::borrow::Cow::from("six_labels"), ::std::borrow::Cow::from("ten_labels"), ::std::borrow::Cow::from("three_labels"), ::std::borrow::Cow::from("two_labels")]))
LabeledMetric::new(BaseMetricId(5), meta, Some(vec![::std::borrow::Cow::from("eight_labels"), ::std::borrow::Cow::from("five_labels"), ::std::borrow::Cow::from("four_labels"), ::std::borrow::Cow::from("nine_labels"), ::std::borrow::Cow::from("one_label"), ::std::borrow::Cow::from("seven_labels"), ::std::borrow::Cow::from("six_labels"), ::std::borrow::Cow::from("ten_labels"), ::std::borrow::Cow::from("three_labels"), ::std::borrow::Cow::from("two_labels")]))
});
#[allow(non_upper_case_globals)]
@@ -179,7 +179,7 @@ pub mod test {
..Default::default()
},
};
LabeledMetric::new(MetricId(6), meta, None)
LabeledMetric::new(BaseMetricId(6), meta, None)
});
#[repr(u16)]
@@ -223,7 +223,7 @@ pub mod test {
..Default::default()
},
};
LabeledMetric::new(MetricId(7), meta, Some(vec![::std::borrow::Cow::from("one_label"), ::std::borrow::Cow::from("two_labels")]))
LabeledMetric::new(BaseMetricId(7), meta, Some(vec![::std::borrow::Cow::from("one_label"), ::std::borrow::Cow::from("two_labels")]))
});
#[allow(non_upper_case_globals)]
@@ -243,7 +243,7 @@ pub mod test {
..Default::default()
},
};
LabeledMetric::new(MetricId(8), meta, None)
LabeledMetric::new(BaseMetricId(8), meta, None)
});
#[repr(u16)]
@@ -287,7 +287,7 @@ pub mod test {
..Default::default()
},
};
LabeledMetric::new(MetricId(9), meta, Some(vec![::std::borrow::Cow::from("one_label"), ::std::borrow::Cow::from("two_labels")]))
LabeledMetric::new(BaseMetricId(9), meta, Some(vec![::std::borrow::Cow::from("one_label"), ::std::borrow::Cow::from("two_labels")]))
});
#[allow(non_upper_case_globals)]
@@ -305,7 +305,7 @@ pub mod test {
disabled: false,
..Default::default()
};
MemoryDistributionMetric::new(MetricId(10), meta, MemoryUnit::Kilobyte)
MemoryDistributionMetric::new(BaseMetricId(10), meta, MemoryUnit::Kilobyte)
});
#[allow(non_upper_case_globals)]
@@ -323,7 +323,7 @@ pub mod test {
disabled: false,
..Default::default()
};
StringListMetric::new(MetricId(11), meta)
StringListMetric::new(BaseMetricId(11), meta)
});
#[allow(non_upper_case_globals)]
@@ -341,7 +341,7 @@ pub mod test {
disabled: false,
..Default::default()
};
StringMetric::new(MetricId(12), meta)
StringMetric::new(BaseMetricId(12), meta)
});
#[allow(non_upper_case_globals)]
@@ -359,7 +359,7 @@ pub mod test {
disabled: false,
..Default::default()
};
TextMetric::new(MetricId(13), meta)
TextMetric::new(BaseMetricId(13), meta)
});
#[allow(non_upper_case_globals)]
@@ -377,7 +377,7 @@ pub mod test {
disabled: false,
..Default::default()
};
TimespanMetric::new(MetricId(14), meta, TimeUnit::Millisecond)
TimespanMetric::new(BaseMetricId(14), meta, TimeUnit::Millisecond)
});
#[allow(non_upper_case_globals)]
@@ -395,7 +395,7 @@ pub mod test {
disabled: false,
..Default::default()
};
TimingDistributionMetric::new(MetricId(15), meta, TimeUnit::Nanosecond)
TimingDistributionMetric::new(BaseMetricId(15), meta, TimeUnit::Nanosecond)
});
#[allow(non_upper_case_globals)]
@@ -413,7 +413,7 @@ pub mod test {
disabled: false,
..Default::default()
};
BooleanMetric::with_unordered_ipc(MetricId(16), meta)
BooleanMetric::with_unordered_ipc(BaseMetricId(16), meta)
});
#[allow(non_upper_case_globals)]
@@ -433,7 +433,7 @@ pub mod test {
..Default::default()
},
};
LabeledMetric::with_unordered_ipc(MetricId(17), meta, None)
LabeledMetric::with_unordered_ipc(BaseMetricId(17), meta, None)
});
}
@@ -476,7 +476,7 @@ pub mod test_nested {
disabled: false,
..Default::default()
};
ObjectMetric::new(MetricId(18), meta)
ObjectMetric::new(BaseMetricId(18), meta)
});
#[allow(non_upper_case_globals)]
@@ -494,7 +494,7 @@ pub mod test_nested {
disabled: false,
..Default::default()
};
DatetimeMetric::new(MetricId(19), meta, TimeUnit::Millisecond)
DatetimeMetric::new(BaseMetricId(19), meta, TimeUnit::Millisecond)
});
#[allow(non_upper_case_globals)]
@@ -512,7 +512,7 @@ pub mod test_nested {
disabled: false,
..Default::default()
};
EventMetric::new(MetricId(20), meta)
EventMetric::new(BaseMetricId(20), meta)
});
#[derive(Default, Debug, Clone, Hash, Eq, PartialEq)]
@@ -547,7 +547,7 @@ pub mod test_nested {
disabled: false,
..Default::default()
};
EventMetric::new(MetricId(21), meta)
EventMetric::new(BaseMetricId(21), meta)
});
#[allow(non_upper_case_globals)]
@@ -565,7 +565,7 @@ pub mod test_nested {
disabled: false,
..Default::default()
};
DenominatorMetric::new(MetricId(22), meta, vec![CommonMetricData {name: "rate_with_external_denominator".into(), category: "test.nested".into(), send_in_pings: vec!["metrics".into()], lifetime: Lifetime::Ping, disabled: false, ..Default::default()}, CommonMetricData {name: "rate_with_external_denominator".into(), category: "test2.nested".into(), send_in_pings: vec!["metrics".into()], lifetime: Lifetime::Ping, disabled: true, ..Default::default()}])
DenominatorMetric::new(BaseMetricId(22), meta, vec![CommonMetricData {name: "rate_with_external_denominator".into(), category: "test.nested".into(), send_in_pings: vec!["metrics".into()], lifetime: Lifetime::Ping, disabled: false, ..Default::default()}, CommonMetricData {name: "rate_with_external_denominator".into(), category: "test2.nested".into(), send_in_pings: vec!["metrics".into()], lifetime: Lifetime::Ping, disabled: true, ..Default::default()}])
});
#[allow(non_upper_case_globals)]
@@ -611,7 +611,7 @@ pub mod test_nested {
disabled: false,
..Default::default()
};
QuantityMetric::new(MetricId(25), meta)
QuantityMetric::new(BaseMetricId(25), meta)
});
#[allow(non_upper_case_globals)]
@@ -629,7 +629,7 @@ pub mod test_nested {
disabled: false,
..Default::default()
};
RateMetric::new(MetricId(26), meta)
RateMetric::new(BaseMetricId(26), meta)
});
#[allow(non_upper_case_globals)]
@@ -647,7 +647,7 @@ pub mod test_nested {
disabled: false,
..Default::default()
};
NumeratorMetric::new(MetricId(27), meta)
NumeratorMetric::new(BaseMetricId(27), meta)
});
#[allow(non_upper_case_globals)]
@@ -665,7 +665,7 @@ pub mod test_nested {
disabled: false,
..Default::default()
};
UuidMetric::new(MetricId(28), meta)
UuidMetric::new(BaseMetricId(28), meta)
});
}
@@ -695,7 +695,7 @@ pub mod test2 {
disabled: true,
..Default::default()
};
BooleanMetric::new(MetricId(29), meta)
BooleanMetric::new(BaseMetricId(29), meta)
});
#[allow(non_upper_case_globals)]
@@ -713,7 +713,7 @@ pub mod test2 {
disabled: true,
..Default::default()
};
CounterMetric::new(MetricId(30), meta)
CounterMetric::new(BaseMetricId(30), meta)
});
#[allow(non_upper_case_globals)]
@@ -731,7 +731,7 @@ pub mod test2 {
disabled: true,
..Default::default()
};
CustomDistributionMetric::new(MetricId(31), meta, 0, 100, 100, HistogramType::Linear)
CustomDistributionMetric::new(BaseMetricId(31), meta, 0, 100, 100, HistogramType::Linear)
});
#[allow(non_upper_case_globals)]
@@ -751,7 +751,7 @@ pub mod test2 {
..Default::default()
},
};
LabeledMetric::new(MetricId(32), meta, None)
LabeledMetric::new(BaseMetricId(32), meta, None)
});
#[repr(u16)]
@@ -819,7 +819,7 @@ pub mod test2 {
..Default::default()
},
};
LabeledMetric::new(MetricId(33), meta, Some(vec![::std::borrow::Cow::from("eight_labels"), ::std::borrow::Cow::from("five_labels"), ::std::borrow::Cow::from("four_labels"), ::std::borrow::Cow::from("nine_labels"), ::std::borrow::Cow::from("one_label"), ::std::borrow::Cow::from("seven_labels"), ::std::borrow::Cow::from("six_labels"), ::std::borrow::Cow::from("ten_labels"), ::std::borrow::Cow::from("three_labels"), ::std::borrow::Cow::from("two_labels")]))
LabeledMetric::new(BaseMetricId(33), meta, Some(vec![::std::borrow::Cow::from("eight_labels"), ::std::borrow::Cow::from("five_labels"), ::std::borrow::Cow::from("four_labels"), ::std::borrow::Cow::from("nine_labels"), ::std::borrow::Cow::from("one_label"), ::std::borrow::Cow::from("seven_labels"), ::std::borrow::Cow::from("six_labels"), ::std::borrow::Cow::from("ten_labels"), ::std::borrow::Cow::from("three_labels"), ::std::borrow::Cow::from("two_labels")]))
});
#[allow(non_upper_case_globals)]
@@ -839,7 +839,7 @@ pub mod test2 {
..Default::default()
},
};
LabeledMetric::new(MetricId(34), meta, None)
LabeledMetric::new(BaseMetricId(34), meta, None)
});
#[repr(u16)]
@@ -883,7 +883,7 @@ pub mod test2 {
..Default::default()
},
};
LabeledMetric::new(MetricId(35), meta, Some(vec![::std::borrow::Cow::from("one_label"), ::std::borrow::Cow::from("two_labels")]))
LabeledMetric::new(BaseMetricId(35), meta, Some(vec![::std::borrow::Cow::from("one_label"), ::std::borrow::Cow::from("two_labels")]))
});
#[allow(non_upper_case_globals)]
@@ -903,7 +903,7 @@ pub mod test2 {
..Default::default()
},
};
LabeledMetric::new(MetricId(36), meta, None)
LabeledMetric::new(BaseMetricId(36), meta, None)
});
#[repr(u16)]
@@ -947,7 +947,7 @@ pub mod test2 {
..Default::default()
},
};
LabeledMetric::new(MetricId(37), meta, Some(vec![::std::borrow::Cow::from("one_label"), ::std::borrow::Cow::from("two_labels")]))
LabeledMetric::new(BaseMetricId(37), meta, Some(vec![::std::borrow::Cow::from("one_label"), ::std::borrow::Cow::from("two_labels")]))
});
#[allow(non_upper_case_globals)]
@@ -965,7 +965,7 @@ pub mod test2 {
disabled: true,
..Default::default()
};
MemoryDistributionMetric::new(MetricId(38), meta, MemoryUnit::Kilobyte)
MemoryDistributionMetric::new(BaseMetricId(38), meta, MemoryUnit::Kilobyte)
});
#[allow(non_upper_case_globals)]
@@ -983,7 +983,7 @@ pub mod test2 {
disabled: true,
..Default::default()
};
StringListMetric::new(MetricId(39), meta)
StringListMetric::new(BaseMetricId(39), meta)
});
#[allow(non_upper_case_globals)]
@@ -1001,7 +1001,7 @@ pub mod test2 {
disabled: true,
..Default::default()
};
StringMetric::new(MetricId(40), meta)
StringMetric::new(BaseMetricId(40), meta)
});
#[allow(non_upper_case_globals)]
@@ -1019,7 +1019,7 @@ pub mod test2 {
disabled: true,
..Default::default()
};
TextMetric::new(MetricId(41), meta)
TextMetric::new(BaseMetricId(41), meta)
});
#[allow(non_upper_case_globals)]
@@ -1037,7 +1037,7 @@ pub mod test2 {
disabled: true,
..Default::default()
};
TimespanMetric::new(MetricId(42), meta, TimeUnit::Millisecond)
TimespanMetric::new(BaseMetricId(42), meta, TimeUnit::Millisecond)
});
#[allow(non_upper_case_globals)]
@@ -1055,7 +1055,7 @@ pub mod test2 {
disabled: true,
..Default::default()
};
TimingDistributionMetric::new(MetricId(43), meta, TimeUnit::Nanosecond)
TimingDistributionMetric::new(BaseMetricId(43), meta, TimeUnit::Nanosecond)
});
#[allow(non_upper_case_globals)]
@@ -1073,7 +1073,7 @@ pub mod test2 {
disabled: true,
..Default::default()
};
BooleanMetric::with_unordered_ipc(MetricId(44), meta)
BooleanMetric::with_unordered_ipc(BaseMetricId(44), meta)
});
#[allow(non_upper_case_globals)]
@@ -1093,7 +1093,7 @@ pub mod test2 {
..Default::default()
},
};
LabeledMetric::with_unordered_ipc(MetricId(45), meta, None)
LabeledMetric::with_unordered_ipc(BaseMetricId(45), meta, None)
});
}
@@ -1136,7 +1136,7 @@ pub mod test2_nested {
disabled: true,
..Default::default()
};
ObjectMetric::new(MetricId(46), meta)
ObjectMetric::new(BaseMetricId(46), meta)
});
#[allow(non_upper_case_globals)]
@@ -1154,7 +1154,7 @@ pub mod test2_nested {
disabled: true,
..Default::default()
};
DatetimeMetric::new(MetricId(47), meta, TimeUnit::Millisecond)
DatetimeMetric::new(BaseMetricId(47), meta, TimeUnit::Millisecond)
});
#[allow(non_upper_case_globals)]
@@ -1172,7 +1172,7 @@ pub mod test2_nested {
disabled: true,
..Default::default()
};
EventMetric::new(MetricId(48), meta)
EventMetric::new(BaseMetricId(48), meta)
});
#[derive(Default, Debug, Clone, Hash, Eq, PartialEq)]
@@ -1207,7 +1207,7 @@ pub mod test2_nested {
disabled: true,
..Default::default()
};
EventMetric::new(MetricId(49), meta)
EventMetric::new(BaseMetricId(49), meta)
});
#[allow(non_upper_case_globals)]
@@ -1267,7 +1267,7 @@ pub mod test2_nested {
disabled: true,
..Default::default()
};
QuantityMetric::new(MetricId(53), meta)
QuantityMetric::new(BaseMetricId(53), meta)
});
#[allow(non_upper_case_globals)]
@@ -1285,7 +1285,7 @@ pub mod test2_nested {
disabled: true,
..Default::default()
};
RateMetric::new(MetricId(54), meta)
RateMetric::new(BaseMetricId(54), meta)
});
#[allow(non_upper_case_globals)]
@@ -1303,7 +1303,7 @@ pub mod test2_nested {
disabled: true,
..Default::default()
};
NumeratorMetric::new(MetricId(55), meta)
NumeratorMetric::new(BaseMetricId(55), meta)
});
#[allow(non_upper_case_globals)]
@@ -1321,7 +1321,7 @@ pub mod test2_nested {
disabled: true,
..Default::default()
};
UuidMetric::new(MetricId(56), meta)
UuidMetric::new(BaseMetricId(56), meta)
});
}
@@ -1335,114 +1335,114 @@ pub(crate) mod __glean_metric_maps {
use crate::private::*;
use once_cell::sync::Lazy;
pub static BOOLEAN_MAP: Lazy<HashMap<MetricId, &Lazy<BooleanMetric>>> = Lazy::new(|| {
pub static BOOLEAN_MAP: Lazy<HashMap<BaseMetricId, &Lazy<BooleanMetric>>> = Lazy::new(|| {
let mut map = HashMap::with_capacity(4);
map.insert(MetricId(1), &super::test::boolean_metric);
map.insert(MetricId(16), &super::test::unordered_boolean_metric);
map.insert(MetricId(29), &super::test2::boolean_metric);
map.insert(MetricId(44), &super::test2::unordered_boolean_metric);
map.insert(BaseMetricId(1), &super::test::boolean_metric);
map.insert(BaseMetricId(16), &super::test::unordered_boolean_metric);
map.insert(BaseMetricId(29), &super::test2::boolean_metric);
map.insert(BaseMetricId(44), &super::test2::unordered_boolean_metric);
map
});
pub static COUNTER_MAP: Lazy<HashMap<MetricId, &Lazy<CounterMetric>>> = Lazy::new(|| {
pub static COUNTER_MAP: Lazy<HashMap<BaseMetricId, &Lazy<CounterMetric>>> = Lazy::new(|| {
let mut map = HashMap::with_capacity(7);
map.insert(MetricId(2), &super::test::counter_metric);
map.insert(MetricId(23), &super::test_nested::optimizable_counter_metric);
map.insert(MetricId(24), &super::test_nested::optimizable_disabled_counter_metric);
map.insert(MetricId(30), &super::test2::counter_metric);
map.insert(MetricId(50), &super::test2_nested::external_denominator);
map.insert(MetricId(51), &super::test2_nested::optimizable_counter_metric);
map.insert(MetricId(52), &super::test2_nested::optimizable_disabled_counter_metric);
map.insert(BaseMetricId(2), &super::test::counter_metric);
map.insert(BaseMetricId(23), &super::test_nested::optimizable_counter_metric);
map.insert(BaseMetricId(24), &super::test_nested::optimizable_disabled_counter_metric);
map.insert(BaseMetricId(30), &super::test2::counter_metric);
map.insert(BaseMetricId(50), &super::test2_nested::external_denominator);
map.insert(BaseMetricId(51), &super::test2_nested::optimizable_counter_metric);
map.insert(BaseMetricId(52), &super::test2_nested::optimizable_disabled_counter_metric);
map
});
pub static CUSTOM_DISTRIBUTION_MAP: Lazy<HashMap<MetricId, &Lazy<CustomDistributionMetric>>> = Lazy::new(|| {
pub static CUSTOM_DISTRIBUTION_MAP: Lazy<HashMap<BaseMetricId, &Lazy<CustomDistributionMetric>>> = Lazy::new(|| {
let mut map = HashMap::with_capacity(2);
map.insert(MetricId(3), &super::test::custom_distribution_metric);
map.insert(MetricId(31), &super::test2::custom_distribution_metric);
map.insert(BaseMetricId(3), &super::test::custom_distribution_metric);
map.insert(BaseMetricId(31), &super::test2::custom_distribution_metric);
map
});
pub static MEMORY_DISTRIBUTION_MAP: Lazy<HashMap<MetricId, &Lazy<MemoryDistributionMetric>>> = Lazy::new(|| {
pub static MEMORY_DISTRIBUTION_MAP: Lazy<HashMap<BaseMetricId, &Lazy<MemoryDistributionMetric>>> = Lazy::new(|| {
let mut map = HashMap::with_capacity(2);
map.insert(MetricId(10), &super::test::memory_distribution_metric);
map.insert(MetricId(38), &super::test2::memory_distribution_metric);
map.insert(BaseMetricId(10), &super::test::memory_distribution_metric);
map.insert(BaseMetricId(38), &super::test2::memory_distribution_metric);
map
});
pub static STRING_LIST_MAP: Lazy<HashMap<MetricId, &Lazy<StringListMetric>>> = Lazy::new(|| {
pub static STRING_LIST_MAP: Lazy<HashMap<BaseMetricId, &Lazy<StringListMetric>>> = Lazy::new(|| {
let mut map = HashMap::with_capacity(2);
map.insert(MetricId(11), &super::test::string_list_metric);
map.insert(MetricId(39), &super::test2::string_list_metric);
map.insert(BaseMetricId(11), &super::test::string_list_metric);
map.insert(BaseMetricId(39), &super::test2::string_list_metric);
map
});
pub static STRING_MAP: Lazy<HashMap<MetricId, &Lazy<StringMetric>>> = Lazy::new(|| {
pub static STRING_MAP: Lazy<HashMap<BaseMetricId, &Lazy<StringMetric>>> = Lazy::new(|| {
let mut map = HashMap::with_capacity(2);
map.insert(MetricId(12), &super::test::string_metric);
map.insert(MetricId(40), &super::test2::string_metric);
map.insert(BaseMetricId(12), &super::test::string_metric);
map.insert(BaseMetricId(40), &super::test2::string_metric);
map
});
pub static TEXT_MAP: Lazy<HashMap<MetricId, &Lazy<TextMetric>>> = Lazy::new(|| {
pub static TEXT_MAP: Lazy<HashMap<BaseMetricId, &Lazy<TextMetric>>> = Lazy::new(|| {
let mut map = HashMap::with_capacity(2);
map.insert(MetricId(13), &super::test::text_metric);
map.insert(MetricId(41), &super::test2::text_metric);
map.insert(BaseMetricId(13), &super::test::text_metric);
map.insert(BaseMetricId(41), &super::test2::text_metric);
map
});
pub static TIMESPAN_MAP: Lazy<HashMap<MetricId, &Lazy<TimespanMetric>>> = Lazy::new(|| {
pub static TIMESPAN_MAP: Lazy<HashMap<BaseMetricId, &Lazy<TimespanMetric>>> = Lazy::new(|| {
let mut map = HashMap::with_capacity(2);
map.insert(MetricId(14), &super::test::timespan_metric);
map.insert(MetricId(42), &super::test2::timespan_metric);
map.insert(BaseMetricId(14), &super::test::timespan_metric);
map.insert(BaseMetricId(42), &super::test2::timespan_metric);
map
});
pub static TIMING_DISTRIBUTION_MAP: Lazy<HashMap<MetricId, &Lazy<TimingDistributionMetric>>> = Lazy::new(|| {
pub static TIMING_DISTRIBUTION_MAP: Lazy<HashMap<BaseMetricId, &Lazy<TimingDistributionMetric>>> = Lazy::new(|| {
let mut map = HashMap::with_capacity(2);
map.insert(MetricId(15), &super::test::timing_distribution_metric);
map.insert(MetricId(43), &super::test2::timing_distribution_metric);
map.insert(BaseMetricId(15), &super::test::timing_distribution_metric);
map.insert(BaseMetricId(43), &super::test2::timing_distribution_metric);
map
});
pub static DATETIME_MAP: Lazy<HashMap<MetricId, &Lazy<DatetimeMetric>>> = Lazy::new(|| {
pub static DATETIME_MAP: Lazy<HashMap<BaseMetricId, &Lazy<DatetimeMetric>>> = Lazy::new(|| {
let mut map = HashMap::with_capacity(2);
map.insert(MetricId(19), &super::test_nested::datetime_metric);
map.insert(MetricId(47), &super::test2_nested::datetime_metric);
map.insert(BaseMetricId(19), &super::test_nested::datetime_metric);
map.insert(BaseMetricId(47), &super::test2_nested::datetime_metric);
map
});
pub static DENOMINATOR_MAP: Lazy<HashMap<MetricId, &Lazy<DenominatorMetric>>> = Lazy::new(|| {
pub static DENOMINATOR_MAP: Lazy<HashMap<BaseMetricId, &Lazy<DenominatorMetric>>> = Lazy::new(|| {
let mut map = HashMap::with_capacity(1);
map.insert(MetricId(22), &super::test_nested::external_denominator);
map.insert(BaseMetricId(22), &super::test_nested::external_denominator);
map
});
pub static QUANTITY_MAP: Lazy<HashMap<MetricId, &Lazy<QuantityMetric>>> = Lazy::new(|| {
pub static QUANTITY_MAP: Lazy<HashMap<BaseMetricId, &Lazy<QuantityMetric>>> = Lazy::new(|| {
let mut map = HashMap::with_capacity(2);
map.insert(MetricId(25), &super::test_nested::quantity_metric);
map.insert(MetricId(53), &super::test2_nested::quantity_metric);
map.insert(BaseMetricId(25), &super::test_nested::quantity_metric);
map.insert(BaseMetricId(53), &super::test2_nested::quantity_metric);
map
});
pub static RATE_MAP: Lazy<HashMap<MetricId, &Lazy<RateMetric>>> = Lazy::new(|| {
pub static RATE_MAP: Lazy<HashMap<BaseMetricId, &Lazy<RateMetric>>> = Lazy::new(|| {
let mut map = HashMap::with_capacity(2);
map.insert(MetricId(26), &super::test_nested::rate_metric);
map.insert(MetricId(54), &super::test2_nested::rate_metric);
map.insert(BaseMetricId(26), &super::test_nested::rate_metric);
map.insert(BaseMetricId(54), &super::test2_nested::rate_metric);
map
});
pub static NUMERATOR_MAP: Lazy<HashMap<MetricId, &Lazy<NumeratorMetric>>> = Lazy::new(|| {
pub static NUMERATOR_MAP: Lazy<HashMap<BaseMetricId, &Lazy<NumeratorMetric>>> = Lazy::new(|| {
let mut map = HashMap::with_capacity(2);
map.insert(MetricId(27), &super::test_nested::rate_with_external_denominator);
map.insert(MetricId(55), &super::test2_nested::rate_with_external_denominator);
map.insert(BaseMetricId(27), &super::test_nested::rate_with_external_denominator);
map.insert(BaseMetricId(55), &super::test2_nested::rate_with_external_denominator);
map
});
pub static UUID_MAP: Lazy<HashMap<MetricId, &Lazy<UuidMetric>>> = Lazy::new(|| {
pub static UUID_MAP: Lazy<HashMap<BaseMetricId, &Lazy<UuidMetric>>> = Lazy::new(|| {
let mut map = HashMap::with_capacity(2);
map.insert(MetricId(28), &super::test_nested::uuid_metric);
map.insert(MetricId(56), &super::test2_nested::uuid_metric);
map.insert(BaseMetricId(28), &super::test_nested::uuid_metric);
map.insert(BaseMetricId(56), &super::test2_nested::uuid_metric);
map
});
@@ -1560,9 +1560,9 @@ pub(crate) mod __glean_metric_maps {
/// or an `EventRecordingError::InvalidId` if no event by that ID exists
/// or an `EventRecordingError::InvalidExtraKey` if the event doesn't take extra pairs,
/// but some are passed in.
pub(crate) fn record_event_by_id_with_time(metric_id: MetricId, timestamp: u64, extra: HashMap<String, String>) -> Result<(), EventRecordingError> {
pub(crate) fn record_event_by_id_with_time(metric_id: BaseMetricId, timestamp: u64, extra: HashMap<String, String>) -> Result<(), EventRecordingError> {
match metric_id {
MetricId(20) => {
BaseMetricId(20) => {
if extra_keys_len(&super::test_nested::event_metric) == 0 && !extra.is_empty() {
return Err(EventRecordingError::InvalidExtraKey);
}
@@ -1570,7 +1570,7 @@ pub(crate) mod __glean_metric_maps {
super::test_nested::event_metric.record_with_time(timestamp, extra);
Ok(())
}
MetricId(21) => {
BaseMetricId(21) => {
if extra_keys_len(&super::test_nested::event_metric_with_extra) == 0 && !extra.is_empty() {
return Err(EventRecordingError::InvalidExtraKey);
}
@@ -1578,7 +1578,7 @@ pub(crate) mod __glean_metric_maps {
super::test_nested::event_metric_with_extra.record_with_time(timestamp, extra);
Ok(())
}
MetricId(48) => {
BaseMetricId(48) => {
if extra_keys_len(&super::test2_nested::event_metric) == 0 && !extra.is_empty() {
return Err(EventRecordingError::InvalidExtraKey);
}
@@ -1586,7 +1586,7 @@ pub(crate) mod __glean_metric_maps {
super::test2_nested::event_metric.record_with_time(timestamp, extra);
Ok(())
}
MetricId(49) => {
BaseMetricId(49) => {
if extra_keys_len(&super::test2_nested::event_metric_with_extra) == 0 && !extra.is_empty() {
return Err(EventRecordingError::InvalidExtraKey);
}
@@ -1772,7 +1772,7 @@ pub(crate) mod __glean_metric_maps {
pub(crate) const SUBMETRIC_BIT: u32 = 25;
pub(crate) static NEXT_LABELED_SUBMETRIC_ID: AtomicU32 = AtomicU32::new((1 << SUBMETRIC_BIT) + 1);
pub(crate) static LABELED_METRICS_TO_IDS: Lazy<RwLock<HashMap<(MetricId, String), SubMetricId>>> = Lazy::new(||
pub(crate) static LABELED_METRICS_TO_IDS: Lazy<RwLock<HashMap<(BaseMetricId, String), SubMetricId>>> = Lazy::new(||
RwLock::new(HashMap::new())
);
pub(crate) static LABELED_ENUMS_TO_IDS: Lazy<RwLock<HashMap<(u32, u16), u32>>> = Lazy::new(||