summaryrefslogtreecommitdiffstats
path: root/toolkit/components/glean/api/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--toolkit/components/glean/api/src/common_test.rs1
-rw-r--r--toolkit/components/glean/api/src/ffi/custom_distribution.rs20
-rw-r--r--toolkit/components/glean/api/src/ffi/event.rs5
-rw-r--r--toolkit/components/glean/api/src/private/custom_distribution.rs17
-rw-r--r--toolkit/components/glean/api/src/private/timing_distribution.rs12
5 files changed, 47 insertions, 8 deletions
diff --git a/toolkit/components/glean/api/src/common_test.rs b/toolkit/components/glean/api/src/common_test.rs
index 3c8c2c71e1..46062736f2 100644
--- a/toolkit/components/glean/api/src/common_test.rs
+++ b/toolkit/components/glean/api/src/common_test.rs
@@ -43,6 +43,7 @@ fn setup_glean(tempdir: Option<tempfile::TempDir>) -> tempfile::TempDir {
rate_limit: None,
enable_event_timestamps: false,
experimentation_id: None,
+ enable_internal_pings: true
};
let client_info = glean::ClientInfoMetrics {
diff --git a/toolkit/components/glean/api/src/ffi/custom_distribution.rs b/toolkit/components/glean/api/src/ffi/custom_distribution.rs
index 643ebfbff5..6f369fd268 100644
--- a/toolkit/components/glean/api/src/ffi/custom_distribution.rs
+++ b/toolkit/components/glean/api/src/ffi/custom_distribution.rs
@@ -69,6 +69,26 @@ pub extern "C" fn fog_custom_distribution_accumulate_samples_signed(
}
#[no_mangle]
+pub extern "C" fn fog_custom_distribution_accumulate_single_sample(id: u32, sample: u64) {
+ with_metric!(
+ CUSTOM_DISTRIBUTION_MAP,
+ id,
+ metric,
+ metric.accumulate_single_sample_signed(sample as i64)
+ );
+}
+
+#[no_mangle]
+pub extern "C" fn fog_custom_distribution_accumulate_single_sample_signed(id: u32, sample: i64) {
+ with_metric!(
+ CUSTOM_DISTRIBUTION_MAP,
+ id,
+ metric,
+ metric.accumulate_single_sample_signed(sample)
+ );
+}
+
+#[no_mangle]
pub extern "C" fn fog_custom_distribution_test_get_error(
id: u32,
diff --git a/toolkit/components/glean/api/src/ffi/event.rs b/toolkit/components/glean/api/src/ffi/event.rs
index bd167021d6..5d1e2dc0f1 100644
--- a/toolkit/components/glean/api/src/ffi/event.rs
+++ b/toolkit/components/glean/api/src/ffi/event.rs
@@ -4,8 +4,6 @@
#![cfg(feature = "with_gecko")]
-use std::collections::HashMap;
-
use nsstring::{nsACString, nsCString};
use thin_vec::ThinVec;
@@ -59,7 +57,6 @@ pub extern "C" fn fog_event_record(
Some(m) => m.record_raw(extra),
None => panic!("No (dynamic) metric for event with id {}", id),
}
- return;
} else {
match metric_maps::record_event_by_id(id, extra) {
Ok(()) => {}
@@ -148,7 +145,7 @@ pub extern "C" fn fog_event_test_get_value(
};
for event in events {
- let extra = event.extra.unwrap_or_else(HashMap::new);
+ let extra = event.extra.unwrap_or_default();
let extra_len = extra.len();
let mut extras = ThinVec::with_capacity(extra_len * 2);
for (k, v) in extra.into_iter() {
diff --git a/toolkit/components/glean/api/src/private/custom_distribution.rs b/toolkit/components/glean/api/src/private/custom_distribution.rs
index aeaf9b58c2..85121fca1e 100644
--- a/toolkit/components/glean/api/src/private/custom_distribution.rs
+++ b/toolkit/components/glean/api/src/private/custom_distribution.rs
@@ -92,8 +92,21 @@ impl CustomDistribution for CustomDistributionMetric {
}
}
- pub fn accumulate_single_sample_signed(&self, _sample: i64) {
- unimplemented!("bug 1884183: expose this to FOG")
+ pub fn accumulate_single_sample_signed(&self, sample: i64) {
+ match self {
+ CustomDistributionMetric::Parent { inner, .. } => {
+ inner.accumulate_single_sample(sample)
+ }
+ CustomDistributionMetric::Child(c) => {
+ with_ipc_payload(move |payload| {
+ if let Some(v) = payload.custom_samples.get_mut(&c.0) {
+ v.push(sample);
+ } else {
+ payload.custom_samples.insert(c.0, vec![sample]);
+ }
+ });
+ }
+ }
}
pub fn test_get_value<'a, S: Into<Option<&'a str>>>(
diff --git a/toolkit/components/glean/api/src/private/timing_distribution.rs b/toolkit/components/glean/api/src/private/timing_distribution.rs
index 6707560e41..2807b87c4f 100644
--- a/toolkit/components/glean/api/src/private/timing_distribution.rs
+++ b/toolkit/components/glean/api/src/private/timing_distribution.rs
@@ -374,8 +374,16 @@ impl TimingDistribution for TimingDistributionMetric {
}
}
- pub fn accumulate_single_sample(&self, _sample: i64) {
- unimplemented!("bug 1884183: expose this to FOG")
+ pub fn accumulate_single_sample(&self, sample: i64) {
+ match self {
+ TimingDistributionMetric::Parent { id: _id, inner } => {
+ inner.accumulate_single_sample(sample)
+ }
+ TimingDistributionMetric::Child(_c) => {
+ // TODO: Instrument this error
+ log::error!("Can't record samples for a timing distribution from a child metric");
+ }
+ }
}
/// **Exported for test purposes.**