Report time of applying experiments as a single sample to Glean

This happens early during startup and Glean will now delay executing the
actual recording until after libxul is loaded externally.
This avoids forcing that load of Glean/libxul too early.
This commit is contained in:
Jan-Erik Rediger 2024-09-02 16:50:33 +02:00
Родитель fd2bd27dc5
Коммит 581f5d2866
1 изменённых файлов: 6 добавлений и 3 удалений

Просмотреть файл

@ -44,6 +44,7 @@ import org.mozilla.experiments.nimbus.internal.NimbusException
import org.mozilla.experiments.nimbus.internal.RecordedContext
import java.io.File
import java.io.IOException
import kotlin.system.measureTimeMillis
private const val EXPERIMENT_COLLECTION_NAME = "nimbus-mobile-experiments"
private const val NIMBUS_DATA_DIR: String = "nimbus_data"
@ -308,10 +309,12 @@ open class Nimbus(
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
internal fun applyPendingExperimentsOnThisThread() = withCatchAll("applyPendingExperiments") {
try {
val events = NimbusHealth.applyPendingExperimentsTime.measure {
nimbusClient.applyPendingExperiments()
var events: List<EnrollmentChangeEvent>?
val time = measureTimeMillis {
events = nimbusClient.applyPendingExperiments()
}
recordExperimentTelemetryEvents(events)
NimbusHealth.applyPendingExperimentsTime.accumulateSingleSample(time)
recordExperimentTelemetryEvents(events!!)
// Get the experiments to record in telemetry
postEnrolmentCalculation()
} catch (e: NimbusException.InvalidExperimentFormat) {