def _finalize_telemetry_glean(telemetry, is_bootstrap, success): """Submit telemetry collected by Glean. Finalizes some metrics (command success state and duration, system information) and requests Glean to send the collected data. """ from mach.telemetry import MACH_METRICS_PATH from mozbuild.telemetry import ( get_cpu_brand, get_distro_and_version, get_psutil_stats, ) mach_metrics = telemetry.metrics(MACH_METRICS_PATH) mach_metrics.mach.duration.stop() mach_metrics.mach.success.set(success) system_metrics = mach_metrics.mach.system system_metrics.cpu_brand.set(get_cpu_brand()) distro, version = get_distro_and_version() system_metrics.distro.set(distro) system_metrics.distro_version.set(version) has_psutil, logical_cores, physical_cores, memory_total = get_psutil_stats( ) if has_psutil: # psutil may not be available (we allow `mach create-mach-environment` # to fail to install it). system_metrics.logical_cores.add(logical_cores) system_metrics.physical_cores.add(physical_cores) if memory_total is not None: system_metrics.memory.accumulate( int(math.ceil(float(memory_total) / (1024 * 1024 * 1024)))) telemetry.submit(is_bootstrap)
def _finalize_telemetry_glean(telemetry, is_bootstrap, success): """Submit telemetry collected by Glean. Finalizes some metrics (command success state and duration, system information) and requests Glean to send the collected data. """ from mach.telemetry import MACH_METRICS_PATH from mozbuild.telemetry import ( get_cpu_brand, get_distro_and_version, get_psutil_stats, get_shell_info, get_vscode_running, ) mach_metrics = telemetry.metrics(MACH_METRICS_PATH) mach_metrics.mach.duration.stop() mach_metrics.mach.success.set(success) system_metrics = mach_metrics.mach.system cpu_brand = get_cpu_brand() if cpu_brand: system_metrics.cpu_brand.set(cpu_brand) distro, version = get_distro_and_version() system_metrics.distro.set(distro) system_metrics.distro_version.set(version) vscode_terminal, ssh_connection = get_shell_info() system_metrics.vscode_terminal.set(vscode_terminal) system_metrics.ssh_connection.set(ssh_connection) system_metrics.vscode_running.set(get_vscode_running()) has_psutil, logical_cores, physical_cores, memory_total = get_psutil_stats( ) if has_psutil: # psutil may not be available (we may not have been able to download # a wheel or build it from source). system_metrics.logical_cores.add(logical_cores) if physical_cores is not None: system_metrics.physical_cores.add(physical_cores) if memory_total is not None: system_metrics.memory.accumulate( int(math.ceil(float(memory_total) / (1024 * 1024 * 1024)))) telemetry.submit(is_bootstrap)