Extensions.AppLaunchSource off-by-one error |
||||
Issue descriptionIn this code snippet, the type passed to UMA_HISTOGRAM_ENUMERATION doesn't match histograms.xml. In https://cs.chromium.org/chromium/src/extensions/browser/api/app_runtime/app_runtime_api.cc?dr=CSs&sq=package:chromium&rcl=1478013686&l=55 : void DispatchOnLaunchedEventImpl( const std::string& extension_id, app_runtime::LaunchSource source, ... UMA_HISTOGRAM_ENUMERATION( "Extensions.AppLaunchSource", source, NUM_APP_LAUNCH_SOURCES); app_runtime::LaunchSource is defined as: enum LaunchSource { LAUNCH_SOURCE_NONE, LAUNCH_SOURCE_UNTRACKED, LAUNCH_SOURCE_APP_LAUNCHER, ... LAUNCH_SOURCE_TEST, LAUNCH_SOURCE_INSTALLED_NOTIFICATION, LAUNCH_SOURCE_LAST = LAUNCH_SOURCE_INSTALLED_NOTIFICATION, }; However, in histograms.xml: <enum name="AppLaunchSource" type="int"> <int value="0" label="SOURCE_UNTRACKED"/> <int value="1" label="SOURCE_APP_LAUNCHER"/> ... <int value="18" label="SOURCE_TEST"/> <int value="19" label="SOURCE_INSTALLED_NOTIFICATION"/> </enum> This mismatch has caused off-by-one error on UMA data analysis. This is discovered by the checks implemented in this CL: https://codereview.chromium.org/2469993002/
,
Nov 2 2016
,
Nov 2 2016
I think the best way to fix this is to edit histograms.xml and change the labels to match LaunchSource, and use LAUNCH_SOURCE_LAST+1 as the max.
,
Nov 2 2016
How weird. There is also https://cs.chromium.org/chromium/src/extensions/common/constants.h?rcl=1478101093&l=122: enum AppLaunchSource { SOURCE_UNTRACKED = 0, SOURCE_APP_LAUNCHER, SOURCE_NEW_TAB_PAGE, SOURCE_RELOAD, SOURCE_RESTART, SOURCE_LOAD_AND_LAUNCH, SOURCE_COMMAND_LINE, SOURCE_FILE_HANDLER, SOURCE_URL_HANDLER, SOURCE_SYSTEM_TRAY, SOURCE_ABOUT_PAGE, SOURCE_KEYBOARD, SOURCE_EXTENSIONS_PAGE, SOURCE_MANAGEMENT_API, SOURCE_EPHEMERAL_APP_DEPRECATED, SOURCE_BACKGROUND, SOURCE_KIOSK, SOURCE_CHROME_INTERNAL, SOURCE_TEST, SOURCE_INSTALLED_NOTIFICATION, NUM_APP_LAUNCH_SOURCES }; I don't really know why we have two enumerations. cylee@, can you remember?
,
Nov 2 2016
I guess the original intention was to use AppLaunchSource for UMA, but LaunchSource was wrongly passed to UMA_HISTOGRAM_ENUMERATION. For data consistency, we can no longer "fix" it by using the original intention. As for why having two enum, could it be that one is generated?
,
Nov 2 2016
Right, one was auto generated from the IDL, but I guess was a bit too high in the dependency stack to use everywhere, so another was defined for general use. Importantly, the values passed into the histogram will in fact always be of the autogenerated type. It would have been better to pass the other type in but it's too late to change things. So I think what we should do is: - update the histograms.xml as suggested to match LaunchSource. - use LAUNCH_SOURCE_LAST instead of NUM_APP_LAUNCH_SOURCES as the last launch source - for clarity add the _NONE value to the constants. - add a comment to the .idl file mentioning that these should not be reordered etc. as they are used in histograms.
,
Nov 2 2016
Hopefully no important decisions were made based on the distribution of "Extensions.AppLaunchSource" in UMA.
,
Nov 16 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/004905cf6e6644d5d31bba196cb4cb41fb68bb0a commit 004905cf6e6644d5d31bba196cb4cb41fb68bb0a Author: wychen <wychen@chromium.org> Date: Wed Nov 16 22:00:19 2016 Fix Extensions.AppLaunchSource off-by-one error BUG= 661405 Review-Url: https://codereview.chromium.org/2486453002 Cr-Commit-Position: refs/heads/master@{#432638} [modify] https://crrev.com/004905cf6e6644d5d31bba196cb4cb41fb68bb0a/extensions/browser/api/app_runtime/app_runtime_api.cc [modify] https://crrev.com/004905cf6e6644d5d31bba196cb4cb41fb68bb0a/extensions/common/api/app_runtime.idl [modify] https://crrev.com/004905cf6e6644d5d31bba196cb4cb41fb68bb0a/extensions/common/constants.h [modify] https://crrev.com/004905cf6e6644d5d31bba196cb4cb41fb68bb0a/tools/metrics/histograms/histograms.xml
,
Nov 17 2016
|
||||
►
Sign in to add a comment |
||||
Comment 1 by wychen@chromium.org
, Nov 2 2016