Skip to content

Commit

Permalink
Merge branch 'release-v60.3.0' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
badboy committed May 31, 2024
2 parents 8494585 + 66c25b2 commit 6ba5ccf
Show file tree
Hide file tree
Showing 18 changed files with 233 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .buildconfig.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
libraryVersion: 60.2.0
libraryVersion: 60.3.0
groupId: org.mozilla.telemetry
projects:
glean:
Expand Down
3 changes: 2 additions & 1 deletion .dictionary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
personal_ws-1.1 en 279 utf-8
personal_ws-1.1 en 282 utf-8
AAR
AARs
ABI
Expand All @@ -9,6 +9,7 @@ AndroidX
AppServices
BEHAVIOUR
BUGFIX
Backported
Bool
Booleans
CLI
Expand Down
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Unreleased changes

[Full changelog](https://github.com/mozilla/glean/compare/v60.2.0...main)
[Full changelog](https://github.com/mozilla/glean/compare/v60.3.0...main)

# v60.3.0 (2024-05-31)

[Full changelog](https://github.com/mozilla/glean/compare/v60.2.0...v60.3.0)

* Android
* Allow configuring `delayPingLifetimeIo` in Kotlin and auto-flush this data after 1000 writes.
It is also auto-flushed on background. ([#2851](https://github.com/mozilla/glean/pull/2851))

# v60.2.0 (2024-05-23)

Expand All @@ -9,6 +17,15 @@
* Rust
* Accept a ping schedule map on initialize ([#2839](https://github.com/mozilla/glean/pull/2839))

# v60.1.1 (2024-05-31)

[Full changelog](https://github.com/mozilla/glean/compare/v60.1.0...v60.1.1)

* Android
* Allow configuring `delayPingLifetimeIo` in Kotlin and auto-flush this data after 1000 writes.
It is also auto-flushed on background. ([#2851](https://github.com/mozilla/glean/pull/2851))
(Backported changes)

# v60.1.0 (2024-05-06)

[Full changelog](https://github.com/mozilla/glean/compare/v60.0.0...v60.1.0)
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions DEPENDENCIES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4951,9 +4951,9 @@ SOFTWARE.

The following text applies to code linked from these dependencies:

* [glean-core 60.2.0]( https://github.com/mozilla/glean )
* [glean-core 60.3.0]( https://github.com/mozilla/glean )
* [glean-build 14.0.1]( https://github.com/mozilla/glean )
* [glean 60.2.0]( https://github.com/mozilla/glean )
* [glean 60.3.0]( https://github.com/mozilla/glean )
* [zeitstempel 0.1.1]( https://github.com/badboy/zeitstempel )

```
Expand Down
2 changes: 1 addition & 1 deletion glean-core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "glean-core"
version = "60.2.0"
version = "60.3.0"
authors = ["Jan-Erik Rediger <[email protected]>", "The Glean Team <[email protected]>"]
description = "A modern Telemetry library"
repository = "https://github.com/mozilla/glean"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ open class GleanInternalAPI internal constructor() {
languageBindingName = LANGUAGE_BINDING_NAME,
uploadEnabled = uploadEnabled,
maxEvents = null,
delayPingLifetimeIo = false,
delayPingLifetimeIo = configuration.delayPingLifetimeIo,
appBuild = "none",
useCoreMps = false,
trimDataToRegisteredPings = false,
Expand Down Expand Up @@ -446,6 +446,9 @@ open class GleanInternalAPI internal constructor() {
* Handle the background event and send the appropriate pings.
*/
internal fun handleBackgroundEvent() {
// Persist data on backgrounding the app
persistPingLifetimeData()

gleanHandleClientInactive()
}

Expand Down Expand Up @@ -499,6 +502,16 @@ open class GleanInternalAPI internal constructor() {
return gleanSetSourceTags(tags.toList())
}

/**
* Asks the database to persist ping-lifetime data to disk. Probably expensive to call.
* Only has effect when Glean is configured with `delay_ping_lifetime_io: true`.
* If Glean hasn't been initialized this will dispatch and return Ok(()),
* otherwise it will block until the persist is done and return its Result.
*/
fun persistPingLifetimeData() {
return gleanPersistPingLifetimeData()
}

/**
* Set configuration to override metrics' enabled/disabled state, typically from a remote_settings
* experiment or rollout.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import mozilla.telemetry.glean.net.PingUploader
* @property experimentationId An experimentation identifier derived by the application
* to be sent with all pings.
* @property enableInternalPings Whether to enable internal pings.
* @property delayPingLifetimeIo Whether Glean should delay persistence of data from metrics with ping lifetime.
*/
data class Configuration @JvmOverloads constructor(
val serverEndpoint: String = DEFAULT_TELEMETRY_ENDPOINT,
Expand All @@ -38,6 +39,7 @@ data class Configuration @JvmOverloads constructor(
val enableEventTimestamps: Boolean = true,
val experimentationId: String? = null,
val enableInternalPings: Boolean = true,
val delayPingLifetimeIo: Boolean = false,
) {
companion object {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -877,4 +877,111 @@ class MetricsPingSchedulerTest {
server.shutdown()
}
}

fun `smoke-test for delayPingLifetimeIo=true`() {
// Essentially a copy of the
// "Data recorded before Glean inits must not get into overdue pings" test.
//
// Setting `delayPingLifetimeIo = true` on init to ensure data is flushed.
// This should then all work as expected.

// Reset Glean and do not start it right away.
Glean.testDestroyGleanHandle()

// Let's create a fake time the metrics ping was sent: this is required for
// us to not send a 'metrics' ping the first time we init glean.
val fakeNowDoNotSend = Calendar.getInstance()
fakeNowDoNotSend.clear()
fakeNowDoNotSend.set(2015, 6, 11, 4, 0, 0)
SystemClock.setCurrentTimeMillis(fakeNowDoNotSend.timeInMillis)

// Create a fake instance of the metrics ping scheduler just to set the last
// collection time.
val fakeMpsSetter = spy(MetricsPingScheduler(context, GleanBuildInfo.buildInfo))
fakeMpsSetter.updateSentDate(getISOTimeString(fakeNowDoNotSend, truncateTo = TimeUnit.DAY))

// Create a metric and set its value. We expect this to be sent in the ping that gets
// generated the SECOND time we start glean.
val expectedStringMetric = StringMetricType(
CommonMetricData(
disabled = false,
category = "telemetry",
lifetime = Lifetime.PING,
name = "expected_metric",
sendInPings = listOf("metrics"),
),
)
val expectedValue = "must-exist-in-the-first-ping"

// Start the web-server that will receive the metrics ping.
val server = getMockWebServer()
val config = Configuration(
serverEndpoint = "http://" + server.hostName + ":" + server.port,
delayPingLifetimeIo = true,
)

// Reset Glean and start it for the FIRST time, then record a value.
resetGlean(
context = context,
config = config,
)
expectedStringMetric.set(expectedValue)

// Destroy glean: it will retain the previously stored metric.
Glean.testDestroyGleanHandle()

// Create a metric and attempt to record data before Glean is initialized. This
// will be queued in the dispatcher.
val stringMetric = StringMetricType(
CommonMetricData(
disabled = false,
category = "telemetry",
lifetime = Lifetime.PING,
name = "canary_metric",
sendInPings = listOf("metrics"),
),
)
val canaryValue = "must-not-be-in-the-first-ping"
stringMetric.set(canaryValue)

// Set the current system time to a known datetime: this should make the metrics ping
// overdue and trigger it at startup.
val fakeNowTriggerPing = Calendar.getInstance()
fakeNowTriggerPing.clear()
fakeNowTriggerPing.set(2015, 6, 12, 7, 0, 0)
SystemClock.setCurrentTimeMillis(fakeNowTriggerPing.timeInMillis)

try {
// Initialize Glean the SECOND time: it will send the expected string metric (stored
// from the previous run) but must not send the canary string, which would be sent
// next time the 'metrics' ping is collected after this one.
resetGlean(
context = context,
clearStores = false,
uploadEnabled = true,
config = config,
)

// Trigger worker task to upload the pings in the background.
triggerWorkManager(context)

// Wait for the metrics ping to be received.
val request = server.takeRequest(20L, AndroidTimeUnit.SECONDS)!!
val docType = request.path!!.split("/")[3]
assertEquals("The received ping must be a 'metrics' ping", "metrics", docType)

val metricsJsonData = request.getPlainBody()

assertFalse(
"The canary metric must not be present in this ping",
metricsJsonData.contains("must-not-be-in-the-first-ping"),
)
assertTrue(
"The expected metric must be in this ping",
metricsJsonData.contains(expectedValue),
)
} finally {
server.shutdown()
}
}
}
4 changes: 2 additions & 2 deletions glean-core/rlb/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "glean"
version = "60.2.0"
version = "60.3.0"
authors = ["Jan-Erik Rediger <[email protected]>", "The Glean Team <[email protected]>"]
description = "Glean SDK Rust language bindings"
repository = "https://github.com/mozilla/glean"
Expand All @@ -23,7 +23,7 @@ maintenance = { status = "actively-developed" }

[dependencies.glean-core]
path = ".."
version = "60.2.0"
version = "60.3.0"

[dependencies]
inherent = "1"
Expand Down
2 changes: 1 addition & 1 deletion glean-core/rlb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ pub fn get_timestamp_ms() -> u64 {
/// If Glean hasn't been initialized this will dispatch and return Ok(()),
/// otherwise it will block until the persist is done and return its Result.
pub fn persist_ping_lifetime_data() {
glean_core::persist_ping_lifetime_data();
glean_core::glean_persist_ping_lifetime_data();
}

#[cfg(test)]
Expand Down
Loading

0 comments on commit 6ba5ccf

Please sign in to comment.