зеркало из https://github.com/mozilla/glean.git
Port initialize_for_subprocess for use in Python upload process
This commit is contained in:
Родитель
af0767e771
Коммит
3972a64953
|
@ -13,6 +13,15 @@ namespace glean {
|
|||
// It will return immediately.
|
||||
boolean glean_initialize(InternalConfiguration cfg, ClientInfoMetrics client_info, OnGleanEvents callbacks);
|
||||
|
||||
// Creates and initializes a new Glean object for use in a subprocess.
|
||||
//
|
||||
// Importantly, this will not send any pings at startup, since that
|
||||
// sort of management should only happen in the main process.
|
||||
//
|
||||
// Must only be used for an uploader process.
|
||||
// The general API or any metrics API **will not work**.
|
||||
boolean glean_initialize_for_subprocess(InternalConfiguration cfg);
|
||||
|
||||
void glean_set_upload_enabled(boolean enabled);
|
||||
|
||||
// Experiment reporting API
|
||||
|
|
|
@ -224,17 +224,37 @@ pub fn glean_initialize(
|
|||
client_info: ClientInfoMetrics,
|
||||
callbacks: Box<dyn OnGleanEvents>,
|
||||
) -> bool {
|
||||
initialize_inner(cfg, client_info, callbacks)
|
||||
initialize_inner(cfg, client_info, callbacks);
|
||||
true
|
||||
}
|
||||
|
||||
/// Creates and initializes a new Glean object for use in a subprocess.
|
||||
///
|
||||
/// Importantly, this will not send any pings at startup, since that
|
||||
/// sort of management should only happen in the main process.
|
||||
pub fn glean_initialize_for_subprocess(cfg: InternalConfiguration) -> bool {
|
||||
let glean = match Glean::new_for_subprocess(&cfg, true) {
|
||||
Ok(glean) => glean,
|
||||
Err(err) => {
|
||||
log::error!("Failed to initialize Glean: {}", err);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
if core::setup_glean(glean).is_err() {
|
||||
return false;
|
||||
}
|
||||
log::info!("Glean initialized for subprocess");
|
||||
true
|
||||
}
|
||||
|
||||
fn initialize_inner(
|
||||
cfg: InternalConfiguration,
|
||||
client_info: ClientInfoMetrics,
|
||||
callbacks: Box<dyn OnGleanEvents>,
|
||||
) -> bool {
|
||||
) {
|
||||
if was_initialize_called() {
|
||||
log::error!("Glean should not be initialized multiple times");
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
let init_handle = std::thread::Builder::new()
|
||||
|
@ -404,8 +424,6 @@ fn initialize_inner(
|
|||
if dispatcher::global::is_test_mode() {
|
||||
join_init();
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
/// TEST ONLY FUNCTION
|
||||
|
|
Загрузка…
Ссылка в новой задаче