<!--
Copyright 2021 The Chromium Authors
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->

<!--
This file is used to generate a comprehensive list of ML Service histograms
along with a detailed description for each histogram.

For best practices on writing histogram descriptions, see
https://chromium.googlesource.com/chromium/src.git/+/HEAD/tools/metrics/histograms/README.md

Please follow the instructions in the OWNERS file in this directory to find a
reviewer. If no OWNERS file exists, please consider signing up at
go/reviewing-metrics (Googlers only), as all subdirectories are expected to
have an OWNERS file. As a last resort you can send the CL to
chromium-metrics-reviews@google.com.
-->

<histogram-configuration>

<histograms>

<variants name="BuiltinModelName">
<!-- Built-in with common TFLite-related histograms -->

  <variant name="SmartDimModel"/>
  <variant name="TestModel"/>
</variants>

<variants name="PerformanceMetricsRequestName">
<!-- ML Service Mojo requests for which standard performance histograms are
  gathered using RequestMetrics -->

  <variant name="DocumentScanner.DetectCornersFromJPEG"/>
  <variant name="DocumentScanner.DetectCornersFromNV12"/>
  <variant name="DocumentScanner.DoPostProcessing"/>
  <variant name="DocumentScanner.LoadModelResult"/>
  <variant name="HandwritingModel.LoadModelResult"/>
  <variant name="HandwritingModel.Recognize"/>
  <variant name="ImageAnnotator.AnnotateEncodedImage"/>
  <variant name="ImageAnnotator.AnnotateRawImage"/>
  <variant name="ImageAnnotator.LoadModelResult"/>
  <variant name="SmartDimModel.CreateGraphExecutorResult"/>
  <variant name="SmartDimModel.ExecuteResult"/>
  <variant name="SmartDimModel.LoadModelResult"/>
  <variant name="Soda.LoadModelResult"/>
  <variant name="TestModel.CreateGraphExecutorResult"/>
  <variant name="TestModel.ExecuteResult"/>
  <variant name="TestModel.LoadModelResult"/>
  <variant name="TextClassifier.Annotate"/>
  <variant name="TextClassifier.FindLanguages"/>
  <variant name="TextClassifier.LoadModelResult"/>
  <variant name="TextClassifier.SuggestSelection"/>
  <variant name="TextSuggester.LoadModelResult"/>
  <variant name="TextSuggester.Suggest"/>
  <variant name="WebPlatformHandwritingModel.GetPrediction"/>
  <variant name="WebPlatformHandwritingModel.LoadModelResult"/>
</variants>

<histogram name="MachineLearningService.CpuUsageMilliPercent"
    units="1/1000ths of %" expires_after="2027-01-24">
  <owner>amoylan@chromium.org</owner>
  <owner>ml-service-team@google.com</owner>
  <summary>
    Fraction of total CPU resources used by ChromeOS ML Service, sampled every 5
    minutes.
  </summary>
</histogram>

<histogram name="MachineLearningService.DocumentScanner.{RequestName}.Event"
    enum="MachineLearningServiceDocumentScannerResultEvent"
    expires_after="2026-09-08">
  <owner>wtlee@chromium.org</owner>
  <owner>chromeos-camera-eng@google.com</owner>
  <owner>ml-service-team@google.com</owner>
  <summary>
    The result of DocumentScanner.{RequestName} request, which can be OK or
    ERROR.
  </summary>
  <token key="RequestName">
    <variant name="DetectCornersFromJPEG"/>
    <variant name="DetectCornersFromNV12"/>
    <variant name="DoPostProcessing"/>
  </token>
</histogram>

<histogram name="MachineLearningService.GrammarChecker.Check.Event"
    enum="Boolean" expires_after="2026-10-04">
  <owner>jiwan@chromium.org</owner>
  <owner>amoylan@chromium.org</owner>
  <summary>The result of grammar check, which can be OK or ERROR.</summary>
</histogram>

<histogram name="MachineLearningService.HandwritingModel.LoadModelResult.Event"
    enum="MachineLearningServiceLoadHandwritingModelResultEvent"
    expires_after="2027-03-01">
  <owner>amoylan@chromium.org</owner>
  <owner>ml-service-team@google.com</owner>
  <summary>
    The result of load handwriting model, which can be OK or some specific
    error. The error code could be logged in machine learning service in chrome
    or in chromeos when handwriting model is not loaded successfully.
  </summary>
