зеркало из https://github.com/mozilla/glean.git
Bug 1551863 - Pass missing disabled flag to Rust side (#64)
Bug 1551863 - Pass missing disabled flag to Rust side
This commit is contained in:
Коммит
3c663feb46
|
@ -8,6 +8,7 @@ import androidx.annotation.VisibleForTesting
|
|||
import com.sun.jna.StringArray
|
||||
import mozilla.telemetry.glean.Glean
|
||||
import mozilla.telemetry.glean.rust.LibGleanFFI
|
||||
import mozilla.telemetry.glean.rust.toByte
|
||||
|
||||
class BooleanMetricType(
|
||||
disabled: Boolean,
|
||||
|
@ -27,7 +28,8 @@ class BooleanMetricType(
|
|||
name = name,
|
||||
send_in_pings = ffiPingsList,
|
||||
send_in_pings_len = sendInPings.size,
|
||||
lifetime = lifetime.ordinal)
|
||||
lifetime = lifetime.ordinal,
|
||||
disabled = disabled.toByte())
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -36,7 +38,7 @@ class BooleanMetricType(
|
|||
* @param value This is a user defined boolean value.
|
||||
*/
|
||||
fun set(value: Boolean) {
|
||||
LibGleanFFI.INSTANCE.glean_boolean_set(Glean.handle, this.handle, if (value) { 1 } else { 0 })
|
||||
LibGleanFFI.INSTANCE.glean_boolean_set(Glean.handle, this.handle, value.toByte())
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,6 +8,7 @@ import androidx.annotation.VisibleForTesting
|
|||
import com.sun.jna.StringArray
|
||||
import mozilla.telemetry.glean.Glean
|
||||
import mozilla.telemetry.glean.rust.LibGleanFFI
|
||||
import mozilla.telemetry.glean.rust.toByte
|
||||
|
||||
import mozilla.telemetry.glean.Dispatchers
|
||||
// import mozilla.components.service.glean.storages.CountersStorageEngine
|
||||
|
@ -43,7 +44,8 @@ class CounterMetricType(
|
|||
name = name,
|
||||
send_in_pings = ffiPingsList,
|
||||
send_in_pings_len = sendInPings.size,
|
||||
lifetime = lifetime.ordinal)
|
||||
lifetime = lifetime.ordinal,
|
||||
disabled = disabled.toByte())
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,6 +8,7 @@ import androidx.annotation.VisibleForTesting
|
|||
import com.sun.jna.StringArray
|
||||
import mozilla.telemetry.glean.Glean
|
||||
import mozilla.telemetry.glean.rust.LibGleanFFI
|
||||
import mozilla.telemetry.glean.rust.toByte
|
||||
|
||||
import mozilla.telemetry.glean.Dispatchers
|
||||
// import mozilla.components.service.glean.storages.StringsStorageEngine
|
||||
|
@ -42,7 +43,8 @@ class StringMetricType(
|
|||
name = name,
|
||||
send_in_pings = ffiPingsList,
|
||||
send_in_pings_len = sendInPings.size,
|
||||
lifetime = lifetime.ordinal)
|
||||
lifetime = lifetime.ordinal,
|
||||
disabled = disabled.toByte())
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,6 +12,9 @@ import com.sun.jna.Pointer
|
|||
import com.sun.jna.StringArray
|
||||
import java.lang.reflect.Proxy
|
||||
|
||||
// Turn a boolean into its Byte (u8) representation
|
||||
internal fun Boolean.toByte(): Byte = if (this) 1 else 0
|
||||
|
||||
@Suppress("TooManyFunctions")
|
||||
internal interface LibGleanFFI : Library {
|
||||
companion object {
|
||||
|
@ -52,7 +55,8 @@ internal interface LibGleanFFI : Library {
|
|||
name: String,
|
||||
send_in_pings: StringArray,
|
||||
send_in_pings_len: Int,
|
||||
lifetime: Int
|
||||
lifetime: Int,
|
||||
disabled: Byte
|
||||
): Long
|
||||
|
||||
fun glean_new_counter_metric(
|
||||
|
@ -60,7 +64,8 @@ internal interface LibGleanFFI : Library {
|
|||
name: String,
|
||||
send_in_pings: StringArray,
|
||||
send_in_pings_len: Int,
|
||||
lifetime: Int
|
||||
lifetime: Int,
|
||||
disabled: Byte
|
||||
): Long
|
||||
|
||||
fun glean_new_string_metric(
|
||||
|
@ -68,7 +73,8 @@ internal interface LibGleanFFI : Library {
|
|||
name: String,
|
||||
send_in_pings: StringArray,
|
||||
send_in_pings_len: Int,
|
||||
lifetime: Int
|
||||
lifetime: Int,
|
||||
disabled: Byte
|
||||
): Long
|
||||
|
||||
fun glean_ping_collect(glean_handle: Long, ping_name: String): Pointer?
|
||||
|
|
|
@ -17,7 +17,6 @@ import org.junit.Assert.assertEquals
|
|||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
|
@ -61,7 +60,6 @@ class CounterMetricTypeTest {
|
|||
assertEquals(11, counterMetric.testGetValue())
|
||||
}
|
||||
|
||||
@Ignore("Ignoring the test as 'disabled' is not passed through FFI")
|
||||
@Test
|
||||
fun `counters with no lifetime must not record data`() {
|
||||
// Define a 'counterMetric' counter metric, which will be stored in "store1".
|
||||
|
@ -81,7 +79,6 @@ class CounterMetricTypeTest {
|
|||
counterMetric.testHasValue())
|
||||
}
|
||||
|
||||
@Ignore("Ignoring the test as 'disabled' is not passed through FFI")
|
||||
@Test
|
||||
fun `disabled counters must not record data`() {
|
||||
// Define a 'counterMetric' counter metric, which will be stored in "store1". It's disabled
|
||||
|
|
|
@ -78,19 +78,22 @@ uint64_t glean_new_boolean_metric(FfiStr category,
|
|||
FfiStr name,
|
||||
RawStringArray send_in_pings,
|
||||
int32_t send_in_pings_len,
|
||||
int32_t lifetime);
|
||||
int32_t lifetime,
|
||||
uint8_t disabled);
|
||||
|
||||
uint64_t glean_new_counter_metric(FfiStr category,
|
||||
FfiStr name,
|
||||
RawStringArray send_in_pings,
|
||||
int32_t send_in_pings_len,
|
||||
int32_t lifetime);
|
||||
int32_t lifetime,
|
||||
uint8_t disabled);
|
||||
|
||||
uint64_t glean_new_string_metric(FfiStr category,
|
||||
FfiStr name,
|
||||
RawStringArray send_in_pings,
|
||||
int32_t send_in_pings_len,
|
||||
int32_t lifetime);
|
||||
int32_t lifetime,
|
||||
uint8_t disabled);
|
||||
|
||||
char *glean_ping_collect(uint64_t glean_handle, FfiStr ping_name);
|
||||
|
||||
|
|
|
@ -92,6 +92,7 @@ pub extern "C" fn glean_new_boolean_metric(
|
|||
send_in_pings: RawStringArray,
|
||||
send_in_pings_len: i32,
|
||||
lifetime: i32,
|
||||
disabled: u8,
|
||||
) -> u64 {
|
||||
BOOLEAN_METRICS.insert_with_log(|| {
|
||||
let send_in_pings = unsafe { from_raw_string_array(send_in_pings, send_in_pings_len) };
|
||||
|
@ -106,7 +107,7 @@ pub extern "C" fn glean_new_boolean_metric(
|
|||
category: category.into_string(),
|
||||
send_in_pings,
|
||||
lifetime,
|
||||
..Default::default()
|
||||
disabled: disabled != 0,
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
@ -118,6 +119,7 @@ pub extern "C" fn glean_new_string_metric(
|
|||
send_in_pings: RawStringArray,
|
||||
send_in_pings_len: i32,
|
||||
lifetime: i32,
|
||||
disabled: u8,
|
||||
) -> u64 {
|
||||
STRING_METRICS.insert_with_log(|| {
|
||||
let send_in_pings = unsafe { from_raw_string_array(send_in_pings, send_in_pings_len) };
|
||||
|
@ -135,7 +137,7 @@ pub extern "C" fn glean_new_string_metric(
|
|||
category: category.into_string(),
|
||||
send_in_pings,
|
||||
lifetime,
|
||||
..Default::default()
|
||||
disabled: disabled != 0,
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
@ -147,6 +149,7 @@ pub extern "C" fn glean_new_counter_metric(
|
|||
send_in_pings: RawStringArray,
|
||||
send_in_pings_len: i32,
|
||||
lifetime: i32,
|
||||
disabled: u8,
|
||||
) -> u64 {
|
||||
COUNTER_METRICS.insert_with_log(|| {
|
||||
let send_in_pings = unsafe { from_raw_string_array(send_in_pings, send_in_pings_len) };
|
||||
|
@ -164,7 +167,7 @@ pub extern "C" fn glean_new_counter_metric(
|
|||
category: category.into_string(),
|
||||
send_in_pings,
|
||||
lifetime,
|
||||
..Default::default()
|
||||
disabled: disabled != 0,
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче