firebase_ml_log_sdk.proto 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. }
  57. // A list of error codes for various components of the system. For model downloading, the
  58. // range of error codes is 100 to 199.
  59. enum ErrorCode {
  60. // No error at all.
  61. NO_ERROR = 0;
  62. // The temporary URI to download the model has expired.
  63. URI_EXPIRED = 101;
  64. // There is no network connection when trying to download the model file or
  65. // the model info.
  66. NO_NETWORK_CONNECTION = 102;
  67. // The download started on a valid condition but didn't finish successfully.
  68. DOWNLOAD_FAILED = 104;
  69. // We received an unsuccessful http status code when trying to download the
  70. // model info. An unsuccessful http status code is a code that's neither 200
  71. // nor 304. See go/firebase-ml-model-hosting-design for a list of possible
  72. // status codes while downloading the model info.
  73. MODEL_INFO_DOWNLOAD_UNSUCCESSFUL_HTTP_STATUS = 105;
  74. // Didn't receive a model hash while trying to download the model info.
  75. MODEL_INFO_DOWNLOAD_NO_HASH = 106;
  76. // Failed to connect to the Firebase Console while trying to download the
  77. // model info.
  78. MODEL_INFO_DOWNLOAD_CONNECTION_FAILED = 107;
  79. // Model hash mismatches the expected value.
  80. MODEL_HASH_MISMATCH = 116;
  81. // An unknown error has occurred. This is for conditions that should never
  82. // happen. But we log them anyways. If there is a surge in UNKNOWN error
  83. // codes, we need to check our code.
  84. UNKNOWN_ERROR = 9999;
  85. }
  86. // Detailed information about a model.
  87. // The message used to be named "CustomModelOptions".
  88. message ModelOptions {
  89. // Inherent properties about the model: name, version, URI, source.
  90. ModelInfo model_info = 1;
  91. // True if models can be updated.
  92. bool is_model_update_enabled = 4;
  93. }
  94. // Information about model downloading. A single model download request may
  95. // result in multiple log entries. "download_status" in the log entry indicates
  96. // during which stage it is logged.
  97. // This message used to be named "CustomModelDownloadLogEvent".
  98. message ModelDownloadLogEvent {
  99. // The download status. The model download is made up of two major stages: the
  100. // retrieval of the model info in Firebase backend, and then the download of
  101. // the model file in GCS. Whether or not the download is requested implicitly
  102. // or explicitly does not affect the later stages of the download. As a
  103. // result, later stages (i.e. enum tag 3+) do not distinguish between explicit
  104. // and implicit triggering.
  105. enum DownloadStatus {
  106. UNKNOWN_STATUS = 0;
  107. // The download is requested by the developer, i.e. ensureModelDownloaded()
  108. // is called.
  109. EXPLICITLY_REQUESTED = 1;
  110. // The download is requested by the SDK implicitly.
  111. IMPLICITLY_REQUESTED = 2;
  112. // The retrieval of the model info succeeded.
  113. MODEL_INFO_RETRIEVAL_SUCCEEDED = 3;
  114. // The retrieval of the model info failed. See error_code field for details.
  115. MODEL_INFO_RETRIEVAL_FAILED = 4;
  116. // A new download with the OS downloader has been scheduled.
  117. SCHEDULED = 5;
  118. // There is an existing downloading session. No new download is scheduled.
  119. DOWNLOADING = 6;
  120. // The download of the model file succeeded.
  121. SUCCEEDED = 7;
  122. // The download of the model file failed.
  123. FAILED = 8;
  124. // Update is enabled and available while the existing model is downloaded or
  125. // live.
  126. UPDATE_AVAILABLE = 10;
  127. }
  128. // Model information and options for downloading.
  129. ModelOptions options = 1;
  130. // The rough duration of the download. This is not marked as
  131. // ST_SENSITIVE_TIMESTAMP because it is a duration instead of a timestamp.
  132. // We delegate the download to OS downloader. We may not be notified
  133. // when the download completes, such as when the app is killed.
  134. uint64 rough_download_duration_ms = 2;
  135. // The error code for model download.
  136. ErrorCode error_code = 3;
  137. // The exact duration of the download. This is not marked as
  138. // ST_SENSITIVE_TIMESTAMP because it is a duration instead of a timestamp.
  139. // We know the exact duration when the download is completed while the app is
  140. // still alive and receives the completed notification from OS downloader.
  141. uint64 exact_download_duration_ms = 4;
  142. // The download status.
  143. DownloadStatus download_status = 5;
  144. // If this field is logged for DownloadStatus.MODEL_INFO_RETRIEVAL_FAILED, it
  145. // is the http status code from the firebase console. See
  146. // go/firebase-ml-model-hosting-design. Same on both Android and iOS.
  147. // If this field is logged for DownloadStatus.FAILED, it is the http status
  148. // code on iOS, and the DownloadManager's "COLUMN_REASON" value on Android. On
  149. // iOS, the status code can be a negative integer.
  150. int64 download_failure_status = 6;
  151. }
  152. // Main log event for FirebaseMl, that contains individual API events, like model
  153. // download.
  154. // NEXT ID: 44.
  155. message FirebaseMlLogEvent {
  156. // Information about various parts of the system: app, Firebase, SDK.
  157. SystemInfo system_info = 1;
  158. // The event name.
  159. EventName event_name = 2;
  160. // Model downloading logs.
  161. // ==========================
  162. ModelDownloadLogEvent model_download_log_event = 3;
  163. }