</histogram>

<histogram name="MachineLearningService.HandwritingModel.Recognize.Event"
    enum="Boolean" expires_after="2027-02-01">
  <owner>amoylan@chromium.org</owner>
  <owner>ml-service-team@google.com</owner>
  <summary>
    The result of handwriting recognition, which can be OK or some specific
    error.
  </summary>
</histogram>

<histogram
    name="MachineLearningService.HeatmapPalmRejection.ExecuteResult.Event"
    enum="MachineLearningServiceExecuteResultEvent" expires_after="2026-11-01">
  <owner>jiwan@chromium.org</owner>
  <owner>robsc@chromium.org</owner>
  <owner>amoylan@chromium.org</owner>
  <summary>
    The result of heatmap palm rejection Execute request, which can be OK or
    some specific error.
  </summary>
</histogram>

<histogram
    name="MachineLearningService.HeatmapPalmRejection.LoadModelResult.Event"
    enum="MachineLearningServiceLoadHeatmapPalmRejectionResult"
    expires_after="2026-11-01">
  <owner>jiwan@chromium.org</owner>
  <owner>robsc@chromium.org</owner>
  <owner>amoylan@chromium.org</owner>
  <summary>
    The result of load heatmap palm rejection module, which can be OK or some
    specific error.
  </summary>
</histogram>

<histogram
    name="MachineLearningService.ImageAnnotator.AnnotateEncodedImage.Event"
    enum="Boolean" expires_after="2026-05-04">
  <owner>chenjih@google.com</owner>
  <owner>nbowe@chromium.org</owner>
  <summary>
    The result of image annotation, which can be OK or some specific error.
  </summary>
</histogram>

<histogram name="MachineLearningService.LoadModelResult"
    enum="MachineLearningServiceLoadModelResultEvent"
    expires_after="2027-03-01">
  <owner>amoylan@chromium.org</owner>
  <owner>ml-service-team@google.com</owner>
  <summary>
    The error result of LoadModel in cases when the model name could not be
    determined. See MachineLearningService.*.LoadModelResult.Event for the
    result broken down by model name when the name is known.
  </summary>
</histogram>

<histogram name="MachineLearningService.MlCore.DlcBeginInstallDlcServiceError"
    enum="MachineLearningServiceDlcErrorCode" expires_after="2027-02-01">
  <owner>amoylan@chromium.org</owner>
  <owner>chenjih@google.com</owner>
  <owner>nbowe@chromium.org</owner>
  <summary>
    The detailed error code received from DLC Service while trying to request to
    install the ML Core DLC.
  </summary>
</histogram>

<histogram name="MachineLearningService.MlCore.DlcBeginInstallResult"
    enum="MachineLearningServiceDlcBeginInstallResult"
    expires_after="2027-02-01">
  <owner>amoylan@chromium.org</owner>
  <owner>chenjih@google.com</owner>
  <owner>nbowe@chromium.org</owner>
  <summary>
    Result of an attempt to request DLC Service to begin installation of the ML
    Core DLC. See the related histogram .DlcBeginInstallDlcServiceError for
    detailed error codes returned from DLC Service.
  </summary>
</histogram>

<histogram name="MachineLearningService.MlCore.DlcFinalInstallDlcServiceError"
    enum="MachineLearningServiceDlcErrorCode" expires_after="2027-02-01">
  <owner>amoylan@chromium.org</owner>
  <owner>chenjih@google.com</owner>
  <owner>nbowe@chromium.org</owner>
  <summary>
    The detailed error code received from DLC Service after a DLC State Change
    notification from DLC Service, following a request to install the ML Core
    DLC. &quot;BUSY&quot; code is considered non-final as retries are made in
    this case.
  </summary>
</histogram>

<histogram name="MachineLearningService.MlCore.DlcFinalInstallResult"
    enum="MachineLearningServiceDlcFinalInstallResult"
    expires_after="2027-02-01">
  <owner>amoylan@chromium.org</owner>
  <owner>chenjih@google.com</owner>
  <owner>nbowe@chromium.org</owner>
  <summary>
    Final result of an attempt to install the ML Core DLC. See the related
    histogram .DlcFinalInstallDlcServiceError for detailed error codes returned
    from DLC Service.
  </summary>
</histogram>

