firebase_ml_log_sdk.proto 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. // Copyright 2021 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. // This is a slimmed down version of our internal logging proto used only for
  16. // testing, to valid that the incoming json will convert as expected!
  17. // All numbers and naming should be kept consistent with the internal proto.
  18. // Information about various parts of the system: app, Firebase, SDK.
  19. message SystemInfo {
  20. // The application's unique id. On iOS, this is the bundle ID.
  21. string app_id = 1 ;
  22. // Application version string. On iOS, this is "version_number" + "#" + "build_number".
  23. string app_version = 2;
  24. // Uniquely identifiable id associated with the Firebase project. Might be an
  25. // empty string if the developer does not pass a correct FirebaseOptions with
  26. // a valid Firebase Project ID.
  27. string firebase_project_id = 3;
  28. // Firebase ML SDK version.
  29. string ml_sdk_version = 4;
  30. // The API key of the firebase project.
  31. string api_key = 7 ;
  32. }
  33. // Information about models.
  34. message ModelInfo {
  35. // The name of the model defined by the model creator. This string should be
  36. // meaningful to the creator and describes what the model does. For example,
  37. // the name can be "mobile vision face recognition" or "speech to text".
  38. string name = 1 ;
  39. // The version of the model defined by the model creator.
  40. string version = 2 ;
  41. // The expected checksum (SHA256) of the model file. Only hash of models
  42. // downloaded from cloud is logged.
  43. string hash = 5;
  44. // The model type is currently envisioned to be used mainly for model
  45. // download/update.
  46. enum ModelType {
  47. TYPE_UNKNOWN = 0;
  48. CUSTOM = 1;
  49. }
  50. ModelType model_type = 6;
  51. }
  52. enum EventName {
  53. UNKNOWN_EVENT = 0;
  54. MODEL_DOWNLOAD = 100;
  55. MODEL_UPDATE = 101;
  56. REMOTE_MODEL_DELETE_ON_DEVICE = 252;
  57. }
  58. // A list of error codes for various components of the system. For model downloading, the
  59. // range of error codes is 100 to 199.
  60. enum ErrorCode {
  61. // No error at all.
  62. NO_ERROR = 0;
  63. // The temporary URI to download the model has expired.
  64. URI_EXPIRED = 101;
  65. // There is no network connection when trying to download the model file or
  66. // the model info.
  67. NO_NETWORK_CONNECTION = 102;
  68. // The download started on a valid condition but didn't finish successfully.
  69. DOWNLOAD_FAILED = 104;
  70. // We received an unsuccessful http status code when trying to download the
  71. // model info. An unsuccessful http status code is a code that's neither 200
  72. // nor 304. See go/firebase-ml-model-hosting-design for a list of possible
  73. // status codes while downloading the model info.
  74. MODEL_INFO_DOWNLOAD_UNSUCCESSFUL_HTTP_STATUS = 105;
  75. // Didn't receive a model hash while trying to download the model info.
  76. MODEL_INFO_DOWNLOAD_NO_HASH = 106;
  77. // Failed to connect to the Firebase Console while trying to download the
  78. // model info.
  79. MODEL_INFO_DOWNLOAD_CONNECTION_FAILED = 107;
  80. // Model hash mismatches the expected value.
  81. MODEL_HASH_MISMATCH = 116;
  82. // An unknown error has occurred. This is for conditions that should never
  83. // happen. But we log them anyways. If there is a surge in UNKNOWN error
  84. // codes, we need to check our code.
  85. UNKNOWN_ERROR = 9999;
  86. }
  87. // Detailed information about a model.
  88. // The message used to be named "CustomModelOptions".
  89. message ModelOptions {
  90. // Inherent properties about the model: name, version, URI, source.
  91. ModelInfo model_info = 1;
  92. // True if models can be updated.
  93. bool is_model_update_enabled = 4;
  94. }
  95. // Information about model downloading. A single model download request may
  96. // result in multiple log entries. "download_status" in the log entry indicates
  97. // during which stage it is logged.
  98. // This message used to be named "CustomModelDownloadLogEvent".
  99. message ModelDownloadLogEvent {
  100. // The download status. The model download is made up of two major stages: the
  101. // retrieval of the model info in Firebase backend, and then the download of
  102. // the model file in GCS. Whether or not the download is requested implicitly
  103. // or explicitly does not affect the later stages of the download. As a
  104. // result, later stages (i.e. enum tag 3+) do not distinguish between explicit
  105. // and implicit triggering.
  106. enum DownloadStatus {
  107. UNKNOWN_STATUS = 0;
  108. // The download is requested by the developer, i.e. ensureModelDownloaded()
  109. // is called.
  110. EXPLICITLY_REQUESTED = 1;
  111. // The download is requested by the SDK implicitly.
  112. IMPLICITLY_REQUESTED = 2;
  113. // The retrieval of the model info succeeded.
  114. MODEL_INFO_RETRIEVAL_SUCCEEDED = 3;
  115. // The retrieval of the model info failed. See error_code field for details.
  116. MODEL_INFO_RETRIEVAL_FAILED = 4;
  117. // A new download with the OS downloader has been scheduled.
  118. SCHEDULED = 5;
  119. // There is an existing downloading session. No new download is scheduled.
  120. DOWNLOADING = 6;
  121. // The download of the model file succeeded.
  122. SUCCEEDED = 7;
  123. // The download of the model file failed.
  124. FAILED = 8;
  125. // Update is enabled and available while the existing model is downloaded or
  126. // live.
  127. UPDATE_AVAILABLE = 10;
  128. }
  129. // Model information and options for downloading.
  130. ModelOptions options = 1;
  131. // The rough duration of the download. This is not marked as
  132. // ST_SENSITIVE_TIMESTAMP because it is a duration instead of a timestamp.
  133. // We delegate the download to OS downloader. We may not be notified
  134. // when the download completes, such as when the app is killed.
  135. uint64 rough_download_duration_ms = 2;
  136. // The error code for model download.
  137. ErrorCode error_code = 3;
  138. // The exact duration of the download. This is not marked as
  139. // ST_SENSITIVE_TIMESTAMP because it is a duration instead of a timestamp.
  140. // We know the exact duration when the download is completed while the app is
  141. // still alive and receives the completed notification from OS downloader.
  142. uint64 exact_download_duration_ms = 4;
  143. // The download status.
  144. DownloadStatus download_status = 5;
  145. // If this field is logged for DownloadStatus.MODEL_INFO_RETRIEVAL_FAILED, it
  146. // is the http status code from the firebase console. See
  147. // go/firebase-ml-model-hosting-design. Same on both Android and iOS.
  148. // If this field is logged for DownloadStatus.FAILED, it is the http status
  149. // code on iOS, and the DownloadManager's "COLUMN_REASON" value on Android. On
  150. // iOS, the status code can be a negative integer.
  151. int64 download_failure_status = 6;
  152. }
  153. // Information about deleting a downloaded model on device.
  154. message DeleteModelLogEvent {
  155. // The type of the downloaded model requested to be deleted.
  156. ModelInfo.ModelType model_type = 1;
  157. // Whether the downloaded model is deleted successfully.
  158. bool is_successful = 2;
  159. }
  160. // Main log event for FirebaseMl, that contains individual API events, like model
  161. // download.
  162. // NEXT ID: 44.
  163. message FirebaseMlLogEvent {
  164. // Information about various parts of the system: app, Firebase, SDK.
  165. SystemInfo system_info = 1;
  166. // The event name.
  167. EventName event_name = 2;
  168. // Information about model download.
  169. ModelDownloadLogEvent model_download_log_event = 3;
  170. // Information about deleting a downloaded model.
  171. DeleteModelLogEvent delete_model_log_event = 40;
  172. }