<histogram name="MachineLearningService.MlCore.DlcInstallAttemptCount"
    units="attempts" expires_after="2027-02-01">
  <owner>amoylan@chromium.org</owner>
  <owner>chenjih@google.com</owner>
  <owner>nbowe@chromium.org</owner>
  <summary>
    Indicates at least n attempts were made to install the ML Core DLC. Note
    that the buckets are cumulative: If e.g. 3 attempts are made, then the
    &quot;1&quot;, &quot;2&quot;, and &quot;3&quot; buckets will all be
    incremented.
  </summary>
</histogram>

<histogram name="MachineLearningService.MojoConnectionEvent"
    enum="MachineLearningServiceMojoConnectionEvent" expires_after="2027-02-01">
  <owner>amoylan@chromium.org</owner>
  <owner>ml-service-team@google.com</owner>
  <summary>
    Events related to the connection and disconnection of the Mojo IPC channel
    between Chrome and the ChromeOS ML Service.
  </summary>
</histogram>

<histogram name="MachineLearningService.NumWorkerProcess" units="count"
    expires_after="2027-03-01">
  <owner>amoylan@chromium.org</owner>
  <owner>ml-service-team@google.com</owner>
  <summary>
    Number of worker processes registered in ml-service. Only used in ChromeOS.
    Sampled every 5 minutes.
  </summary>
</histogram>

<histogram name="MachineLearningService.PeakTotalMemoryKb" units="KB"
    expires_after="2026-12-27">
  <owner>amoylan@chromium.org</owner>
  <owner>ml-service-team@google.com</owner>
  <summary>
    Peak total (shared and non-shared) memory used by ChromeOS ML Service over
    the last 24 hours. Sampled every 5 minutes, so may miss short-lived spikes.
  </summary>
</histogram>

<histogram name="MachineLearningService.ProcessError"
    enum="MachineLearningServiceProcessError" expires_after="2027-01-31">
  <owner>amoylan@chromium.org</owner>
  <owner>ml-service-team@google.com</owner>
  <summary>
    Process handling errors of ml-service. Emitted when there is error in
    process handling. For example, &quot;failed to spawning worker process&quot;
    etc. Only used in ChromeOS.
  </summary>
</histogram>

<histogram name="MachineLearningService.ReapWorkerProcessErrno"
    enum="MachineLearningServiceReapWorkerProcessErrno"
    expires_after="2027-03-01">
  <owner>amoylan@chromium.org</owner>
  <owner>ml-service-team@google.com</owner>
  <summary>
    The &quot;errno&quot; of waitpid calls used by ml-service's control process
    to reap the worker processes. This is only recorded when waitpid meets error
    and should be rare. This is a ChromeOS only metric. And we only record the
    corresponding enum values of &quot;ECHILD&quot;, &quot;EINTR&quot; and
    &quot;EINVAL&quot; because according to the man page of waitpid, they are
    the only possible errno. All the other &quot;errno&quot; are treated as
    &quot;unknown&quot; error.
  </summary>
</histogram>

<histogram name="MachineLearningService.TextSuggester.Suggest.Event"
    enum="BooleanError" expires_after="2026-11-01">
  <owner>curtismcmullan@chromium.org</owner>
  <owner>amoylan@chromium.org</owner>
  <summary>
    The result of a text suggester request, which can be OK or ERROR.
  </summary>
</histogram>

<histogram name="MachineLearningService.TotalMemoryKb" units="KB"
    expires_after="2027-02-01">
  <owner>amoylan@chromium.org</owner>
  <owner>ml-service-team@google.com</owner>
  <summary>
    Total (shared and non-shared) memory used by ChromeOS ML Service, sampled
    every 5 minutes.
  </summary>
</histogram>

<histogram
    name="MachineLearningService.WebPlatformHandwritingModel.GetPrediction.Event"
    enum="Boolean" expires_after="2026-11-01">
  <owner>amoylan@chromium.org</owner>
  <owner>ml-service-team@google.com</owner>
  <summary>
    The result of Web platform handwriting recognition, which can be either OK
    or Error.
  </summary>
</histogram>

<histogram
    name="MachineLearningService.WebPlatformHandwritingModel.LoadModelResult.Event"
    enum="MachineLearningServiceLoadHandwritingModelResultEvent"
    expires_after="2026-11-01">
  <owner>amoylan@chromium.org</owner>
  <owner>ml-service-team@google.com</owner>
  <summary>
    The result of load web platform handwriting model, which can be OK or some
    specific error. The error code could be logged in machine learning service
    in chrome or in chromeos when handwriting model is not loaded successfully.
  </summary>
</histogram>

<histogram name="MachineLearningService.WorkerProcessAcceptMojoConnectionTime"
    units="microseconds" expires_after="2027-01-24">
  <owner>amoylan@chromium.org</owner>
  <owner>ml-service-team@google.com</owner>
  <summary>
    The wall time used for the worker process to accept the mojo connection to
    control process in ml-service. Only used in ChromeOS.
  </summary>
</histogram>

<histogram name="MachineLearningService.WorkerProcessCleanUpTime"
    units="microseconds" expires_after="2027-01-31">
  <owner>amoylan@chromium.org</owner>
  <owner>ml-service-team@google.com</owner>
  <summary>
    The wall time used by the control process to reap and cleanup the worker
    processes in ml-service. Only used in ChromeOS.
  </summary>
</histogram>

<histogram name="MachineLearningService.WorkerProcessExitStatus"
    units="exit status" expires_after="2027-03-01">
  <owner>amoylan@chromium.org</owner>
  <owner>ml-service-team@google.com</owner>
  <summary>
    The exit status of the worker processes of ml-service. Only used in Chrome
    OS. This is only emitted when the worker process exits with non-zero status.
    And theoretically, there can be 255 different types of status (from 1 to
    255).
  </summary>
</histogram>

<histogram
    name="MachineLearningService.{ModelName}.CreateGraphExecutorResult.Event"
    enum="MachineLearningServiceCreateGraphExecutorResultEvent"
    expires_after="2027-02-01">
  <owner>amoylan@chromium.org</owner>
  <owner>ml-service-team@google.com</owner>
  <summary>
    The result of CreateGraphExecutor request for model {ModelName}, which can
    be OK or some specific error.
  </summary>
  <token key="ModelName" variants="BuiltinModelName"/>
</histogram>

<histogram name="MachineLearningService.{ModelName}.ExecuteResult.Event"
    enum="MachineLearningServiceExecuteResultEvent" expires_after="2027-02-01">
  <owner>amoylan@chromium.org</owner>
  <owner>ml-service-team@google.com</owner>
  <summary>
    The result of Execute request for model {ModelName}, which can be OK or some
    specific error.
  </summary>
  <token key="ModelName" variants="BuiltinModelName"/>
</histogram>

<histogram name="MachineLearningService.{ModelName}.LoadModelResult.Event"
    enum="MachineLearningServiceLoadModelResultEvent"
    expires_after="2027-02-01">
  <owner>amoylan@chromium.org</owner>
  <owner>ml-service-team@google.com</owner>
  <summary>
    The result of LoadModel request for model {ModelName}, which can be OK or
    some specific error. Additional error information may be found in Chrome
    logs or ml_service logs within ChromeOS logs.
  </summary>
  <token key="ModelName">
    <variant name="DocumentScanner"/>
    <variant name="GrammarChecker">
      <owner>jiwan@chromium.org</owner>
      <owner>amoylan@chromium.org</owner>
    </variant>
    <variant name="ImageAnnotator"/>
    <variant name="SmartDimModel"/>
    <variant name="Soda"/>
    <variant name="TestModel"/>
    <variant name="TextClassifier"/>
    <variant name="TextSuggester"/>
  </token>
</histogram>

<histogram name="MachineLearningService.{RequestName}.CpuTimeMicrosec"
    units="microseconds" expires_after="2027-01-31">
  <owner>amoylan@chromium.org</owner>
  <owner>ml-service-team@google.com</owner>
  <summary>
    CPU time (for one CPU core) of {RequestName} request. Reported for all
    users; users without high-resolution clocks will report 0 for short
    requests.
  </summary>
  <token key="RequestName" variants="PerformanceMetricsRequestName"/>
</histogram>

<histogram name="MachineLearningService.{RequestName}.TotalMemoryDeltaKb"
    units="KB" expires_after="2027-01-31">
  <owner>amoylan@chromium.org</owner>
  <owner>ml-service-team@google.com</owner>
  <summary>Memory usage increase caused by {RequestName} request.</summary>
  <token key="RequestName" variants="PerformanceMetricsRequestName"/>
</histogram>

</histograms>

</histogram-configuration>
